home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / BRIK.ZIP / BRIK.H < prev    next >
C/C++ Source or Header  |  1989-03-13  |  7KB  |  158 lines

  1. /* ::[[ @(#) brik.h 1.26 89/03/11 16:54:08 ]]:: */
  2.  
  3. /*
  4. Checksum:   48859975      (check or update this with "brik")
  5. */
  6.  
  7. /*
  8. The contents of this file are hereby released to the public domain.
  9.  
  10.                                    -- Rahul Dhesi 1989/03/10
  11. */
  12.  
  13. /*
  14. Brik assumes eight-bit bytes and the ASCII character set.  There may also
  15. be some implicit assumptions that the parity bit in characters in text
  16. files is always zero.
  17.  
  18. Options for compiling brik.c on various systems.
  19.  
  20. TRAIL_TB    Define this if a trailing "t" or "b" is needed in the fopen mode
  21.             string to open files in text or binary mode respectively.  Can
  22.             probably be safely defined even for System V and 4.3BSD, since
  23.             compilers will typically just ignore it.
  24. WILDCARD    Define this if wildcards are to be expanded by this program.
  25.             If WILDCARD is defined, then a function nextfile() must also
  26.             be available that conforms to the specifications in turboc.c.
  27. USEINDEX    Define this symbol to make brik use index() instead of strchr().
  28.             Probably needed only 4.2BSD and earlier.
  29. BRKTST      If defined, brik will explicitly test for user interrupts in
  30.             all long loops, so that the program can easily be interrupted
  31.             on microcomputers that don't accept user interrupts
  32.             asynchronously.  If BRKTST is defined, brik will call the
  33.             function brktst() periodically.  This function should check
  34.             for a user interrupt and abort the program if it has occurred.
  35. NIXSEEK     If seeks are UNIX-like, i.e., seeks are possible at any byte
  36.             offset even in text files, then NIXSEEK may be defined to make
  37.             the -gW option perform faster.  If NIXSEEK is not defined, all
  38.             seeks will be to line boundaries using an offset already
  39.             obtained from ftell().  Even on non-UNIX-like systems, it *may*
  40.             be possible to define NIXSEEK, since when brik seeks to an
  41.             arbitrary byte boundary, it always immediately reads
  42.             sequentially forward to a line boundary.  Seeks are needed only
  43.             for the -gW option, which causes brik to seek back to where
  44.             it found the Checksum: header so it can update the stored CRC.
  45. CHECKSEEK   If seeks are flaky despite NIXSEEK being defined, it may help
  46.             to define CHECKSEEK.  In this case brik will seek, read a line,
  47.             seek again, read the line again, compare the two, and proceed
  48.             only if both reads gave the checksum header it was looking for,
  49.             thus confirming that the seeks are working right.  This is
  50.             a very conservative strategy to minimize the risk of corrupting
  51.             a file by overwriting it at the wrong place due to a faulty
  52.             seek.
  53. BUG1,       If ftell() just after fgets() does not return the correct seek
  54. BUG2        offset of the next line, one of these two symbols can be defined
  55.             (but not both).  Each adds different bug fix code and one of them
  56.             may work for you.
  57. ANSIPROTO   If defined, ANSI-style function prototypes will be used.
  58.             If using this symbol creates trouble because your stdio.h
  59.             has slightly different prototypes, don't define it.
  60. NDEBUG      If this symbol is defined, assert() macros throughout the
  61.             brik code will get nulled out, making the executable code
  62.             slightly smaller.
  63. DEBUG       If this symbol is defined, an undocumented -d switch will
  64.             be accepted that will cause information about Checksum:
  65.             header reads and writes to be printed.
  66. EXITBUG     Define this symbol if the exit() function has a bug causing
  67.             anomalous results if the exit code is not exactly 1.
  68. AVOID_MACROS  Brik uses macros for speed in case-insensitive string
  69.             comparisons.  If you get "macro too long" or "expression too
  70.             complex" or similar compilation errors, you can define the
  71.             symbol AVOID_MACROS.  This will cause slower but more compact
  72.             code to be used that does not use long macros, possibly
  73.             allowing compilation.
  74. LOWERIT     If a fast macro or function call is available that will accept
  75.             a single parameter of type "int" and return its lowercase
  76.             value, the symbol LOWERIT may be defined to invoke it.  This
  77.             macro or function must accept any int value, whether or not
  78.             it represents an uppercase character.  Since LOWERIT is
  79.             never called with side-effects, it can safely be a macro.
  80.             If any include file is needed, include it here.  For example,
  81.             if a tolower() macro or function is available that requires
  82.             <ctype.h> to be included, use "#include <ctype.h>" followed
  83.             by "#define LOWERIT tolower" somewhere in brik.h.
  84. STRNICMP    If a case-insensitive implementation of strncmp is available,
  85.             define STRNICMP to be equivalent to it.  If STRNICMP is not
  86.             defined, brik uses its own case-insensitive string comparison
  87.             function.  STRNICMP must accept the same arguments as strncmp.
  88. BINCHAR     Brik uses a simple range test to detect binary characters and
  89.             warn the user if a text mode CRC is being used on a binary file.
  90.             The user may optionally define his own BINCHAR(c) macro, which
  91.             must return nonzero if c should be considered a binary character.
  92. NOCASE      This symbol should be defined if the filesystem is case-
  93.             insensitive.  It will cause all filenames printed to be in
  94.             lowercase.  This will help make a list of files generated by
  95.             the -G option to be more easily usable on systems with case-
  96.             sensitive filesystems, as most file transfer mechanisms (e.g.
  97.             zmodem, kermit, zoo archives) will be compatible with this.
  98.  
  99.                                      -- Rahul Dhesi
  100.                                         1989/03/11
  101.                                         UUCP:      iuvax!bsu-cs!dhesi
  102.                                         Internet:  dhesi@bsu-cs.bsu.edu
  103. */
  104.  
  105. #ifdef TURBOC
  106. # define TRAIL_T
  107. # define WILDCARD
  108. # define ANSIPROTO
  109. # define BRKTST
  110. # define BUG1
  111. # define NOCASE
  112. # define STRNICMP    strnicmp
  113.   int strnicmp (char *, char *, unsigned);
  114. # include <ctype.h>
  115. # define LOWERIT tolower
  116. #endif /* TURBOC */
  117.  
  118. #ifdef SYS_V
  119. # define NIXSEEK
  120. #endif /* SYS_V */
  121.  
  122. #ifdef BSD
  123. # define NIXSEEK
  124. # define USEINDEX
  125. #endif /* BSD */
  126.  
  127. #ifdef VMS
  128. # define WILDCARD
  129. # define CHECKSEEK
  130. # define BUG2
  131. # define EXITBUG
  132. # define NOCASE
  133. #endif /* VMS */
  134.  
  135. #ifdef BUG1
  136. # define SEEKFIX  \
  137.  fgetc(fptr);while(lowerit(fgetc(fptr))!='c')fseek(fptr,-2L,1);fseek(fptr,-1L,1);
  138. #endif
  139.  
  140.  
  141. #ifdef BUG2
  142. # define SEEKFIX  \
  143.    fseek(fptr,-2L,1);while(fgetc(fptr)!='\n');
  144. #endif
  145.  
  146. #ifndef BUG1
  147. # ifndef BUG2
  148. #  define SEEKFIX
  149. # endif
  150. #endif
  151.  
  152. /* another thing to try */
  153. /* fseek(fptr,-2L,1);while(lowerit(fgetc(fptr))!='C');fseek(fptr,-1L,1); */
  154.  
  155. #ifdef EXITBUG
  156. # define exit bugexit
  157. #endif
  158.