home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
SRC
/
lharc.lzh
/
LHARC
/
lhio.h
< prev
next >
Wrap
Text File
|
1991-07-29
|
2KB
|
89 lines
/*----------------------------------------------------------------------*/
/* File I/O module for LHarc UNIX */
/* */
/* Copyright(C) MCMLXXXIX Yooichi.Tagawa */
/* */
/* V0.00 Original 1989.06.25 Y.Tagawa */
/* V0.03 Release #3 Beta Version 1989.07.02 Y.Tagawa */
/*----------------------------------------------------------------------*/
extern int text_mode;
extern unsigned int crc_table[0x100];
extern unsigned int crc_value;
extern int crc_getc_cashe;
extern FILE *crc_infile, *crc_outfile;
extern long crc_size;
#define CRC_CHAR(c) \
{ register unsigned int ctmp = crc_value ^ c; \
crc_value = (ctmp >> 8) ^ crc_table [ ctmp & 0xff ]; }
#if defined (__GNUC__)
/*#define inline*/
static inline fastputc(char ch,register FILE *file)
{
if (file->_ptr != NULL && file->_ptr < file->_end-1)
*(file->_ptr)++ = ch;
else
putc(ch,file);
}
static inline int fastgetc(register FILE *file)
{
if (file->_ptr != NULL && file->_ptr < file->_end)
return(*((unsigned char *) file->_ptr)++);
else
return(getc(file));
}
/* DECODING */
/* '0D0A' -> '0A' conversion and strip '1A' when text_mode */
static inline putc_crc (int c)
{
CRC_CHAR (c);
if (!text_mode || (c != 0x0d && c != 0x1a))
{
#ifdef OSK
fastputc (c, crc_outfile);
#else
putc (c, crc_outfile);
#endif
}
}
/* ENCODING */
/* '0A' -> '0D0A' conversion when text_mode */
static inline int getc_crc ()
{
int c;
if (crc_getc_cashe != EOF)
{
c = crc_getc_cashe;
crc_getc_cashe = EOF;
CRC_CHAR (c);
crc_size++;
}
#ifdef OSK
else if ((c = getc (crc_infile)) != EOF)
#else
else if ((c = fastgetc (crc_infile)) != EOF)
#endif
{
if (text_mode && c == 0x0a)
{
crc_getc_cashe = c;
c = 0x0d;
}
CRC_CHAR (c);
crc_size++;
}
return c;
}
#endif