ReactOS 0.4.15-dev-8236-g99f0937
psconv.h File Reference
#include <ft2build.h>
Include dependency graph for psconv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

FT_BEGIN_HEADER PS_Conv_Strtol (FT_Byte **cursor, FT_Byte *limit, FT_Long base)
 
 PS_Conv_ToInt (FT_Byte **cursor, FT_Byte *limit)
 
 PS_Conv_ToFixed (FT_Byte **cursor, FT_Byte *limit, FT_Long power_ten)
 
 PS_Conv_ASCIIHexDecode (FT_Byte **cursor, FT_Byte *limit, FT_Byte *buffer, FT_Offset n)
 
 PS_Conv_EexecDecode (FT_Byte **cursor, FT_Byte *limit, FT_Byte *buffer, FT_Offset n, FT_UShort *seed)
 

Function Documentation

◆ PS_Conv_ASCIIHexDecode()

PS_Conv_ASCIIHexDecode ( FT_Byte **  cursor,
FT_Byte limit,
FT_Byte buffer,
FT_Offset  n 
)

Definition at line 465 of file psconv.c.

469 {
470 FT_Byte* p;
471 FT_UInt r = 0;
472 FT_UInt w = 0;
473 FT_UInt pad = 0x01;
474
475
476 n *= 2;
477
478#if 1
479
480 p = *cursor;
481
482 if ( p >= limit )
483 return 0;
484
485 if ( n > (FT_UInt)( limit - p ) )
486 n = (FT_UInt)( limit - p );
487
488 /* we try to process two nibbles at a time to be as fast as possible */
489 for ( ; r < n; r++ )
490 {
491 FT_UInt c = p[r];
492
493
494 if ( IS_PS_SPACE( c ) )
495 continue;
496
497 if ( c OP 0x80 )
498 break;
499
500 c = (FT_UInt)ft_char_table[c & 0x7F];
501 if ( c >= 16 )
502 break;
503
504 pad = ( pad << 4 ) | c;
505 if ( pad & 0x100 )
506 {
507 buffer[w++] = (FT_Byte)pad;
508 pad = 0x01;
509 }
510 }
511
512 if ( pad != 0x01 )
513 buffer[w++] = (FT_Byte)( pad << 4 );
514
515 *cursor = p + r;
516
517 return w;
518
519#else /* 0 */
520
521 for ( r = 0; r < n; r++ )
522 {
523 FT_Char c;
524
525
526 if ( IS_PS_SPACE( *p ) )
527 continue;
528
529 if ( *p OP 0x80 )
530 break;
531
532 c = ft_char_table[*p & 0x7F];
533
534 if ( (unsigned)c >= 16 )
535 break;
536
537 if ( r & 1 )
538 {
539 *buffer = (FT_Byte)(*buffer + c);
540 buffer++;
541 }
542 else
543 *buffer = (FT_Byte)(c << 4);
544
545 r++;
546 }
547
548 *cursor = p;
549
550 return ( r + 1 ) / 2;
551
552#endif /* 0 */
553
554 }
OP
Definition: DragDrop.cpp:27
signed char FT_Char
Definition: fttypes.h:143
unsigned char FT_Byte
Definition: fttypes.h:154
unsigned int FT_UInt
Definition: fttypes.h:231
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLuint buffer
Definition: glext.h:5915
const GLubyte * c
Definition: glext.h:8905
GLint limit
Definition: glext.h:10326
GLfloat GLfloat p
Definition: glext.h:8902
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
const char cursor[]
Definition: icontest.c:13
#define c
Definition: ke_i.h:80
#define IS_PS_SPACE(ch)
Definition: psaux.h:1329
static const FT_Char ft_char_table[128]
Definition: psconv.c:43

Referenced by ps_parser_to_bytes().

◆ PS_Conv_EexecDecode()

PS_Conv_EexecDecode ( FT_Byte **  cursor,
FT_Byte limit,
FT_Byte buffer,
FT_Offset  n,
FT_UShort seed 
)

Definition at line 558 of file psconv.c.

