Back to index

tetex-bin  3.0
t1part.c
Go to the documentation of this file.
00001 /*
00002  *   T1part.c version 1.59 beta  Copyright (C)1994, 1996
00003  *   by Sergey Lesenko
00004  *   lesenko@mx.ihep.su
00005  *
00006  *   It is distributed with no warranty of any kind.
00007  *   You may modify and use this program. It can be included
00008  *   in any distribution, commercial or otherwise, so long as
00009  *   copyright notice be preserved on all copies.
00010  */
00011 #include "dvips.h"
00012 #include "t1part.h"
00013 #ifndef SEEK_SET
00014 #define SEEK_SET (0)
00015 #endif
00016 
00017 #ifdef BORLANDC
00018 void huge *UniGetMem(size)
00019 ub4 size ;
00020 {
00021     void huge *tmp;
00022     if ((tmp =(void huge*) farcalloc(1L, size)) == NULL)
00023     {
00024         fprintf(stderr,"Error allocating far memory\n");
00025         exit(1);
00026     }
00027     return tmp;
00028 }
00029 #else
00030 #define  UniGetMem  getmem
00031 #endif
00032 
00033 #ifdef WIN32
00034 /* CHAR is typedef'd by <windows.h> -- popineau@esemetz.ese-metz.fr.  */
00035 #define CHAR CHARACTER
00036 #endif
00037 
00038 typedef struct Char
00039 {
00040     unsigned char *name;
00041     int length;
00042     int num;
00043     int choose;
00044     struct Char *NextChar;
00045 }
00046 CHAR;
00047 
00048 typedef struct String
00049 {
00050     unsigned char *name;
00051     int num;
00052     struct String *NextStr;
00053 }
00054 STRING;
00055 
00056 static STRING *FirstStr;
00057 static STRING *RevStr;
00058 
00059 static CHAR *FirstChar;
00060 static CHAR *FirstCharA;
00061 CHAR *FirstCharB;
00062 static CHAR *FirstCharW;
00063 
00064 int CharCount;
00065 int GridCount;
00066 int ind_ref;
00067 
00068 int LoadVector P2H(int, CHAR *) ;
00069 int Afm P1H(void) ;
00070 
00071 typedef struct
00072 {
00073     int num[4];
00074     int select;
00075 }
00076 def_ref;
00077 
00078 def_ref refer[10];
00079 
00080 #ifndef min
00081 #define min(a, b) ((a) < (b) ? (a) : (b))
00082 #endif
00083 
00084 #ifndef max
00085 #define max(a, b) ((a) > (b) ? (a) : (b))
00086 #endif
00087 
00088 
00089 #define PFA              1
00090 #define PFB              2
00091 
00092 
00093 #define NOTHING          0
00094 #define FLG_ASCII        1
00095 #define FLG_BINARY       2
00096 #define FLG_EOF          3
00097 #define FLG_ZERO_LINE    4
00098 
00099 #define FLG_OUT_STR    (-1)
00100 #define CHAR_NOT_DEF   (-1)
00101 #define SEAC_NOT_END   (-2)
00102 
00103 #define FLG_LOAD_BASE   (1)
00104 
00105 #define STANDARD_ENC    (1)
00106 #define SPECIAL_ENC     (2)
00107 #define AFM_ENC         (4)
00108 
00109 
00110 #define FLG_REENCODE    (4)
00111 
00112 
00113 #define BYTES_PER_LINE  32
00114 
00115 #ifndef KPATHSEA_TYPES_H
00116 #define TRUE             1
00117 #define FALSE            0
00118 #endif /* not KPATHSEA_TYPES_H */
00119 
00120 #define LENIV            0
00121 #define SUBRS            1
00122 #define CHARSTRINGS      2
00123 
00124 #define ERR_FIRST_NUM  (-1)
00125 #define ERR_SECOND_NUM (-2)
00126 #define ERR_FIRST_TOK  (-3)
00127 #define ERR_SECOND_TOK (-4)
00128 #define ERR_STACK      (-5)
00129 #define ERR_NUM_CHAR   (-6)
00130 #define ERR_NAME_CHAR  (-7)
00131 
00132 #define SUBR_STR         1
00133 #define CHAR_STR        -1
00134 #define CHAR_SEAC       -2
00135 #define SKIP_ON_DUP      3
00136 
00137 #define C1           52845
00138 #define C2           22719
00139 #define EDR          55665
00140 #define EER          55665
00141 #define CDR           4330
00142 
00143 #define MAX_ESCAPE      33
00144 
00145 #define HSTEM            1
00146 #define VSTEM            3
00147 #define VMOVETO          4
00148 #define CHARS_RLINETO    5
00149 #define HLINETO          6
00150 #define VLINETO          7
00151 #define RRCURVETO        8
00152 #define CHARS_CLOSEPATH  9
00153 #define CALLSUBR        10
00154 #define RETURN          11
00155 #define ESCAPE          12
00156 #define HSBW            13
00157 #define ENDCHAR         14
00158 #define CHARS_RMOVETO   21
00159 #define HMOVETO         22
00160 #define VHCURVETO       30
00161 #define HVCURVETO       31
00162 
00163 #define DOTSECTION       0
00164 #define VSTEM3           1
00165 #define HSTEM3           2
00166 #define SEAC             6
00167 #define SBW              7
00168 #define CHARS_DIV       12
00169 #define CALLOTHERSUBR   16
00170 #define POP             17
00171 #define SETCURRENTPOINT 33
00172 
00173 typetemp  _HUGE   *temp;
00174 typetemp  _HUGE   *begin_of_scan;
00175 typetemp  _HUGE   *end_of_scan;
00176 unsigned char *line;
00177 unsigned char *tmpline;
00178 unsigned char token[64];
00179 unsigned char notdef[]="/.notdef";
00180 unsigned char grid[256];
00181 unsigned char tmpgrid[256];
00182 unsigned char psfontfile[500]; /* really should dynamically allocate */
00183 unsigned char psvectfile[500];
00184 unsigned char basevect[]="ad.enc";
00185 unsigned char version[] = "v1.59 beta (c)1994, 1996";
00186 unsigned char tmp_token[64];
00187 /* static int j = 0; */
00188 static int stack[128];
00189 
00190 ub1 buf[BUFSIZ];
00191 
00192 int loadbase = 0;
00193 static int encode;
00194 static int reencode;
00195 
00196 int find_encod;
00197 int lastpart=0;
00198 int keep_flg=0;
00199 int keep_num=0;
00200 
00201 int  number;
00202 int  offset;
00203 long value;
00204 int  lenIV = 4;
00205 
00206 static int grow=0;
00207 static int level;
00208 static int flg_seac=0;
00209 
00210 typedef struct
00211 {
00212     char *command;
00213     int code;
00214 }
00215 tablecommand;
00216 
00217 tablecommand TableCommand[] =
00218 {
00219     {"callsubr", CALLSUBR}, {"callothersubr", CALLOTHERSUBR},
00220     {"pop", POP }, {"seac", SEAC}, {""}
00221 };
00222 
00223 typedef struct
00224 {
00225     char *extension;
00226     int num;
00227 }
00228 typefonts;
00229 
00230 
00231 typefonts TypeFonts[] =
00232 {
00233     {".pfa", PFA}, {".pfb", PFB},
00234     {".PFA", PFA}, {".PFB", PFB}, {""}
00235 };
00236 
00237 static char Dup[]="dup";
00238 
00239 typedef struct
00240 {
00241     typetemp  _HUGE  *begin;
00242     int   length;
00243     int   type;
00244     int   offset;
00245     int   oldnum;
00246     int   newnum;
00247 }
00248 def_key;
00249 
00250 def_key keyword[6];
00251 
00252 int FirstKey, current;
00253 
00254 int subrs, char_str;
00255 
00256 
00257 typedef struct
00258 {
00259     char *name;
00260     int num;
00261 }
00262 type_key;
00263 
00264 
00265 type_key Key[] =
00266 {
00267     {"/LenIV", LENIV}, {"/Subrs", SUBRS}, {"/CharStrings", CHARSTRINGS},  {""}
00268 };
00269 
00270 
00271 struct def_label
00272 {
00273     typetemp  _HUGE   *begin;
00274     unsigned char skip;
00275     int length;
00276     short select;
00277     int num;
00278 };
00279 
00280 struct def_label label[NUM_LABEL];
00281 
00282 
00283 
00284 int DefTypeFont
00285 P1C(unsigned char *,name)
00286 {
00287     int i;
00288 
00289     for(i=0;*TypeFonts[i].extension;i++)
00290     {
00291         if(strstr((char *)name,TypeFonts[i].extension)!=0)
00292             return(TypeFonts[i].num);
00293     }
00294     return -1;
00295 }
00296 
00297 int GetZeroLine
00298 P1C(unsigned char *, str)
00299 {
00300     int token_type=0;
00301     if(*str!='0')
00302     {
00303         return (token_type=0);
00304     }
00305     while(*str=='0')
00306     {
00307         str++;
00308     }
00309 
00310     if(*str=='\n' || *str=='\r')
00311         token_type= -1;
00312     else
00313         token_type=0;
00314     return(token_type);
00315 }
00316 
00317 /* We get token type and its content for ASCII code */
00318 
00319 int GetWord
00320 P1C(unsigned char *, mem)
00321 {
00322     int  token_type=0;
00323     register unsigned char *tmp;
00324     tmp=mem;
00325     *tmp= *line;
00326     while((*line!='\0')&&(*line!='%'))
00327     {
00328         if(*line=='-')
00329         {
00330             *tmp++= *line++;
00331         }
00332 
00333         if(isdigit(*line))
00334         {
00335             while(isdigit(*line))
00336             {
00337                 *tmp++= *line++;
00338             }
00339             *tmp = '\0';
00340             return 5;
00341         }
00342 
00343         if(*line=='/')
00344         {
00345             *tmp++= *line++; token_type=1;
00346         }
00347         if(*line=='.')
00348         {
00349             *tmp++= *line++;
00350 
00351             if(token_type==1)
00352             {
00353                 if(*line==' ')
00354                 {
00355                     *tmp = '\0';
00356                     return(token_type=token_type+2);
00357                 }
00358             }
00359         }
00360         if(isalpha(*line))
00361         {
00362             *tmp++ = *line++ ;
00363             while(!isspace(*line) && *line != '/')
00364                 *tmp++= *line++;
00365             *tmp = '\0';
00366             return(token_type=token_type+2);
00367         }
00368 
00369         token_type=0;
00370         tmp=mem;
00371         line++;
00372     }
00373     return(token_type= -1);
00374 }
00375 
00376 /* We get token type and its content for BINARY code */
00377 
00378 int GetToken P1H(void)
00379 {
00380     register unsigned char *tmp;
00381     int token_type=0;
00382 
00383     tmp=token;
00384 
00385     *tmp= *temp;
00386     while(temp<end_of_scan)
00387     {
00388         if(*temp=='/')
00389         {
00390             *tmp++= *temp++; token_type=1;
00391         }
00392 
00393         if(*temp=='.')
00394         {
00395             *tmp++= *temp++;
00396             token_type++;
00397         }
00398 
00399         if(isalpha(*temp))
00400         {
00401             while(isalnum(*temp) || *temp == '.')
00402                 *tmp++= *temp++;
00403 
00404             *tmp = '\0';
00405 
00406             return(token_type=token_type+2);
00407         }
00408         token_type=0;
00409         tmp=token;
00410         temp++;
00411     }
00412     return(token_type= -1);
00413 }
00414 
00415 int GetNum P1H(void)
00416 {
00417     unsigned char *tmp;
00418     tmp=token;
00419     *tmp= *temp;
00420 
00421     while(temp<end_of_scan)
00422     {
00423         if(isdigit(*temp))
00424         {
00425             while(isdigit(*temp))
00426                 *tmp++= *temp++;
00427             *tmp = '\0';
00428             return(atoi((char *)token));
00429         }
00430         temp++;
00431     }
00432 
00433     return -1;
00434 }
00435 
00436 /* We pass token without definition its type, it's for speed */
00437 
00438 int PassToken P1H(void)
00439 {
00440     while(temp < end_of_scan)
00441     {
00442         if(!isspace(*temp))
00443         {
00444             while(!isspace(*temp))
00445                 temp++;
00446             return 1;
00447         }
00448         temp++;
00449     }
00450     return -1;
00451 }
00452 
00453 /*                                                */
00454 /*  Simple pass off without charstring decrypting */
00455 /*                                                */
00456 
00457 int PassString
00458 P1C(unsigned char, flg)
00459 {
00460     int len_str;
00461 
00462     len_str=GetNum();
00463     if(len_str<0)
00464     {
00465         return ERR_SECOND_NUM;
00466     }
00467 
00468     if(PassToken()<0)
00469         return  ERR_FIRST_TOK;
00470 
00471 
00472     if(flg==1)
00473     {
00474         label[number].length = len_str;
00475         label[number].skip = temp - label[number].begin;
00476     }
00477 
00478     temp= temp+1+len_str;
00479 
00480     if(PassToken()<0)
00481         return ERR_SECOND_TOK;
00482     return 1;
00483 }
00484 
00485 void *getmem
00486 P1C(unsigned, size)
00487 {
00488     void *tmp;
00489     if ((tmp = calloc(1, size)) == NULL)
00490     {
00491         fprintf(stderr,"Error allocating memory\n");
00492         exit(1);
00493     }
00494     return tmp;
00495 }
00496 
00497 CHAR *AddChar P3C(CHAR *, TmpChar, unsigned char *, CharName, int, num)
00498 {
00499     int length;
00500 
00501     CHAR *ThisChar = (CHAR*) getmem(sizeof(CHAR));
00502     length         = strlen((char *) CharName);
00503     ThisChar->name = (unsigned char *) getmem(length+1);
00504     strcpy((char *) ThisChar->name, (char *) CharName);
00505     ThisChar->length= length;
00506     ThisChar->num=num;
00507     ThisChar->NextChar = TmpChar;
00508     TmpChar = ThisChar;
00509     return TmpChar;
00510 }
00511 
00512 
00513 void AddStr P2C(unsigned char *, name, int, num)
00514 {
00515     int length;
00516 
00517     STRING *ThisStr = (STRING *) getmem(sizeof(STRING));
00518     length         = strlen((char *) name);
00519     ThisStr->name = (unsigned char *) getmem(length+1);
00520     strcpy((char *) ThisStr->name, (char *) name);
00521     ThisStr->num=num;
00522 
00523     ThisStr->NextStr = FirstStr;
00524     FirstStr = ThisStr;
00525 }
00526 
00527 
00528 /* We prepare own encoding vector for output */
00529 
00530 void RevChar P1C(CHAR *, TmpChar)
00531 {
00532     int i;
00533     CHAR *ThisChar = TmpChar;
00534 
00535     while (ThisChar != NULL)
00536     {
00537             for(i=keyword[char_str].offset-1; i < number; i++)
00538             {
00539                  if(ThisChar->num == label[i].num)
00540                  {
00541                     if (label[i].select==FLG_BINARY)
00542                     {
00543                         CHAR *Rev_Char     = (CHAR *) getmem(sizeof(CHAR));
00544                         Rev_Char->name     = ThisChar->name;
00545                         Rev_Char->num      = ThisChar->num;
00546 
00547                         Rev_Char->NextChar = FirstCharW;
00548                         FirstCharW         = Rev_Char;
00549                         break;
00550                     }
00551                 }
00552             }
00553         ThisChar = ThisChar->NextChar;
00554     }
00555 }
00556 
00557 /* And here we produce own resulting encoding vector for partial font */
00558 
00559 void OutChar
00560 P2C(CHAR *, TmpChar, FILE *, fout)
00561 {
00562 
00563     CHAR *ThisChar = TmpChar;
00564 
00565     while (ThisChar != NULL)
00566     {
00567         CHAR *tm = ThisChar;
00568         if (ThisChar->num >= 0)
00569 #ifdef SHIFTLOWCHARS
00570            fprintf(fout, "dup %d %s put\n",T1Char(ThisChar->num),ThisChar->name);
00571 #else
00572            fprintf(fout, "dup %d %s put\n",ThisChar->num,ThisChar->name);
00573 #endif
00574         ThisChar = ThisChar->NextChar;
00575         free(tm);
00576     }
00577 
00578     FirstCharW = NULL;
00579 }
00580 
00581 
00582 
00583 
00584 /* We prepare strings list for output */
00585 
00586 void Reeverse P1C(STRING *, TmpStr)
00587 {
00588 
00589     int tmp;
00590 
00591     if(encode==AFM_ENC)
00592         tmp = -2;
00593     else
00594         tmp=0;
00595 
00596 
00597     while (TmpStr != NULL)
00598     {
00599 
00600         if(TmpStr->num < tmp)
00601         {
00602             STRING *ThisStr   = (STRING *) getmem(sizeof(STRING));
00603             ThisStr->name     = TmpStr->name;
00604 
00605             ThisStr->NextStr = RevStr;
00606             RevStr         = ThisStr;
00607         }
00608         TmpStr = TmpStr->NextStr;
00609     }
00610 }
00611 
00612 
00613 /* And here we post strings to out */
00614 
00615 void OutStr
00616 P2C(STRING *, TmpStr, FILE *, fout)
00617 {
00618     STRING *ThisStr = TmpStr;
00619     if(encode==AFM_ENC)
00620         fprintf(fout, "readonly def\n");
00621     while (ThisStr != NULL)
00622     {
00623         STRING *tm = ThisStr;
00624         fprintf(fout, "%s",ThisStr->name);
00625         ThisStr = ThisStr->NextStr;
00626         free(tm);
00627     }
00628     RevStr = NULL;
00629 }
00630 
00631 
00632 
00633 
00634 
00635 
00636 void PrintChar P1C(CHAR *, TmpChar)
00637 {
00638     CHAR *ThisChar = TmpChar;
00639     while (ThisChar != NULL)
00640     {
00641         if(ThisChar->choose==1)
00642         {
00643             fprintf(stderr, " Debug: Char %d '%s'\n",
00644                     ThisChar->num,ThisChar->name);
00645         }
00646         ThisChar = ThisChar->NextChar;
00647     }
00648 
00649 }
00650 
00651 
00652 int ClearB P1H(void)
00653 {
00654     CHAR *ThisChar = FirstCharB;
00655     while (ThisChar != NULL)
00656     {
00657         ThisChar->choose=0;
00658         ThisChar = ThisChar->NextChar;
00659     }
00660     return 1;
00661 }
00662 
00663 /* We mark chars in encoding vector thanks same names from
00664 reencoding vector */
00665 
00666 int ChooseChar
00667 P2C(unsigned char *, name, CHAR *, TmpChar)
00668 {
00669     int length;
00670     CHAR *ThisChar = TmpChar;
00671     length=strlen((char *) name);
00672     while (ThisChar != NULL)
00673     {
00674         CHAR *NextChar = ThisChar->NextChar;
00675         if(ThisChar->length==length)
00676         {
00677             if (strcmp((char *) name, (char *) ThisChar->name) == 0)
00678             {
00679                 ThisChar->choose=1;
00680                 return  1;
00681             }
00682         }
00683 /*
00684  *   If we couldn't find it, NextChar is NULL here.  We fake up an entry
00685  *   (assuming it really does exist in the font).  Fix is from Melissa
00686  *   O'Neill; bugs in application of fix due to me.
00687  */
00688         if (NextChar == 0) {
00689            NextChar = (CHAR *) getmem(sizeof(CHAR)) ;
00690            NextChar->name = (unsigned char *) getmem(length + 1) ;
00691            strcpy((char *) NextChar->name, (char *) name) ;
00692            NextChar->length = length ;
00693            NextChar->num = -1 ;
00694            NextChar->NextChar = 0 ;
00695            NextChar->choose = 1 ;
00696            ThisChar->NextChar = NextChar ;
00697         }
00698         ThisChar = NextChar;
00699     }
00700 /*
00701  *   Can't ever get here.
00702  */
00703     return -1;
00704 }
00705 
00706 /* We find index in label array for char, wich is required
00707 for compose char, if it uses SEAC command */
00708 
00709 int FindSeac
00710 P1C(int, num)
00711 {
00712     int i;
00713 
00714     for(i=keyword[char_str].offset-1; i < number; i++)
00715     {
00716         if(label[i].num==num)
00717         {
00718             return i;
00719         }
00720     }
00721     return -1;
00722 }
00723 
00724 
00725 void ClearCW P1H(CHAR *);
00726 
00727 int FindCharW P2C(unsigned char *, name, int, length)
00728 {
00729     CHAR *ThisChar = FirstCharW;
00730 
00731     int find = 0;
00732     int keep_char = 0;
00733     int tmp = 0;
00734     int tmp_num = 0;
00735 
00736     int ddd = 0;
00737 
00738 #ifdef DEBUG
00739         if(dd(D_VIEW_VECTOR))
00740         {
00741             ddd = 1;
00742         }
00743 #endif
00744 
00745     while (ThisChar != NULL)
00746     {
00747         /* since ClearCW may free ThisChar, follow the pointer now. */
00748         CHAR *NextChar = ThisChar->NextChar;
00749 
00750         if(ThisChar->length==length)
00751         {
00752             if (strcmp((char *) name, (char *) ThisChar->name) == 0)
00753             {
00754                 if(ThisChar->choose==1)
00755                 {
00756                     if(find !=2)
00757                     {
00758                         find = 2;
00759                         tmp=FLG_BINARY;
00760                         label[number].num=ThisChar->num;
00761                     }
00762                 }
00763                 else
00764                 {
00765                     keep_char = 0;
00766                     if(find != 2)
00767                     {
00768                         find = 1;
00769                         tmp_num = ThisChar->num;
00770                     }
00771                 }
00772 
00773 
00774                 if(keep_char == 0)
00775                 {
00776                     ClearCW(ThisChar);
00777                 }
00778 
00779                 if((find == 2)&&(ddd == 1))
00780                     keep_char = 1;
00781             }
00782         }
00783         ThisChar = NextChar;
00784     }
00785 
00786     if(find == 1)
00787     {
00788         tmp=NOTHING;
00789         label[number].num=tmp_num;
00790     }
00791     return tmp;
00792 }
00793 
00794 
00795 void ClearCW
00796 P1C(CHAR *, ThisChar)
00797 {
00798 
00799         if (ThisChar == FirstCharW)
00800             FirstCharW = ThisChar->NextChar;
00801         else
00802         {
00803             CHAR *tm = FirstCharW;
00804             while (tm != NULL)
00805             {
00806                 if (ThisChar == tm->NextChar)
00807                 {
00808                     tm->NextChar = ThisChar->NextChar;
00809                     break;
00810                 }
00811                 tm = tm->NextChar;
00812             }
00813         }
00814         free(ThisChar);
00815 }
00816 
00817 
00818 /* We build temporary 'work' encoding vector only for searching
00819 needed chars */
00820 
00821 int WorkVect
00822 P1C(CHAR *, TmpChar)
00823 {
00824     while (TmpChar != NULL) {
00825         {
00826             CHAR *ThisChar     = (CHAR *) getmem(sizeof(CHAR));
00827             ThisChar->name     = TmpChar->name;
00828             ThisChar->length   = TmpChar->length;
00829             ThisChar->num      = TmpChar->num;
00830             ThisChar->choose   = TmpChar->choose;
00831 
00832             ThisChar->NextChar = FirstCharW;
00833             FirstCharW         = ThisChar;
00834         }
00835         TmpChar = TmpChar->NextChar;
00836     }
00837     return 0;
00838 }
00839 
00840 
00841 void UnDefineCharsW P1H(void)
00842 {
00843     CHAR *ThisChar = FirstCharW;
00844     while (ThisChar != NULL)
00845     {
00846         CHAR *tm = ThisChar;
00847         ThisChar = ThisChar->NextChar;
00848         free(tm);
00849     }
00850     FirstCharW = NULL;
00851     CharCount = 0;
00852 }
00853 
00854 CHAR * UnDefineChars P1C(CHAR *, TmpChar)
00855 {
00856     CHAR *ThisChar = TmpChar;
00857     while (ThisChar != NULL)
00858     {
00859         CHAR *tm = ThisChar;
00860         free(ThisChar->name);
00861         ThisChar = ThisChar->NextChar;
00862         free(tm);
00863     }
00864     TmpChar = NULL;
00865     CharCount = 0;
00866     return TmpChar;
00867 }
00868 
00869 
00870 
00871 void UnDefineStr P1H(void)
00872 {
00873     STRING *ThisStr = FirstStr;
00874     while (ThisStr != NULL)
00875     {
00876         STRING *tm = ThisStr;
00877         free(ThisStr->name);
00878         ThisStr = ThisStr->NextStr;
00879         free(tm);
00880     }
00881     FirstStr = NULL;
00882 }
00883 
00884 
00885 
00886 /*                                                    */
00887 /* We mark subroutines without charstring decrypting  */
00888 /*                                                    */
00889 
00890 void ScanSubrs P1C(int, i)
00891 {
00892     int err_num;
00893     int word_type = 0;
00894     int len_dup;
00895     int num_err=0;
00896     int test=0;
00897 
00898     len_dup = strlen(Dup);
00899 
00900     for( ; number <  keyword[i].oldnum + keyword[i].offset;)
00901     {
00902         if((word_type=GetToken())>0)
00903         {
00904             if(word_type==2)
00905             {
00906                 if(!strcmp((char *) token,Dup))
00907                 {
00908                     if(test==0)
00909                         test=1;
00910                     label[number].begin = temp-len_dup;
00911 
00912                     err_num=GetNum();
00913                     if(err_num<0)
00914                         ;
00915                     else
00916                     {
00917                         if(err_num<4)
00918                         {
00919                             label[number].select=FLG_BINARY;
00920                                 keyword[i].newnum++;
00921 
00922                         }
00923                     }
00924 
00925                     label[number].num=err_num;
00926 
00927                     num_err=PassString(1);
00928 
00929                     if(num_err<0)
00930                     {
00931                         ErrorOfScan(num_err);
00932                         fprintf(stderr,"in %d Subr string", number - 1);
00933                         exit(1);
00934                     }
00935                     if(test>1)
00936                         PassToken();
00937 
00938                     number++;
00939                 }
00940                 else
00941                 {
00942                     if(test>=1)
00943                         test++;
00944                 }
00945             }
00946         }
00947         else
00948         {
00949             ErrorOfScan(0);
00950             fprintf(stderr,
00951             "Token 'def' not found in %d Subr string ", number - 1);
00952             exit(1);
00953         }
00954     }
00955 }
00956 
00957 void ViewReturnCall P5C(int, num_err, int, top, int *, 
00958                      pstack, int, j, int, depth)
00959 {
00960     int k,m;
00961 
00962 #ifdef DEBUG
00963     if((dd(D_CALL_SUBR))&&(num_err>0))
00964     {
00965         if(grow==1)
00966         {
00967             grow=0;
00968             fprintf(stderr, "\n              Top: ");
00969         }
00970         else
00971             fprintf(stderr,   "             Back: ");
00972     }
00973 
00974 #endif
00975 
00976     if(num_err<0)
00977     {
00978         if(grow==1)
00979         {
00980             grow=0;
00981             fprintf(stderr, "\n            ERROR: ");
00982             ErrorOfScan(num_err);
00983         }
00984         else
00985             fprintf(stderr,   "             Back: ");
00986     }
00987 
00988     fprintf(stderr, " %d Subr \n", top);
00989 
00990     fprintf(stderr," %dth level> STACK: ", level);
00991 
00992     for(m=0; m < j; m++, pstack++)
00993     {
00994         if(depth>(j-(m+1)))
00995         {
00996             for(k=0;
00997                 TableCommand[k].command;
00998             k++)
00999             {
01000                 if(TableCommand[k].code==*pstack)
01001                 {
01002                     fprintf(stderr," %s",
01003                     TableCommand[k].command);
01004                     k=0;
01005                     break;
01006                 }
01007             }
01008             if(k!=0)
01009                 fprintf(stderr," (%d)", *pstack);
01010         }
01011         else
01012             fprintf(stderr, " %d", *pstack);
01013     }
01014     fprintf(stderr, " \n");
01015 }
01016 
01017 /*                                               */
01018 /* We decrypt charstring  with recursive descent */
01019 /*                                               */
01020 
01021 int DeCodeStr
01022 P2C(int, num, int, numseac)
01023 {
01024     unsigned int loccr;
01025     unsigned char byte;
01026     static int j ;
01027     int i;
01028     unsigned char jj,k;
01029     int tmpnum;
01030     int depth = 0;
01031     int num_err = 0;
01032     int len_str;
01033     typetemp  _HUGE   *loc;
01034     typetemp  _HUGE   *end_str;
01035     int pstack[64];
01036     int last_subr;
01037 
01038     if(num  > CHAR_STR)
01039     {
01040         last_subr=keyword[subrs].offset+keyword[subrs].oldnum;
01041 
01042         for(tmpnum=keyword[subrs].offset; tmpnum<last_subr; tmpnum++)
01043         {
01044               if(label[tmpnum].num==num)
01045                 break;
01046         }
01047 
01048         if(tmpnum==last_subr)
01049         {
01050             fprintf(stderr, " Error: %d Subr not found \n", num);
01051             exit(1);
01052         }
01053         if(label[tmpnum].select==FLG_BINARY)
01054         {
01055             if(j==0)
01056                 return 1;
01057         }
01058         else
01059         {
01060             label[tmpnum].select=FLG_BINARY;
01061             if(num+1 > keyword[subrs].newnum )    /* max num of subr */
01062                 keyword[subrs].newnum = num+1;
01063         }
01064         loc = label[tmpnum].begin + label[tmpnum].skip;
01065         len_str=label[tmpnum].length;
01066     }
01067     else
01068     {
01069         j=0;
01070 
01071         if(num == CHAR_SEAC)
01072         {
01073             if(label[numseac].select!=FLG_BINARY)
01074             {
01075                 label[numseac].select=FLG_BINARY;
01076                 keyword[char_str].newnum++;
01077                 temp = label[numseac].begin;
01078             }
01079             else return 1;
01080         }
01081         len_str=GetNum();
01082 
01083         if(len_str < 0)
01084         {
01085             return ERR_SECOND_NUM;
01086         }
01087         num_err = PassToken();
01088         if(num_err < 0)
01089         {
01090             return ERR_FIRST_TOK;
01091         }
01092         loc=temp;
01093     }
01094     loc++;
01095 
01096     end_str=loc+len_str;
01097 
01098     loccr = CDR;
01099 
01100     for (i = 0; i < lenIV; i++,loc++)
01101     {
01102         byte = CDeCrypt(*loc, &loccr);
01103     }
01104     for (; loc < end_str;)
01105     {
01106         byte = CDeCrypt(*loc++, &loccr);
01107         if (byte == RETURN)
01108         {
01109             j=0;
01110             break;
01111         }
01112         else if (byte == ESCAPE)
01113         {
01114             byte = CDeCrypt(*loc++, &loccr);
01115             if (byte > MAX_ESCAPE)
01116                 fprintf(stderr,
01117             "Error: not_defined_e%d in %s", byte, psfontfile);
01118             else
01119             {
01120                 switch(byte)
01121                 {
01122                     case  DOTSECTION      : j=0; break;
01123                     case  VSTEM3          : j=0; break;
01124                     case  HSTEM3          : j=0; break;
01125                     case  SEAC            :
01126                         stack[j++]=byte;
01127                         grow=1;
01128                         level++;
01129                         jj=j;
01130                         for(k=0;k<jj;k++)
01131                             pstack[k]=stack[k];
01132                         num_err=FindSeac(pstack[jj-3]);
01133                         if(num_err<0)
01134                         {
01135                             flg_seac=1;
01136                             CharCount++;
01137                             keyword[char_str].newnum--;
01138                             if(flg_seac > -3)
01139                                 label[number].select=SEAC_NOT_END;
01140                             grow=0;
01141                             level=0;
01142                             j=0;
01143                             break;
01144                         }
01145 
01146                         num_err=DeCodeStr(CHAR_SEAC, num_err);
01147                         level--;
01148 
01149 #ifdef DEBUG
01150                         if((num_err<0)||(dd(D_CALL_SUBR)))
01151 #else
01152                         if(num_err<0)
01153 #endif
01154                         ViewReturnCall
01155                         (num_err, pstack[jj-3],pstack,jj,1);
01156                         grow=1;
01157                         level++;
01158                         num_err=FindSeac(pstack[jj-2]);
01159                         if(num_err<0)
01160                         {
01161                             flg_seac=1;
01162                             CharCount++;
01163                             keyword[char_str].newnum--;
01164                             keyword[char_str].newnum--;
01165                             if(flg_seac > -3)
01166                                 label[number].select=SEAC_NOT_END;
01167                             grow=0;
01168                             level=0;
01169                             j=0;
01170                             break;
01171                         }
01172                         num_err=DeCodeStr(CHAR_SEAC, num_err);
01173                         level--;
01174 #ifdef DEBUG
01175                         if((num_err<0)||(dd(D_CALL_SUBR)))
01176 #else
01177                         if(num_err<0)
01178 #endif
01179 
01180                         ViewReturnCall
01181                         (num_err, pstack[jj-2],pstack,jj,1);
01182 
01183                         if(num_err<0)
01184                             return ERR_STACK;
01185                         j=0; break;
01186                     case  SBW             : j=0; break;
01187                     case  CHARS_DIV       : j=0; break;
01188                     case  CALLOTHERSUBR   : stack[j++]=byte;
01189                         depth=depth+2;
01190                         break;
01191                     case  POP             : stack[j++]=byte;
01192                         depth=depth+2;
01193                         break;
01194                     case  SETCURRENTPOINT : j=0; break;
01195                 }
01196             }
01197             continue;
01198         }
01199         else if (byte < 32)
01200         {
01201             switch(byte)
01202             {
01203                 case  HSTEM           : j=0; break;
01204                 case  VSTEM           : j=0; break;
01205                 case  VMOVETO         : j=0; break;
01206                 case  CHARS_RLINETO   : j=0; break;
01207                 case  HLINETO         : j=0; break;
01208                 case  VLINETO         : j=0; break;
01209                 case  RRCURVETO       : j=0; break;
01210                 case  CHARS_CLOSEPATH : j=0; break;
01211                 case  CALLSUBR        : stack[j++]=byte;
01212                     depth=depth+2;
01213                     level++;
01214                     grow=1;
01215                     jj=j;
01216                     j=j-depth;
01217                     for(k=0;k<jj;k++)
01218                         pstack[k]=stack[k];
01219 
01220                     num_err = DeCodeStr(stack[j],0);
01221 
01222                     level--;
01223 #ifdef DEBUG
01224                     if((num_err<0)||(dd(D_CALL_SUBR)))
01225 #else
01226                     if(num_err<0)
01227 #endif
01228                     ViewReturnCall
01229                     (num_err, pstack[jj-depth], pstack,jj,depth/2);
01230 
01231                     if(num_err<0)
01232                         return ERR_STACK;
01233                     else
01234                     {
01235                         depth=0;
01236                         break;
01237                     }
01238                 case  RETURN          : j=0; break;
01239                 case  ESCAPE          : break;
01240                 case  HSBW            : j=0; break;
01241                 case  ENDCHAR         : j=0; break;
01242                 case  CHARS_RMOVETO   : j=0; break;
01243                 case  HMOVETO         : j=0; break;
01244                 case  VHCURVETO       : j=0; break;
01245                 case  HVCURVETO       : j=0; break;
01246             }
01247         }
01248         if (byte >= 32)
01249         {
01250             if (byte <= 246)
01251             {
01252                 value= byte  - 139;
01253                 stack[j++]=value;
01254             }
01255             else if ((byte >= 247) && (byte <= 250))
01256             {
01257                 value= (byte  - 247) * 256 + CDeCrypt(*loc++, &loccr) + 108;
01258                 stack[j++]=value;
01259             }
01260             else if ((byte >= 251) && (byte <= 254))
01261             {
01262                 value= -(byte  - 251) * 256 - CDeCrypt(*loc++, &loccr) - 108;
01263                 stack[j++]=value;
01264             }
01265             else if (byte == 255)
01266             {
01267                 value = CDeCrypt(*loc++, &loccr);
01268                 value <<= 8;
01269                 value += CDeCrypt(*loc++, &loccr);
01270                 value <<= 8;
01271                 value += CDeCrypt(*loc++, &loccr);
01272                 value <<= 8;
01273                 value += CDeCrypt(*loc++, &loccr);
01274                 stack[j++]=value;
01275             }
01276         }
01277     }
01278     if(num  == CHAR_STR)
01279     {
01280         temp=loc;
01281         num_err = PassToken();
01282         if(num_err<0)
01283         {
01284             return ERR_SECOND_TOK;
01285         }
01286     }
01287     return 1;
01288 }
01289 
01290 /*                                        */
01291 /*  We mark only necessary charstring     */
01292 /*                                        */
01293 
01294 
01295 void ScanChars P1C(int, i)
01296 {
01297 
01298     int word_type=0;
01299     int found;
01300     int str_len;
01301     int max_num;
01302     int counter;
01303     int num_err = 0;
01304     typetemp  _HUGE   *tmptemp;
01305 
01306 
01307     CharCount++;
01308     counter=number;
01309     max_num = keyword[i].offset+keyword[i].oldnum;
01310 
01311     while( number < max_num )
01312     {
01313         if((word_type=GetToken())>0)
01314         {
01315             if(word_type>=3)
01316             {
01317                 strcpy((char *) tmp_token, (char *) token);
01318                 str_len = strlen((char *) token);
01319 
01320 
01321                 if(CharCount!=0)
01322                 {
01323                     
01324                     num_err=FindCharW(token, str_len);
01325 
01326                     if(num_err==FLG_BINARY)
01327                     {
01328                         CharCount--;
01329                         found=num_err;
01330                         keyword[i].newnum++;
01331                     }
01332                     else
01333                     {
01334 #ifdef DEBUG
01335 
01336                         if(dd(D_VIEW_VECTOR)&&(num_err==-1))
01337                         {
01338                             fprintf(stderr,
01339                          " Debug: Char '%s' not used in WorkVector\n", token);
01340 
01341                         }
01342 #endif
01343                         if(word_type>3)
01344                         {
01345                             if(strstr((char *) token, (char *) notdef)!=NULL)
01346                             {
01347                                 CharCount--;
01348                                 label[number].num = -2;
01349                                 found=FLG_BINARY;
01350                                 keyword[i].newnum++;
01351                             }
01352                             else
01353                                 found=NOTHING;
01354                         }
01355                         else
01356                             found=NOTHING;
01357                     }
01358                 }
01359                 else
01360                 {
01361                     found=NOTHING;
01362                 }
01363 
01364                 label[number].begin = temp-str_len;
01365                 label[number].select = found;
01366 
01367                 switch(found)
01368                 {
01369                     case FLG_BINARY:
01370                         tmptemp=temp;
01371                         for(subrs=FirstKey; subrs<char_str; subrs++)
01372                         {
01373                             level=0;
01374                             if(subrs!=FirstKey)
01375                             {
01376                                 temp=tmptemp;
01377                             }
01378 
01379                             num_err=DeCodeStr(CHAR_STR,0);
01380 
01381                         }
01382 #ifdef DEBUG
01383                         if(dd(D_CALL_SUBR))
01384                         {
01385                             if(num_err>0)
01386                                 fprintf(stderr,
01387                             " Debug for Char '%s'\n", tmp_token);
01388                         }
01389 #endif
01390                         break;
01391                     case NOTHING:
01392 
01393                     num_err=PassString(0);
01394                     break;
01395                 }
01396 
01397                 if(num_err<0)
01398                 {
01399                     ErrorOfScan(num_err);
01400                     fprintf(stderr,"in Char string of '%s'", tmp_token);
01401                     exit(1);
01402                 }
01403                 number++;
01404             }
01405         }
01406         else
01407         {
01408             fprintf(stderr,
01409            "\n File <%s> ended before all chars have been found.", psfontfile);
01410 
01411             fprintf(stderr,
01412             "\n We scan %d Chars from %d",
01413             counter - (2 + keyword[subrs].oldnum),
01414             keyword[i].oldnum);
01415 
01416             if(tmp_token!=NULL)
01417             {
01418                 fprintf(stderr, "\n Last seen token was '%s'\n", tmp_token);
01419             }
01420             exit(1);
01421         }
01422     }
01423 
01424     if(flg_seac!=0)
01425     {
01426         tmptemp=temp;
01427         flg_seac--;
01428         for(; counter<max_num; counter++)
01429         {
01430             if((int) label[counter].select==SEAC_NOT_END)
01431             {
01432                 for(subrs=FirstKey; subrs<char_str; subrs++)
01433                 {
01434                     level=0;
01435                     temp=label[counter].begin;
01436                     num_err=DeCodeStr(CHAR_STR,0);
01437                 }
01438                 if(num_err<0)
01439                 {
01440                     fprintf(stderr," Warning: %d char not choose during SEAC\n",
01441                     label[counter].num);
01442                 }
01443                 else
01444                 {
01445                     CharCount--;
01446                     label[counter].select=FLG_BINARY;
01447                     if(CharCount==0)
01448                         break;
01449                 }
01450             }
01451         }
01452 
01453         temp=tmptemp;
01454     }
01455 
01456     if(CharCount!=0)
01457     {
01458         fprintf(stderr," WARNING: Not all chars found.");
01459         PrintChar(FirstCharW);
01460 
01461     }
01462 }
01463 
01464 void LastLook P1H(void)
01465 {
01466     label[number].begin = temp;
01467     label[number].select = FLG_BINARY;
01468     number++;
01469 }
01470 
01471 int FindKeyWord P2C(int, First_Key, int, lastkey)
01472 {
01473     int word_type=0;
01474     int i;
01475     int tmp_num=0;
01476 
01477     for(;;)
01478     {
01479         if((word_type=GetToken())>0)
01480         {
01481             if(word_type==3)
01482             {
01483                 for(i=First_Key; i<=lastkey; i++)
01484                 {
01485                     if(!strcmp((char *) token, Key[i].name))
01486                     {
01487                         tmp_num = GetNum();
01488                         if(tmp_num<0)
01489                         {
01490                             fprintf(stderr,
01491                             "\n ERROR: Number not found for '%s' in <%s>",
01492                             Key[i].name, psfontfile);
01493                             exit(1);
01494                         }
01495                         keyword[current].oldnum = tmp_num;
01496                         keyword[current].length=strlen((char *) token);
01497                         keyword[current].begin=temp - keyword[current].length;
01498                         return i;
01499                     }
01500                 }
01501             }
01502         }
01503         else
01504         {
01505             fprintf(stderr,
01506             "\n ERROR: In <%s> keyword not found:", psfontfile);
01507 
01508             for(i=First_Key; i<=lastkey; i++)
01509                 fprintf(stderr,"\n %dth > '%s' ",i,Key[i].name);
01510             exit(1);
01511         }
01512     }
01513 }
01514 
01515 /* To increase scan speed we use dynamic range of keywords */
01516 
01517 int ScanBinary P1H(void)
01518 {
01519     int i;
01520     int firstnum, lastnum;
01521     firstnum= LENIV;
01522     lastnum=SUBRS;
01523 
01524     number=0;
01525     label[number].begin = begin_of_scan;
01526     temp = label[number].begin;
01527     label[number].select = FLG_BINARY;
01528     offset= ++number;
01529 
01530     for (current=0, FirstKey=current ; ; current++)
01531     {
01532         i=FindKeyWord(firstnum,lastnum);
01533         switch(i)
01534         {
01535             case  LENIV:
01536                 FirstKey++;
01537                 firstnum=SUBRS;
01538                 lastnum=SUBRS;
01539                 lenIV=keyword[current].oldnum;
01540                 keyword[current].type=Key[0].num;
01541                 break;
01542             case  SUBRS:
01543                 firstnum=SUBRS;
01544                 lastnum= CHARSTRINGS;
01545                 keyword[current].offset=number;
01546                 keyword[current].newnum=0;
01547                 keyword[current].type=Key[1].num;
01548                 ScanSubrs(current);
01549                 LastLook();
01550                 break;
01551             case  CHARSTRINGS:
01552                 char_str=current;
01553                 keyword[current].offset=number;
01554                 keyword[current].newnum=0;
01555                 keyword[current].type=Key[2].num;
01556                 ScanChars(current);
01557                 LastLook();
01558 #ifdef DEBUG
01559                 if(dd(D_CALL_SUBR))
01560                 {
01561                     for(i=0;i<=2;i++)
01562                     {
01563                         if(keyword[i].oldnum!=0)
01564                             fprintf(stderr, " Result for <%s>:  %s  %d (instead %d) \n",
01565                             psfontfile, Key[keyword[i].type].name,keyword[i].newnum, keyword[i].oldnum);
01566                     }
01567 
01568                 }
01569 #endif
01570                 return 1;
01571         }
01572     }
01573 }
01574 
01575 unsigned char *itoasp
01576 P3C(int, n, unsigned char *, s, int, len)
01577 {
01578     static int i, j;
01579 
01580     j++;
01581     if(n/10)
01582         itoasp(n/10,s,len);
01583     else
01584         i=0;
01585     s[i++]=abs(n)%10+'0';
01586     j--;
01587     if(j==0)
01588     {
01589         for(; i<len;)
01590             s[i++]=' ';
01591         s[i]='\0';
01592         return s;
01593     }
01594     return NULL;
01595 }
01596 
01597 void SubstNum P1H(void)
01598 {
01599     int i, j;
01600 
01601     for(i=FirstKey;i<=char_str;i++)
01602     {
01603         itoasp(keyword[i].newnum,token,keyword[i].length);
01604         temp=keyword[i].begin;
01605         for(j=0;token[j];++j,++temp)
01606         {
01607             *temp=token[j];
01608         }
01609         temp=keyword[i].begin;
01610     }
01611 }
01612 
01613 ub4 little4 P1C(ub1 *, buff)
01614 {
01615     return (ub4) buff[0] +
01616     ((ub4) buff[1] << 8) +
01617     ((ub4) buff[2] << 16) +
01618     ((ub4) buff[3] << 24);
01619 }
01620 
01621 unsigned short int  c1 = C1, c2 = C2;
01622 unsigned short int edr;
01623 
01624 
01625 unsigned char CDeCrypt P2C(unsigned char, cipher, unsigned int *, lcdr)
01626 {
01627     register unsigned char plain;
01628 
01629     plain = (cipher ^ (*lcdr >> 8));
01630     *lcdr = (cipher + *lcdr) * c1 + c2;
01631     return plain;
01632 }
01633 
01634 unsigned short int eer;
01635 
01636 /* We find end of own vector with non StandardEncoding,
01637 
01638 
01639 */
01640 
01641 
01642 int EndOfEncoding
01643 P1C(int, err_num)
01644 {
01645 
01646     int j;
01647     int i = 0;
01648     int flg_get_word=0;
01649 
01650 
01651     static char *RefKey[] =
01652     {
01653        "readonly",
01654        "getinterval",
01655        "exch",
01656        "def",
01657        ""
01658     };
01659 
01660     for(;;)
01661     {
01662         if(flg_get_word==0)
01663             flg_get_word = 1;
01664         else
01665         {
01666             err_num=GetWord(token);
01667 
01668         }
01669 
01670         if(err_num <= 0)
01671             return -1;
01672 
01673         if(err_num==5)
01674             refer[ind_ref].num[i++]=atoi((char *) token);
01675         else
01676         {
01677             for(j=0; *RefKey[j]; j++)
01678             {
01679                  if(strcmp((char *) token, RefKey[j]) ==0)
01680                         break;
01681             }
01682             switch(j)
01683             {
01684                 case 0:
01685                 case 3:
01686                     find_encod=1;
01687                     keep_num = -2;
01688                     if(ind_ref!=0)
01689                     {
01690                         CorrectGrid();
01691                     }
01692                     return 1;
01693 
01694                case 1:
01695                     break;
01696 
01697                case 2:
01698                     if(i==1)
01699                     {
01700                         refer[ind_ref].num[1] = 1;
01701                         refer[ind_ref].num[2] = refer[ind_ref].num[0];
01702                         GetWord(token);
01703                         refer[ind_ref].num[0]= atoi((char *) token);
01704                     }
01705                     i=0;
01706                     refer[ind_ref].select=1;
01707                     ind_ref++;
01708                     break;
01709                 default:
01710                     break;
01711             }
01712         }
01713     }
01714 
01715 }
01716 
01717 /* We rebuild grid for case
01718    "dup dup 161 10 getinterval 0 exch putinterval
01719     dup dup 173 23 getinterval 10 exch putinterval
01720     dup dup 127 exch 196 get put readonly def"
01721 in non StandardEncoding */
01722 
01723 
01724 void CorrectGrid P1H(void)
01725 {
01726     int i, j, k, imax;
01727 
01728 
01729     for(j=0; j<=ind_ref; j++){
01730         if(refer[j].select==1){
01731             imax= refer[j].num[1] + refer[j].num[2];
01732 
01733             for(k=0, i=refer[j].num[2]; i< imax; k++,i++){
01734                 if(grid[i]==1){
01735                     grid[i]=0;
01736                     grid[k+refer[j].num[0]]=1;
01737                 }
01738             }
01739         }
01740     }
01741 }
01742  /* We build vector for non StandardEncoding */
01743 
01744 int CharEncoding P1H(void)
01745 {
01746     int err_token=0;
01747     int num=0;
01748     int seen = 0 ;
01749 
01750     while (1) {
01751     err_token=GetWord(token);
01752 
01753     if(err_token==2)
01754     {
01755         if(strcmp((char *) token, Dup) ==0)
01756         {
01757             err_token=GetWord(token);
01758             if(err_token<0)
01759                 return ERR_NUM_CHAR;
01760 
01761             if(err_token!=2)       /* define "dup word" */
01762             {
01763                 num=atoi((char *) token);
01764 
01765                 err_token=GetWord(token);
01766                 if(err_token<0)
01767                 {
01768                     return ERR_NAME_CHAR;
01769                 }
01770                 FirstChar=AddChar(FirstChar,token, num);
01771                 keep_num=num;
01772                 keep_flg=1;
01773                 seen++ ;
01774                 err_token = GetWord(token) ;
01775             }
01776         } else {
01777 
01778            if(keep_flg==1)
01779            {
01780                keep_num=FLG_OUT_STR;
01781    
01782                if(EndOfEncoding(err_token)<0)
01783                {
01784                    return -1;
01785                }
01786            }
01787         }
01788     } else
01789        return seen ;
01790     }
01791 }
01792 
01793 
01794 
01795 void FindEncoding P1H(void)
01796 {
01797     int num_err=0;
01798     int tmpnum;
01799 
01800     line=tmpline;
01801 
01802     if(encode==0)
01803     {
01804 
01805         while((num_err=GetWord(token))>=0)
01806         {
01807             if(num_err==3)
01808             {
01809                 if (strcmp((char *) token,"/Encoding") == 0)
01810                 {
01811 
01812                     tmpnum=GetWord(token);
01813 
01814                     if(tmpnum==5)
01815                     {
01816                         encode=SPECIAL_ENC;
01817                     }
01818 
01819                     else
01820                     {
01821                         find_encod=1;
01822                         encode=STANDARD_ENC;
01823                     }
01824                     return;
01825                 }
01826             }
01827         }
01828     }
01829 
01830     else
01831     {
01832         num_err= CharEncoding();
01833         if(num_err<0)
01834         {
01835             ErrorOfScan(num_err);
01836             fprintf(stderr,
01837             "\n ERROR in encoding vector in <%s>",  psfontfile);
01838             exit(1);
01839         }
01840     }
01841 }
01842 
01843 /* Before parse in BINARY portion of font we should mark needed chars,
01844 reencode them if there is reencoding vector for this case and
01845 build work vector */
01846 
01847 void CheckChoosing P1H(void)
01848 {
01849 
01850     CHAR *TmpChar;
01851     int err_num, i;
01852 
01853     if(encode==STANDARD_ENC)
01854     {
01855         TmpChar = FirstCharB;
01856     }
01857     else
01858     {
01859         if(encode==SPECIAL_ENC)
01860         {
01861             TmpChar = FirstChar;
01862         }
01863         else
01864         {
01865             fprintf(stderr,
01866             "WARNING: '/Encoding' not found in <%s>\n", psfontfile);
01867             exit(1);
01868         }
01869     }
01870 
01871     if(reencode==FLG_REENCODE)
01872         err_num=LoadVector(reencode, TmpChar);
01873     else
01874         err_num=ChooseVect(TmpChar);
01875 
01876     if(err_num<0)
01877     {
01878             Afm();
01879             encode=AFM_ENC;
01880 
01881             TmpChar = FirstCharA;
01882 
01883             for(i=0;i<=255;i++)
01884                 grid[i]=tmpgrid[i];
01885 
01886 
01887     if(reencode==FLG_REENCODE)
01888         err_num=LoadVector(reencode, TmpChar);
01889     else
01890         err_num=ChooseVect(TmpChar);
01891 
01892         if(err_num<0)
01893         {
01894             fprintf(stderr,
01895             "\n Warning: after loading AFM file \n");
01896 
01897             fprintf(stderr,
01898             " only %d chars found instead %d for <%s>\n",
01899             CharCount, GridCount, psfontfile);
01900         }
01901 
01902    }
01903     WorkVect(TmpChar);
01904 
01905 #ifdef DEBUG
01906 
01907     if(dd(D_VIEW_VECTOR))
01908     {
01909         fprintf(stderr, "\n");
01910         if(encode==1)
01911             fprintf(stderr, " Encoding: standard \n");
01912         else
01913             fprintf(stderr, " Encoding: not standard \n");
01914 
01915         if(reencode==FLG_REENCODE)
01916             fprintf(stderr, " with reencode vector <%s>\n", psvectfile);
01917 
01918         PrintChar(FirstCharW);
01919     }
01920 #endif
01921 
01922 }
01923 
01924 /*
01925  *   As we write the output file, we search for /UniqueID, and if we find
01926  *   such, we munge it.  We need to do this because the font is only partial,
01927  *   and if we send out a valid UniqueID, this well may mess up future jobs
01928  *   that use this font, but characters that we do not include.  We munge
01929  *   the string from /UniqueID to /UniqueXX just to make it more clear
01930  *   what we've done.
01931  */
01932 
01933 char *KillUnique P1C(char *, s)
01934 {
01935    char *r = strstr(s, "/UniqueID") ;
01936    if (r) {
01937       r[7] = 'X' ;
01938       r[8] = 'X' ;
01939    }
01940    return s ;
01941 }
01942 
01943 void OutASCII P3C(FILE *, fout, ub1 *, buff, ub4, len)
01944 {
01945     ub4 i;
01946 
01947     for (i = 0; i < len; i++)
01948     {
01949         if ((*buff == 10)||(*buff == 13))
01950         {
01951             buff++;
01952             *line++='\n';
01953             *line='\0';
01954 
01955             if((find_encod==0)&&(lastpart==0))
01956             {
01957                 FindEncoding();
01958             }
01959 
01960             line=(unsigned char *) KillUnique((char *) tmpline);
01961 
01962             if(keep_flg==0)
01963                 fprintf(fout,"%s", line);
01964             else
01965             {
01966                 if(keep_num<0)
01967                 {
01968                     AddStr(line,keep_num);
01969                     if(keep_num==-2)
01970                         keep_num = -3;
01971                 }
01972 
01973             }
01974         }
01975         else
01976         {
01977             *line++ = *buff++;
01978         }
01979     }
01980 }
01981 
01982 /* It's eexec decription for PFB format */
01983 
01984 void BinEDeCrypt P2C(ub1 *, buff, ub4, len)
01985 {
01986     ub4 i;
01987 
01988     for (i = 0; i < len; i++, temp++, buff++)
01989     {
01990         *temp  = (*buff ^ (edr >> 8));
01991         edr = (*buff + edr) * c1 + c2;
01992     }
01993 }
01994 
01995 /* And  it's eexec decription for PFA format */
01996 
01997 
01998 void HexEDeCrypt P1C(unsigned char *, mem)
01999 {
02000     int ch1, ch2, cipher;
02001 
02002 
02003     for(;*mem!='\n' && *mem!='\r'; temp++)
02004     {
02005         ch1= *mem++;
02006         ch2= *mem++;
02007 
02008         if ('A' <= ch1 && ch1 <= 'F')
02009             ch1 -= 'A' - 10;
02010         else if ('a' <= ch1 && ch1 <= 'f')
02011             ch1 -= 'a' - 10;
02012         else
02013             ch1 -= '0';
02014         ch1<<=4;
02015 
02016         if ('A' <= ch2 && ch2 <= 'F')
02017             ch2 -= 'A' - 10;
02018         else if ('a' <= ch2 && ch2 <= 'f')
02019             ch2 -= 'a' - 10;
02020         else
02021             ch2 -= '0';
02022 
02023         cipher = ch1 + ch2;
02024 
02025         *temp = (cipher ^ (edr >> 8));
02026         edr = (cipher + edr) * c1 + c2;
02027 
02028     }
02029 }
02030 
02031 int PartialPFA P2C(FILE *, fin, FILE *, fout)
02032 {
02033     ub1  type;
02034     ub4 memory, addmemory, length, add_of_len;
02035     unsigned char *mem = tmpline;
02036     int check_vect=0;
02037 
02038     tmpline=buf;
02039     edr  = EDR;
02040     type = FLG_ASCII;
02041     memory = BASE_MEM;
02042     addmemory= ADD_MEM;
02043     length=0;
02044     temp=(typetemp *) UniGetMem(memory);
02045     begin_of_scan=temp;
02046 
02047     for(;;)
02048     {
02049         if(fgets((char *)buf,BUFSIZ,fin)==NULL)
02050             break;
02051         switch (type)
02052         {
02053             case FLG_ASCII:
02054                 if(strstr((char *)buf,"currentfile eexec") != NULL)
02055                 {
02056                     type=FLG_BINARY;
02057                 }
02058 
02059                 if((find_encod==0)&&(lastpart==0))
02060                 {
02061                     FindEncoding();
02062                 }
02063 
02064                 if(keep_flg==0)
02065                     fprintf(fout,"%s", KillUnique((char *)buf));
02066                 else
02067                 {
02068                     AddStr(buf,keep_num);
02069                 }
02070                 break;
02071 
02072             case FLG_BINARY:
02073                 if(check_vect==0)
02074                 {
02075                     tmpline=mem;
02076                     CheckChoosing();
02077                     check_vect=1;
02078                 }
02079 
02080                 if(GetZeroLine(buf)<0)
02081                 {
02082                     type = FLG_ZERO_LINE;
02083                     end_of_scan=temp;
02084                     ScanBinary();
02085                     SubstNum();
02086                     if(keep_flg==1)
02087                     {
02088                         keep_flg=0;
02089                         lastpart=1;
02090                         if(encode!=1)
02091                         {
02092                             UnDefineCharsW();
02093                             if(encode==4)
02094                                 RevChar(FirstCharA);
02095                              else
02096                                  RevChar(FirstChar);
02097 
02098                             OutChar(FirstCharW, fout);
02099                         }
02100                         Reeverse(FirstStr);
02101                         OutStr(RevStr, fout);
02102                     }
02103 
02104                     OutHEX(fout);
02105                     UniFree(begin_of_scan);
02106                     fprintf(fout, "%s", KillUnique((char*) buf));
02107                     break;
02108                 }
02109 
02110                 add_of_len=strlen((char *) buf)/2;
02111                 length=length + add_of_len;
02112 
02113                 if(length>memory)
02114                 {
02115                     memory = memory + addmemory;
02116 /* Using "memory = length;" retains minimum */
02117 /* of memory  but it will be more slowly    */
02118                     begin_of_scan = (typetemp*) UniRealloc(begin_of_scan, memory);
02119                     temp = begin_of_scan + length - add_of_len;
02120                 }
02121                 HexEDeCrypt(buf);
02122                 break;
02123             case FLG_ZERO_LINE:
02124                 fprintf(fout, "%s", buf);
02125                 break;
02126         }
02127     }
02128     if(type == FLG_ZERO_LINE)
02129         return TRUE;
02130     else return FALSE;
02131 }
02132 
02133 #define FIRST_ASCII     1
02134 #define FIRST_BINARY    2
02135 #define NEXT_BINARY     3
02136 #define NEXT_ASCII      4
02137 
02138 int PartialPFB
02139 P2C(FILE *, fin, FILE *, fout)
02140 {
02141     ub1  type;
02142     ub4  t_length, length, nread;
02143     int  nbytes, rc;
02144     int  check_vect = 0;
02145     int  sub_type = FIRST_ASCII;
02146 
02147     line=tmpline;
02148     edr  = EDR;
02149 
02150 /* To find summary length of multiple binary parts we prescan font file */
02151 
02152     t_length = 0L;
02153 
02154     for (;;)
02155     {
02156         if ((rc = fread((char *) buf, 1, 6, fin)) < 2)
02157         {
02158             return FALSE;
02159         }
02160 
02161         if (buf[0] != 128)
02162             return FALSE;
02163 
02164         type = buf[1];
02165 
02166         if (type == FLG_EOF)
02167         {
02168             break;
02169         }
02170 
02171         if (rc != 6)
02172             return FALSE;
02173 
02174         length = little4(&buf[2]);
02175 
02176         if(type==FLG_BINARY)
02177         {
02178             t_length = (ub4)(length + t_length);
02179         }
02180         fseek(fin, ftell(fin) + length, SEEK_SET);
02181    }
02182 
02183 /* Here we start real parsing */
02184 
02185     sub_type = FIRST_BINARY;
02186 
02187     fseek(fin, 0L, SEEK_SET);
02188 
02189     for (;;)
02190     {
02191         if ((rc = fread((char *) buf, 1, 6, fin)) < 2)
02192         {
02193             return FALSE;
02194         }
02195         if (buf[0] != 128)
02196             return FALSE;
02197 
02198         type = buf[1];
02199 
02200         if (type == FLG_EOF)
02201         {
02202             return TRUE;
02203         }
02204 
02205         if (rc != 6)
02206             return FALSE;
02207 
02208         length = little4(&buf[2]);
02209 
02210         if(type==FLG_BINARY)
02211         {
02212             if(sub_type == FIRST_BINARY)
02213             {
02214                 sub_type = NEXT_BINARY;
02215                 temp=(typetemp*) UniGetMem(t_length);
02216                 begin_of_scan=temp;
02217             }
02218         }
02219         else
02220         {
02221             if( sub_type == NEXT_BINARY)
02222             {
02223                 sub_type = NEXT_ASCII;
02224                 end_of_scan=temp;
02225                 ScanBinary();
02226                 SubstNum();
02227                 if(keep_flg==1)
02228                 {
02229                     keep_flg=0;
02230                     lastpart=1;
02231                     if(encode!=1)
02232                     {
02233                         UnDefineCharsW();
02234                         if(encode==4)
02235                             RevChar(FirstCharA);
02236                         else
02237                             RevChar(FirstChar);
02238 
02239                         OutChar(FirstCharW, fout);
02240                     }
02241                         
02242                     Reeverse(FirstStr);
02243                     OutStr(RevStr, fout);
02244                 }
02245             OutHEX(fout);
02246             UniFree(begin_of_scan);
02247         }
02248         }
02249 
02250         for (nread = 0; nread < length; nread += rc)
02251         {
02252             nbytes = min(BUFSIZ, length - nread);
02253 
02254             if ((rc = fread((char *) buf, 1, nbytes, fin)) == 0)
02255             {
02256                 return FALSE;
02257             }
02258             switch (type)
02259             {
02260                 case FLG_ASCII:
02261                     OutASCII(fout, buf, (ub4) rc);
02262                     break;
02263                 case FLG_BINARY:
02264                     if(check_vect==0)
02265                     {
02266                         CheckChoosing();
02267                         check_vect=1;
02268                     }
02269                     BinEDeCrypt(buf, (ub4) rc);
02270                     break;
02271                 default:
02272                     return FALSE;
02273             }
02274         }
02275     }
02276 }
02277 
02278 void OutHEX
02279 P1C(FILE *, fout)
02280 {
02281     int i=0;
02282     int num;
02283     static char *hexstr = "0123456789abcdef" ;
02284     int bin;
02285 
02286     line=tmpline;
02287     eer  = EER;
02288     label[number].begin  =  end_of_scan;
02289     label[number].select = NOTHING;
02290     number++;
02291 
02292     for(num=0; num < number; num++)
02293     {
02294         switch(label[num].select)
02295         {
02296             case NOTHING:
02297                 break;
02298             case FLG_BINARY:
02299                 label[num].select=NOTHING;
02300                 for(temp=label[num].begin; temp<label[num+1].begin; temp++,i++)
02301                 {
02302                     bin = (*temp ^ (eer >> 8));    /* Eexec encryption */
02303                     eer = ((bin + eer) * c1 + c2);
02304 
02305                     *line++= hexstr[(bin&0xf0)>>4];
02306                     *line++= hexstr[bin&0xf];
02307 
02308                     if (!((i + 1) % BYTES_PER_LINE))
02309                     {
02310                         *line++='\0';
02311                         line =tmpline;
02312                         fprintf(fout, "%s\n",line);
02313                     }
02314                 }
02315                 break;
02316         }
02317     }
02318     if (i % BYTES_PER_LINE)
02319     {
02320         *line++='\0';
02321         line =tmpline;
02322         fprintf(fout, "%s\n",line);
02323     }
02324 }
02325 
02326 /* We parse AFM file only if we've received errors after
02327 parsing of own vector */
02328 
02329 int Afm P1H(void)
02330 {
02331     unsigned char afmfile[100];
02332     FILE  *fafm;
02333     int err_num=0;
02334     int i,j,k,num=0;
02335     unsigned char name[40];
02336 
02337     static char *AfmKey[] =
02338     {
02339         "StartCharMetrics",
02340         "EndCharMetrics",
02341             ""
02342     };
02343 
02344     static char *InfoKey[] =
02345     {
02346         "C",
02347         "N",
02348         ""
02349     };
02350 
02351     for(i=0; psfontfile[i] ; i++)
02352     {
02353         if(psfontfile[i] == '.')
02354             break;
02355         else
02356             afmfile[i]=psfontfile[i];
02357     }
02358 
02359     afmfile[i]='\0';
02360     strcat((char *) afmfile,".afm");
02361     fprintf(stderr, "<%s>", afmfile);
02362 
02363     if ((fafm = psfopen((char *) afmfile, "r")) == NULL)
02364     {
02365         NameOfProgram();
02366         perror((char *) afmfile);
02367         return -1;
02368     }
02369 
02370     for(j=0;;)
02371     {
02372         line = tmpline;
02373 
02374         if(fgets((char *) line,BUFSIZ,fafm)==NULL)
02375             break;
02376 
02377         if(strstr((char *) line, AfmKey[j])!=NULL)
02378         {
02379             if(j==0)
02380             {
02381                 j++;
02382                 continue;
02383             }
02384             else
02385             {
02386                 fclose(fafm);
02387                 return 1;
02388             }
02389         }
02390 
02391         if(j==1)
02392         {
02393             for(k=0; err_num>=0; )
02394             {
02395                 err_num=GetWord(token);
02396                 if(err_num==2)
02397                 {
02398                     if(strcmp((char *) token,InfoKey[k])==0)
02399                     {
02400                         if(k==0)
02401                         {
02402                             err_num=GetWord(token);
02403                             num=atoi((char *) token);
02404                             k=1;
02405                             continue;
02406                         }
02407                         else
02408                         {
02409                             err_num=GetWord(token);
02410                             name[0]='/';
02411                             name[1]='\0';
02412                             strcat((char *) name, (char *) token);
02413                             if(num>=0)
02414                                 FirstCharA=AddChar(FirstCharA, name, num);
02415                             break;
02416                         }
02417                     }
02418                 }
02419 
02420             }
02421         }
02422     }
02423     return -2;
02424 }
02425 
02426 int FontPart P3C(FILE *, fout, unsigned char *, fontfile,
02427                unsigned char *, vectfile )
02428 {
02429     FILE  *fin=0;
02430     int   num;
02431     int   rc;
02432     int i;
02433 
02434     ind_ref=0;
02435     reencode=0;
02436     encode=0;
02437     lastpart=0;
02438     keep_flg=0;
02439     flg_seac=0;
02440     strcpy((char *) psfontfile, (char *) fontfile);
02441     find_encod=0;
02442     CharCount=0;
02443 
02444     if(loadbase != 1)
02445     {
02446         for(i=offset; i < NUM_LABEL; i++)
02447               label[i].num=CHAR_NOT_DEF;
02448 
02449 
02450         strcpy((char *) psvectfile, (char *) basevect);
02451 
02452 #ifdef DEBUG
02453         if(dd(D_VIEW_VECTOR))
02454            fprintf(stderr, " Base vector <%s>.", basevect);
02455 #endif
02456 
02457         if(LoadVector(1, FirstCharB)==1)
02458         {
02459             loadbase = FLG_LOAD_BASE;
02460 
02461         }
02462         else
02463             exit(1);
02464     }
02465 
02466     if(vectfile)
02467     {
02468         reencode=FLG_REENCODE;
02469         strcpy((char *) psvectfile, (char *) vectfile);
02470     }
02471 
02472     for(num=0;num<NUM_LABEL;num++)
02473         label[num].select = NOTHING;
02474 
02475     switch(DefTypeFont(fontfile))
02476     {
02477         case PFA:
02478             if ((fin = psfopen((char *) fontfile, "r"))==NULL)
02479             {
02480                 NameOfProgram();
02481                 perror((char *) fontfile);
02482                 return -1;
02483             }
02484             rc = PartialPFA(fin,fout);
02485             if (rc == FALSE)
02486             {
02487                 NameOfProgram();
02488                 (void) fprintf(stderr,
02489                 "Error: %s is not a valid PFA file\n", fontfile);
02490                 return -1;
02491             }
02492 
02493             break;
02494         case PFB:
02495             if ((fin = psfopen((char *) fontfile, OPEN_READ_BINARY))==NULL)
02496             {
02497                 NameOfProgram();
02498                 perror((char *) fontfile);
02499                 return -1;
02500             }
02501             rc = PartialPFB(fin,fout);
02502             if (rc==FALSE)
02503             {
02504                 NameOfProgram();
02505                 (void) fprintf(stderr,
02506                 "Error: %s is not a valid PFB file\n", fontfile);
02507                 return -1;
02508             }
02509             break;
02510         case -1:
02511             NameOfProgram();
02512             fprintf(stderr,
02513             "Error: %s has neither PFA nor PFB extension", fontfile);
02514             return -1;
02515     }
02516 
02517     UnDefineCharsW();
02518 
02519     if(encode==AFM_ENC)
02520         FirstCharA=UnDefineChars(FirstCharA);
02521 
02522     if(encode!=1)
02523     {
02524         UnDefineStr();
02525     }
02526 
02527     FirstChar=UnDefineChars(FirstChar);
02528 
02529     fclose(fin);
02530 
02531     for(i=0; i < number; i++)
02532         label[i].num=CHAR_NOT_DEF;
02533 
02534     ClearB();
02535     return 1;
02536 }
02537 
02538 
02539 
02540 int LoadVector P2C(int, num, CHAR *, TmpChar)
02541 {
02542 
02543     FILE  *fvect;
02544     int i = 0;
02545     int j = 0;
02546     int end_vect=0;
02547     int index_grid = 0;
02548 
02549     CharCount = 0;
02550 
02551     if ((fvect = psfopen((char *) psvectfile, "r")) == NULL)
02552     {
02553         NameOfProgram();
02554         perror((char *) psvectfile);
02555         return -1;
02556     }
02557 
02558     for(;;)
02559     {
02560         line = tmpline;
02561 
02562         if((fgets((char*)line,BUFSIZ,fvect)==NULL)||(end_vect!=0))
02563             break;
02564 
02565         for(;;)
02566         {
02567             j=GetWord(token);
02568             if(j==3)
02569             {
02570                 if(i==0)
02571                 {
02572                     i++;
02573                     continue;
02574                 }
02575 
02576                 if(num==4)
02577                 {
02578                     if(grid[index_grid]==1)
02579                     {
02580                         if(ChooseChar(token, TmpChar)> 0)
02581                             CharCount++;
02582                         else
02583                         {
02584                            fprintf(stderr,
02585                "Error: '%s' not found in reencoding vector <%s> for <%s>\n",
02586                              token,psvectfile, psfontfile);
02587                         }
02588                     }
02589                     index_grid++;
02590                 }
02591                 else
02592                 {
02593                     if(num==1)                    /* Build base vector */
02594                     {
02595                         FirstCharB=AddChar(FirstCharB,token, CharCount);
02596                         CharCount++;
02597                     }
02598                 }
02599                 continue;
02600             }
02601             if(j== -1)
02602                 break;
02603             if(j==2)
02604             {
02605                 i=0;
02606                 end_vect = 1;
02607                 break;
02608             }
02609         }
02610     }
02611 
02612     if(j==2)
02613     {
02614         if((index_grid!=256)&&(CharCount!=256))
02615         {
02616             fclose(fvect);
02617             fprintf(stderr,"Error during Load Vector in <%s>  \n",
02618             psvectfile);
02619             fprintf(stderr,
02620                     "Found %d chars instead 256\n", max(index_grid,CharCount));
02621             return -3;
02622         }
02623 
02624         if(CharCount>0)
02625         {
02626             fclose(fvect);
02627             return 1;
02628         }
02629         else
02630         {
02631             fclose(fvect);
02632             fprintf(stderr,
02633                      "\n Warning: Vector from <%s> for <%s> doesn't load\n",
02634             psvectfile, psfontfile);
02635             return -1;
02636         }
02637     }
02638     else
02639     {
02640         fprintf(stderr,"\n Error: ending token 'def' not found in <%s> \n",
02641         psvectfile);
02642         return -2;
02643     }
02644 }
02645 
02646 int ChooseVect
02647 P1C(CHAR *, tmpChar)
02648 {
02649     CHAR *ThisChar = tmpChar;
02650 
02651     CharCount=0;
02652     while (ThisChar != NULL)
02653     {
02654         ThisChar->choose= grid[ThisChar->num];
02655         if(grid[ThisChar->num]==1)
02656         {
02657             CharCount++;
02658         }
02659         ThisChar = ThisChar->NextChar;
02660     }
02661 
02662     if(CharCount<GridCount)
02663         return -1;
02664     else
02665         return 1;
02666 
02667 }
02668 
02669 void ErrorOfScan
02670 P1C(int, err)
02671 {
02672     switch(err)
02673     {
02674 
02675         case 0: break;
02676 
02677         case ERR_FIRST_NUM:
02678             fprintf(stderr, " First number not found ");
02679             break;
02680         case ERR_SECOND_NUM:
02681             fprintf(stderr, " Second number not found ");
02682             break;
02683 
02684         case ERR_FIRST_TOK:
02685             fprintf(stderr, " First token not found ");
02686             break;
02687 
02688         case ERR_SECOND_TOK:
02689             fprintf(stderr, " Second token not found ");
02690             break;
02691 
02692         case ERR_STACK:
02693             fprintf(stderr, " End of stack ");
02694             break;
02695 
02696         case ERR_NUM_CHAR:
02697             fprintf(stderr, " Number of char not found ");
02698             break;
02699 
02700         case ERR_NAME_CHAR:
02701             fprintf(stderr, " Name of char not found ");
02702             break;
02703     }
02704 }
02705 
02706 void NameOfProgram P1H(void)
02707 {
02708 #ifdef DVIPS
02709     fprintf(stderr,"This is DVIPS, t1part module \n");
02710 #else
02711     fprintf(stderr,"This is t1part, %s by Sergey Lesenko\n", version);
02712 #endif
02713 }
02714 
02715