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.h < prev    next >
Text File  |  1990-07-10  |  2KB  |  54 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. /*
  9.  * File I/O: numbers.
  10.  *
  11.  * We deal in fixed format numbers and (FILE *)s here.
  12.  * For pointer I/O, see pio.h.
  13.  *
  14.  * N.B.: These do the `wrong thing' at EOF.  It is imperative
  15.  * that the caller add appropriate `if (feof(fp))' statements.
  16.  */
  17.  
  18. /*
  19.  * Get one unsigned byte.  Note that this is a proper expression.
  20.  * The reset have more limited contexts, and are therefore OddLy
  21.  * CapItaliseD.
  22.  */
  23. #define    fgetbyte(fp)    getc(fp)
  24.  
  25. /*
  26.  * Get a two-byte unsigned integer, a three-byte unsigned integer,
  27.  * or a four-byte signed integer.
  28.  */
  29. #define fGetWord(fp, r)    ((r)  = getc(fp) << 8,  (r) |= getc(fp))
  30. #define fGet3Byte(fp,r) ((r)  = getc(fp) << 16, (r) |= getc(fp) << 8, \
  31.              (r) |= getc(fp))
  32. #define fGetLong(fp, r)    ((r)  = getc(fp) << 24, (r) |= getc(fp) << 16, \
  33.              (r) |= getc(fp) << 8,  (r) |= getc(fp))
  34.  
  35. /*
  36.  * Fast I/O write (and regular write) macros.
  37.  */
  38. #define    putbyte(fp, r)    ((void) putc((r), fp))
  39.  
  40. #define PutWord(fp, r)    ((void) putc((r) >> 8,  fp), \
  41.              (void) putc((r), fp))
  42. #define Put3Byte(fp, r)    ((void) putc((r) >> 16, fp), \
  43.              (void) putc((r) >> 8, fp), \
  44.              (void) putc((r), fp))
  45. #define PutLong(fp, r)    ((void) putc((r) >> 24, fp), \
  46.              (void) putc((r) >> 16, fp), \
  47.              (void) putc((r) >> 8, fp), \
  48.              (void) putc((r), fp))
  49.  
  50. /*
  51.  * Function types
  52.  */
  53. i32    GetByte(), GetWord(), Get3Byte(), GetLong();
  54.