563 {
564 FT_Byte* p;
565 FT_UInt r;
566 FT_UInt s = *seed;
567
568
569#if 1
570
571 p = *cursor;
572
573 if ( p >= limit )
574 return 0;
575
576 if ( n > (FT_UInt)(limit - p) )
577 n = (FT_UInt)(limit - p);
578
579 for ( r = 0; r < n; r++ )
580 {
581 FT_UInt val = p[r];
582 FT_UInt b = ( val ^ ( s >> 8 ) );
583
584
585 s = ( (val + s)*52845U + 22719 ) & 0xFFFFU;
586 buffer[r] = (FT_Byte) b;
587 }
588
589 *cursor = p + n;
590 *seed = (FT_UShort)s;
591
592#else /* 0 */
593
594 for ( r = 0, p = *cursor; r < n && p < limit; r++, p++ )
595 {
596 FT_Byte b = (FT_Byte)( *p ^ ( s >> 8 ) );
597
598
599 s = (FT_UShort)( ( *p + s ) * 52845U + 22719 );
600 *buffer++ = b;
601 }
602 *cursor = p;
603 *seed = s;
604
605#endif /* 0 */
606
607 return r;
608 }
unsigned short FT_UShort
Definition: fttypes.h:209
GLdouble s
Definition: gl.h:2039
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLuint GLfloat * val
Definition: glext.h:7180
#define b
Definition: ke_i.h:79

Referenced by t1_decrypt().

◆ PS_Conv_Strtol()

FT_BEGIN_HEADER PS_Conv_Strtol ( FT_Byte **  cursor,
FT_Byte limit,
FT_Long  base 
)

Definition at line 84 of file psconv.c.

87 {
88 FT_Byte* p = *cursor;
89
90 FT_Long num = 0;
91 FT_Bool sign = 0;
92 FT_Bool have_overflow = 0;
93
94 FT_Long num_limit;
96
97
98 if ( p >= limit )
99 goto Bad;
100
101 if ( base < 2 || base > 36 )
102 {
103 FT_TRACE4(( "!!!INVALID BASE:!!!" ));
104 return 0;
105 }
106
107 if ( *p == '-' || *p == '+' )
108 {
109 sign = FT_BOOL( *p == '-' );
110
111 p++;
112 if ( p == limit )
113 goto Bad;
114
115 /* only a single sign is allowed */
116 if ( *p == '-' || *p == '+' )
117 return 0;
118 }
119
120 num_limit = 0x7FFFFFFFL / base;
121 c_limit = (FT_Char)( 0x7FFFFFFFL % base );
122
123 for ( ; p < limit; p++ )
124 {
125 FT_Char c;
126
127
128 if ( IS_PS_SPACE( *p ) || *p OP 0x80 )
129 break;
130
131 c = ft_char_table[*p & 0x7F];
132
133 if ( c < 0 || c >= base )
134 break;
135
136 if ( num > num_limit || ( num == num_limit && c > c_limit ) )
137 have_overflow = 1;
138 else
139 num = num * base + c;
140 }
141
142 *cursor = p;
143
144 if ( have_overflow )
145 {
146 num = 0x7FFFFFFFL;
147 FT_TRACE4(( "!!!OVERFLOW:!!!" ));
148 }
149
150 if ( sign )
151 num = -num;
152
153 return num;
154
155 Bad:
156 FT_TRACE4(( "!!!END OF DATA:!!!" ));
157 return 0;
158 }
#define FT_TRACE4(varformat)
Definition: ftdebug.h:161
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
signed long FT_Long
Definition: fttypes.h:242
#define FT_BOOL(x)
Definition: fttypes.h:578
GLuint GLuint num
Definition: glext.h:9618
#define sign(x)
Definition: mapdesc.cc:613
@ c_limit
Definition: synths.h:13

Referenced by PS_Conv_ToInt().

◆ PS_Conv_ToFixed()

PS_Conv_ToFixed ( FT_Byte **  cursor,
FT_Byte limit,
FT_Long  power_ten 
)

Definition at line 196 of file psconv.c.

