home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / archiver / rblharc / lhio.h < prev    next >
C/C++ Source or Header  |  1993-07-08  |  2KB  |  77 lines

  1. /*----------------------------------------------------------------------*/
  2. /*        File I/O module for LHarc UNIX                */
  3. /*                                    */
  4. /*        Copyright(C) MCMLXXXIX  Yooichi.Tagawa            */
  5. /*                                    */
  6. /*  V0.00  Original                1989.06.25  Y.Tagawa    */
  7. /*  V0.03  Release #3  Beta Version        1989.07.02  Y.Tagawa    */
  8. /*----------------------------------------------------------------------*/
  9.  
  10. extern int        text_mode;
  11.  
  12. extern unsigned int    crc_table[0x100];
  13. extern unsigned int    crc_value;
  14. extern int        crc_getc_cashe;
  15. extern FILE        *crc_infile, *crc_outfile;
  16. extern long        crc_size;
  17. #ifdef atarist
  18. #  ifndef TSTFLG
  19. #    define TSTFLG 1
  20. #  endif
  21. #endif
  22.  
  23. #ifdef TSTFLG
  24. extern int tstflg;
  25. #endif
  26.  
  27. #define CRC_CHAR(c)                        \
  28. { register unsigned int ctmp = crc_value ^ c;             \
  29.       crc_value = (ctmp >> 8) ^ crc_table [ ctmp & 0xff ]; }
  30.  
  31.  
  32.  
  33. #if defined (__GNUC__)
  34. /*#define inline*/
  35.  
  36. /* DECODING */
  37. /* '0D0A' -> '0A' conversion and strip '1A' when text_mode */
  38. static inline putc_crc (int c)
  39. {
  40.     CRC_CHAR (c);
  41.     
  42. #ifdef atarist
  43.     if (!tstflg) /* If we are EXtracting the archive not merely Testing */
  44. #endif
  45.     if (!text_mode || (c != 0x0d && c != 0x1a))
  46.     {
  47.         putc (c, crc_outfile);
  48.     }
  49. }
  50.  
  51. /* ENCODING */
  52. /* '0A' -> '0D0A' conversion when text_mode */
  53. static int getc_crc ()
  54. {
  55.     int    c;
  56.     
  57.     if (crc_getc_cashe != EOF)
  58.     {
  59.     c = crc_getc_cashe;
  60.     crc_getc_cashe = EOF;
  61.     CRC_CHAR (c);
  62.     crc_size++;
  63.     }
  64.     else if ((c = getc (crc_infile)) != EOF)
  65.     {
  66.     if (text_mode && c == 0x0a)
  67.     {
  68.         crc_getc_cashe = c;
  69.         c = 0x0d;
  70.     }
  71.     CRC_CHAR (c);
  72.     crc_size++;
  73.     }
  74.     return c;
  75. }
  76. #endif
  77.