| 1 |
/* param_routines.c: Data structures for parameter lists. |
| 2 |
|
| 3 |
This file is part of Omega, |
| 4 |
which is based on the web2c distribution of TeX, |
| 5 |
|
| 6 |
Copyright (c) 1994--2001 John Plaice and Yannis Haralambous |
| 7 |
|
| 8 |
Omega is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 2 of the License, or |
| 11 |
(at your option) any later version. |
| 12 |
|
| 13 |
Omega is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with Omega; if not, write to the Free Software Foundation, Inc., |
| 20 |
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
| 21 |
|
| 22 |
*/ |
| 23 |
|
| 24 |
#include "cpascal.h" |
| 25 |
#include "list_routines.h" |
| 26 |
#include "manifests.h" |
| 27 |
#include "header_routines.h" |
| 28 |
#include "param_routines.h" |
| 29 |
#include "print_routines.h" |
| 30 |
#include "out_routines.h" |
| 31 |
#include "error_routines.h" |
| 32 |
#include "out_ofm.h" |
| 33 |
|
| 34 |
#define PARAM_MIN 1 |
| 35 |
|
| 36 |
av_list param_list = NULL; |
| 37 |
int param_max = PARAM_MIN-1; |
| 38 |
int param_started = FALSE; |
| 39 |
|
| 40 |
unsigned np=0; |
| 41 |
|
| 42 |
void |
| 43 |
init_parameters(void) |
| 44 |
{ |
| 45 |
if (param_started==TRUE) |
| 46 |
warning_0("FONTDIMEN previously defined; all old parameters ignored"); |
| 47 |
if (param_list!=NULL) { |
| 48 |
av_list L1 = param_list, L2; |
| 49 |
while (L1 != NULL) { |
| 50 |
L2 = L1->ptr; |
| 51 |
free(L1); |
| 52 |
L1 = L2; |
| 53 |
} |
| 54 |
} |
| 55 |
param_list = NULL; |
| 56 |
param_max = PARAM_MIN-1; |
| 57 |
np=param_max; |
| 58 |
param_started = TRUE; |
| 59 |
} |
| 60 |
|
| 61 |
void |
| 62 |
set_param_word(int index, int val) |
| 63 |
{ |
| 64 |
av_list L1, L2; |
| 65 |
|
| 66 |
if (index < PARAM_MIN) { |
| 67 |
warning_0("PARAMETER index must be at least 1; ignored"); |
| 68 |
return; |
| 69 |
} |
| 70 |
L1 = param_list; |
| 71 |
if (L1 == NULL) { |
| 72 |
param_list = av_list1(index, val); |
| 73 |
param_max = index; |
| 74 |
np=param_max; |
| 75 |
} else { |
| 76 |
L2 = L1->ptr; |
| 77 |
while ((L2 != NULL) && (lattr(L2) <= index)) { |
| 78 |
L1 = L2; |
| 79 |
L2 = L2->ptr; |
| 80 |
} |
| 81 |
if (index < lattr(L1)) { |
| 82 |
param_list = av_list1(index, val); |
| 83 |
param_list->ptr = L1; |
| 84 |
} else if (index == lattr(L1)) { |
| 85 |
warning_1("PARAMETER index (%d) previously defined; " |
| 86 |
"old value ignored", index); |
| 87 |
lval(L1) = val; |
| 88 |
} else { |
| 89 |
if (L2==NULL) {param_max=index; np=param_max;} |
| 90 |
L2 = av_list1(index, val); |
| 91 |
L2->ptr = L1->ptr; |
| 92 |
L1->ptr = L2; |
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
void |
| 98 |
retrieve_parameters(unsigned char *table) |
| 99 |
{ |
| 100 |
int value; |
| 101 |
unsigned i; |
| 102 |
unsigned np_prime = np; |
| 103 |
|
| 104 |
param_list = NULL; |
| 105 |
for (i=1; i<=np_prime; i++) { |
| 106 |
value = ((table[4*i] & 0xff) << 24) | |
| 107 |
((table[4*i+1] & 0xff) << 16) | |
| 108 |
((table[4*i+2] & 0xff) << 8) | |
| 109 |
(table[4*i+3] & 0xff); |
| 110 |
if ((i<=7) | (value != 0)) { |
| 111 |
set_param_word(i, value); |
| 112 |
} |
| 113 |
} |
| 114 |
np = np_prime; |
| 115 |
} |
| 116 |
|
| 117 |
void |
| 118 |
print_parameters(void) |
| 119 |
{ |
| 120 |
av_list L = param_list; |
| 121 |
|
| 122 |
if (L == NULL) |
| 123 |
return; |
| 124 |
|
| 125 |
print_font_dimension(); |
| 126 |
while (L != NULL) { |
| 127 |
print_parameter(lattr(L), lval(L)); |
| 128 |
L = L->ptr; |
| 129 |
} |
| 130 |
right(); |
| 131 |
} |
| 132 |
|
| 133 |
static void |
| 134 |
output_ofm_one_parameter(unsigned i, fix param) |
| 135 |
{ |
| 136 |
if (i==P_SLANT) out_ofm_4(param); |
| 137 |
else out_ofm_scaled(param); |
| 138 |
} |
| 139 |
|
| 140 |
void |
| 141 |
output_ofm_parameter(void) |
| 142 |
{ |
| 143 |
unsigned i=1, j; |
| 144 |
|
| 145 |
av_list L = param_list; |
| 146 |
|
| 147 |
while(L != NULL) { |
| 148 |
j=lattr(L); |
| 149 |
while (i<j) { |
| 150 |
output_ofm_one_parameter(i, 0); |
| 151 |
i++; |
| 152 |
} |
| 153 |
output_ofm_one_parameter(i, lval(L)); |
| 154 |
L = L->ptr; i++; |
| 155 |
} |
| 156 |
} |