199 {
200 FT_Byte* p = *cursor;
201 FT_Byte* curp;
202
203 FT_Fixed integral = 0;
204 FT_Long decimal = 0;
205 FT_Long divider = 1;
206
207 FT_Bool sign = 0;
208 FT_Bool have_overflow = 0;
209 FT_Bool have_underflow = 0;
210
211
212 if ( p >= limit )
213 goto Bad;
214
215 if ( *p == '-' || *p == '+' )
216 {
217 sign = FT_BOOL( *p == '-' );
218
219 p++;
220 if ( p == limit )
221 goto Bad;
222
223 /* only a single sign is allowed */
224 if ( *p == '-' || *p == '+' )
225 return 0;
226 }
227
228 /* read the integer part */
229 if ( *p != '.' )
230 {
231 curp = p;
232 integral = PS_Conv_ToInt( &p, limit );
233
234 if ( p == curp )
235 return 0;
236
237 if ( integral > 0x7FFF )
238 have_overflow = 1;
239 else
240 integral = (FT_Fixed)( (FT_UInt32)integral << 16 );
241 }
242
243 /* read the decimal part */
244 if ( p < limit && *p == '.' )
245 {
246 p++;
247
248 for ( ; p < limit; p++ )
249 {
250 FT_Char c;
251
252
253 if ( IS_PS_SPACE( *p ) || *p OP 0x80 )
254 break;
255
256 c = ft_char_table[*p & 0x7F];
257
258 if ( c < 0 || c >= 10 )
259 break;
260
261 /* only add digit if we don't overflow */
262 if ( divider < 0xCCCCCCCL && decimal < 0xCCCCCCCL )
263 {
264 decimal = decimal * 10 + c;
265
266 if ( !integral && power_ten > 0 )
267 power_ten--;
268 else
269 divider *= 10;
270 }
271 }
272 }
273
274 /* read exponent, if any */
275 if ( p + 1 < limit && ( *p == 'e' || *p == 'E' ) )
276 {
277 FT_Long exponent;
278
279
280 p++;
281
282 curp = p;
283 exponent = PS_Conv_ToInt( &p, limit );
284
285 if ( curp == p )
286 return 0;
287
288 /* arbitrarily limit exponent */
289 if ( exponent > 1000 )
290 have_overflow = 1;
291 else if ( exponent < -1000 )
292 have_underflow = 1;
293 else
294 power_ten += exponent;
295 }
296
297 *cursor = p;
298
299 if ( !integral && !decimal )
300 return 0;
301
302 if ( have_overflow )
303 goto Overflow;
304 if ( have_underflow )
305 goto Underflow;
306
307 while ( power_ten > 0 )
308 {
309 if ( integral >= 0xCCCCCCCL )
310 goto Overflow;
311 integral *= 10;
312
313 if ( decimal >= 0xCCCCCCCL )
314 {
315 if ( divider == 1 )
316 goto Overflow;
317 divider /= 10;
318 }
319 else
320 decimal *= 10;
321
322 power_ten--;
323 }
324
325 while ( power_ten < 0 )
326 {
327 integral /= 10;
328 if ( divider < 0xCCCCCCCL )
329 divider *= 10;
330 else
331 decimal /= 10;
332
333 if ( !integral && !decimal )
334 goto Underflow;
335
336 power_ten++;
337 }
338
339 if ( decimal )
340 {
341 decimal = FT_DivFix( decimal, divider );
342 /* it's not necessary to check this addition for overflow */
343 /* due to the structure of the real number representation */
344 integral += decimal;
345 }
346
347 Exit:
348 if ( sign )
349 integral = -integral;
350
351 return integral;
352
353 Bad:
354 FT_TRACE4(( "!!!END OF DATA:!!!" ));
355 return 0;
356
357 Overflow:
358 integral = 0x7FFFFFFFL;
359 FT_TRACE4(( "!!!OVERFLOW:!!!" ));
360 goto Exit;
361
362 Underflow:
363 FT_TRACE4(( "!!!UNDERFLOW:!!!" ));
364 return 0;
365 }
FT_DivFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:608
signed long FT_Fixed
Definition: fttypes.h:288
PS_Conv_ToInt(FT_Byte **cursor, FT_Byte *limit)
Definition: psconv.c:162
static void Exit(void)
Definition: sock.c:1330

Referenced by afm_parser_read_vals(), ps_parser_load_field(), ps_parser_to_fixed(), ps_tocoordarray(), and ps_tofixedarray().

◆ PS_Conv_ToInt()

PS_Conv_ToInt ( FT_Byte **  cursor,
FT_Byte limit 
)

Definition at line 162 of file psconv.c.

165 {
166 FT_Byte* p = *cursor;
167 FT_Byte* curp;
168
169 FT_Long num;
170
171
172 curp = p;
173 num = PS_Conv_Strtol( &p, limit, 10 );
174
175 if ( p == curp )
176 return 0;
177
178 if ( p < limit && *p == '#' )
179 {
180 p++;
181
182 curp = p;
183 num = PS_Conv_Strtol( &p, limit, num );
184
185 if ( p == curp )
186 return 0;
187 }
188
189 *cursor = p;
190
191 return num;
192 }
PS_Conv_Strtol(FT_Byte **cursor, FT_Byte *limit, FT_Long base)
Definition: psconv.c:84

Referenced by afm_parser_read_vals(), PS_Conv_ToFixed(), ps_parser_load_field(), and ps_parser_to_int().