home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / stex2-18.zip / SeeTeX / libtex / scanpost.c < prev    next >
C/C++ Source or Header  |  1990-07-10  |  2KB  |  112 lines

  1. /*
  2.  * Copyright (c) 1987, 1989 University of Maryland
  3.  * Department of Computer Science.  All rights reserved.
  4.  * Permission to copy for any purpose is hereby granted
  5.  * so long as this copyright notice remains intact.
  6.  */
  7.  
  8. #ifndef lint
  9. static char rcsid[] = "$Header: /usr/local/src/SeeTeX/libtex/RCS/scanpost.c,v 1.2 90/07/10 14:33:23 grunwald Exp Locker: grunwald $";
  10. #endif
  11.  
  12. /*
  13.  * ScanPostAmble - read a DVI postamble.
  14.  */
  15.  
  16. #include <stdio.h>
  17. #include "types.h"
  18. #include "dvicodes.h"
  19. #include "fio.h"
  20. #include "gripes.h"
  21. #include "postamble.h"
  22.  
  23. ScanPostAmble(f, headerfunc, fontfunc)
  24.     register FILE *f;
  25.     void (*headerfunc)();
  26.     register void (*fontfunc)();
  27. {
  28.     register int n;
  29.     register char *s;
  30.     char name[512];
  31.  
  32.     if (FindPostAmble(f)) {
  33.         GripeCannotFindPostamble();
  34.         return(1);
  35.           }
  36.     if (GetByte(f) != Sign8(DVI_POST)) {
  37.         GripeMissingOp("POST");
  38.         return(1);
  39.           }
  40.  
  41.     /* Read the postamble info stuff. */
  42.     {
  43.         struct PostAmbleInfo pai;
  44.         register struct PostAmbleInfo *p = &pai;
  45.  
  46.         p->pai_PrevPagePointer = GetLong(f);
  47.         p->pai_Numerator = GetLong(f);
  48.         p->pai_Denominator = GetLong(f);
  49.         p->pai_DVIMag = GetLong(f);
  50.         p->pai_TallestPageHeight = GetLong(f);
  51.         p->pai_WidestPageWidth = GetLong(f);
  52.         p->pai_DVIStackSize = GetWord(f);
  53.         p->pai_NumberOfPages = GetWord(f);
  54.  
  55.         (*headerfunc)(p);
  56.     }
  57.  
  58.     /* Now read all the font definitions. */
  59.     {
  60.         struct PostAmbleFont paf;
  61.         register struct PostAmbleFont *p = &paf;
  62.         int c;
  63.  
  64.         for (;;) {
  65.             if ((c = getc(f)) == EOF)
  66.                 GripeUnexpectedDVIEOF();
  67.             switch (c) {
  68.  
  69.             case DVI_NOP:
  70.                 break;
  71.  
  72.             case DVI_FNTDEF1:
  73.                 p->paf_DVIFontIndex = UnSign8(getc(f));
  74.                 break;
  75.  
  76.             case DVI_FNTDEF2:
  77.                 p->paf_DVIFontIndex = UnSign16(GetWord(f));
  78.                 break;
  79.  
  80.             case DVI_FNTDEF3:
  81.                 p->paf_DVIFontIndex = UnSign24(Get3Byte(f));
  82.                 break;
  83.  
  84.             case DVI_FNTDEF4:
  85.                 p->paf_DVIFontIndex = GetLong(f);
  86.                 break;
  87.  
  88.             case DVI_POSTPOST:
  89.                 return(0);
  90.  
  91.             default:
  92.                 GripeMissingOp("POSTPOST");
  93.                 return(1);
  94.                 /*NOTREACHED*/
  95.             }
  96.             p->paf_DVIChecksum = GetLong(f);
  97.             p->paf_DVIMag = GetLong(f);
  98.             p->paf_DVIDesignSize = GetLong(f);
  99.             p->paf_n1 = UnSign8(getc(f));
  100.             p->paf_n2 = UnSign8(getc(f));
  101.             p->paf_name = name;    /* never trust people not to
  102.                            clobber it */
  103.             n = p->paf_n1 + p->paf_n2;
  104.             s = name;
  105.             while (--n >= 0)
  106.                 *s++ = GetByte(f);
  107.             *s = 0;
  108.             (*fontfunc)(p);
  109.         }
  110.     }
  111. }
  112.