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 / fio.c < prev    next >
C/C++ Source or Header  |  1990-07-10  |  1KB  |  45 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/src/local/tex/local/mctex/lib/RCS/fio.c,v 2.4 89/08/22 21:50:31 chris Exp $";
  10. #endif
  11.  
  12. /*
  13.  * File I/O subroutines for getting bytes, words, 3bytes, and longwords.
  14.  * N.B.: these believe they are working on a DVI file.
  15.  */
  16.  
  17. #include <stdio.h>
  18. #include "types.h"
  19. #include "error.h"
  20. #include "fio.h"
  21.  
  22. static char eofmsg[] = "unexpected EOF, help";
  23.  
  24. /* for symmetry: */
  25. #define    fGetByte(fp, r)    ((r) = getc(fp))
  26. #define    Sign32(i)    (i)
  27.  
  28. #define make(name, func, signextend) \
  29. i32 \
  30. name(fp) \
  31.     register FILE *fp; \
  32. { \
  33.     register i32 n; \
  34.  \
  35.     func(fp, n); \
  36.     if (feof(fp)) \
  37.         error(1, 0, eofmsg); \
  38.     return (signextend(n)); \
  39. }
  40.  
  41. make(GetByte,  fGetByte,  Sign8)
  42. make(GetWord,  fGetWord,  Sign16)
  43. make(Get3Byte, fGet3Byte, Sign24)
  44. make(GetLong,  fGetLong,  Sign32)
  45.