Back to index

tetex-bin  3.0
param_routines.c
Go to the documentation of this file.
00001 /* param_routines.c: Data structures for parameter lists.
00002 
00003 This file is part of Omega,
00004 which is based on the web2c distribution of TeX,
00005 
00006 Copyright (c) 1994--2001 John Plaice and Yannis Haralambous
00007 
00008 Omega is free software; you can redistribute it and/or modify
00009 it under the terms of the GNU General Public License as published by
00010 the Free Software Foundation; either version 2 of the License, or
00011 (at your option) any later version.
00012 
00013 Omega is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Omega; if not, write to the Free Software Foundation, Inc.,
00020 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00021 
00022 */
00023 
00024 #include "cpascal.h"
00025 #include "list_routines.h"
00026 #include "manifests.h"
00027 #include "header_routines.h"
00028 #include "param_routines.h"
00029 #include "print_routines.h"
00030 #include "out_routines.h"
00031 #include "error_routines.h"
00032 #include "out_ofm.h"
00033 
00034 #define PARAM_MIN 1
00035 
00036 av_list param_list = NULL;
00037 int param_max = PARAM_MIN-1;
00038 int param_started = FALSE;
00039 
00040 unsigned np=0;
00041 
00042 void
00043 init_parameters(void)
00044 {
00045     if (param_started==TRUE)
00046     warning_0("FONTDIMEN previously defined;  all old parameters ignored");
00047     if (param_list!=NULL) {
00048         av_list L1 = param_list, L2;
00049         while (L1 != NULL) {
00050            L2 = L1->ptr;
00051            free(L1);
00052            L1 = L2;
00053         }
00054     }
00055     param_list = NULL;
00056     param_max = PARAM_MIN-1;
00057     np=param_max;
00058     param_started = TRUE;
00059 }
00060 
00061 void
00062 set_param_word(int index, int val)
00063 {
00064     av_list L1, L2;
00065 
00066     if (index < PARAM_MIN) {
00067         warning_0("PARAMETER index must be at least 1; ignored");
00068         return;
00069     }
00070     L1 = param_list;
00071     if (L1 == NULL) {
00072         param_list = av_list1(index, val);
00073         param_max = index;
00074         np=param_max;
00075     } else {
00076         L2 = L1->ptr;
00077         while ((L2 != NULL) && (lattr(L2) <= index)) {
00078             L1 = L2;
00079             L2 = L2->ptr;
00080         }
00081         if (index < lattr(L1)) {
00082             param_list = av_list1(index, val);
00083             param_list->ptr = L1;
00084        } else if (index == lattr(L1)) {
00085         warning_1("PARAMETER index (%d) previously defined; "
00086                   "old value ignored", index);
00087             lval(L1)  = val;
00088         } else {
00089             if (L2==NULL) {param_max=index; np=param_max;}
00090             L2 = av_list1(index, val);
00091             L2->ptr = L1->ptr;
00092             L1->ptr = L2;
00093         }
00094     }
00095 }
00096 
00097 void
00098 retrieve_parameters(unsigned char *table)
00099 {
00100     int value;
00101     unsigned i;
00102     unsigned np_prime = np;
00103 
00104     param_list = NULL;
00105     for (i=1; i<=np_prime; i++) {
00106         value = ((table[4*i] & 0xff) << 24) |
00107                 ((table[4*i+1] & 0xff) << 16) |
00108                 ((table[4*i+2] & 0xff) << 8) |
00109                 (table[4*i+3] & 0xff);
00110         if ((i<=7) | (value != 0)) {
00111            set_param_word(i, value);
00112         }
00113     }
00114     np = np_prime;
00115 }
00116 
00117 void
00118 print_parameters(void)
00119 {
00120     av_list L = param_list;
00121 
00122     print_font_dimension();
00123     while (L != NULL) {
00124        print_parameter(lattr(L), lval(L));
00125        L = L->ptr;
00126     }
00127     right();
00128 }
00129 
00130 
00131 void
00132 output_ofm_parameter(void)
00133 {
00134     unsigned i=1, j;
00135 
00136     av_list L = param_list;
00137 
00138     while(L != NULL) {
00139        j=lattr(L);
00140        while (i<j) {
00141            output_ofm_one_parameter(i, 0);
00142            i++;
00143        }
00144        output_ofm_one_parameter(i, lval(L));
00145        L = L->ptr; i++;
00146     }
00147 }
00148 
00149 void
00150 output_ofm_one_parameter(unsigned i, fix param)
00151 {
00152     if (i==P_SLANT) out_ofm_4(param);
00153     else out_ofm_scaled(param);
00154 }