home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- * *
- * io.h *
- * ==== *
- * *
- * I/O routines for image conversion programs *
- * *
- * Version 1.00 (13-Aug-1993) *
- * 1.10 (20-Aug-1993) read_struct & write_struct added *
- * 1.20 (22-Aug-1993) new endian routines added *
- * 1.30 (23-Aug-1993) progess function added *
- * 1.42 (12-Oct-1993) progess start & finish functions added *
- * *
- * (C) 1993 DEEJ Technology PLC *
- * *
- ****************************************************************************/
-
- #ifndef __io_h
- #define __io_h
-
- #define uchar unsigned char
- #define ushort unsigned short
- #define uint unsigned int
-
- #ifndef BYTE
- #define BYTE unsigned char
- #define WORD unsigned short
- #define DWORD unsigned int
- #endif
-
- /* endian type definititions */
-
- #define LITTLE_ENDIAN 0
- #define BIG_ENDIAN 1
- #define LE LITTLE_ENDIAN
- #define BE BIG_ENDIAN
-
- /**** machine configuration ****/
-
- #ifdef RISCOS
- #define ENDIAN_TYPE LITTLE_ENDIAN
- #define ALIGN_WORD 2
- #define ALIGN_DWORD 4
- #define ENDIAN_MACROS
- #endif
-
- #ifdef M68K
- /* 68000 based */
- #define ENDIAN_TYPE BIG_ENDIAN
- #define ALIGN_WORD 2
- #define ALIGN_DWORD 2
- #endif
-
- #ifdef SPARC
- #define ENDIAN_TYPE BIG_ENDIAN
- #define ALIGN_WORD 2
- #define ALIGN_DWORD 4
- #endif
-
- #ifdef PA_RISC
- #define ENDIAN_TYPE BIG_ENDIAN
- #define ALIGN_WORD 2
- #define ALIGN_DWORD 4
- #endif
-
- /* add new machine definitions here */
-
- #ifndef ENDIAN_TYPE
- /* comment follow line if compiler does not support it */
- #error "io.h: Not setup for this machine"
- #endif
-
- #ifndef TRUE
- #define TRUE 1
- #define FALSE 0
- #endif
- #ifndef BOOL
- #define BOOL int
- #endif
-
- /* macros */
-
- #ifdef ENDIAN_MACROS
-
- #define swap_endian(dword) ( ((dword & 0xff000000)>>24) | \
- ((dword & 0x00ff0000)>>8) | \
- ((dword & 0x0000ff00)<<8) | \
- ((dword & 0x000000ff)<<24) )
-
- #define swap_endian_word(word) ( ((ushort)(word & 0xff00)>>8) | \
- ((ushort)(word & 0x00ff)<<8) )
-
- #define endian(type,dword) ((type!=ENDIAN_TYPE) ? swap_endian(dword) : dword)
- #define endian_w(type,word) ((type!=ENDIAN_TYPE) ? swap_endian(word) : word)
-
- #define bit_swap(byte) ( ((byte & 0x80)>>7) | \
- ((byte & 0x40)>>5) | \
- ((byte & 0x20)>>3) | \
- ((byte & 0x10)>>1) | \
- ((byte & 0x08)<<1) | \
- ((byte & 0x04)<<3) | \
- ((byte & 0x02)<<5) | \
- ((byte & 0x01)<<7) )
-
- #define bit2_swap(byte) ( ((byte & 0xC0)>>6) | \
- ((byte & 0x30)>>2) | \
- ((byte & 0x0C)<<2) | \
- ((byte & 0x03)<<6) )
-
- #define bit4_swap(byte) ( ((byte & 0xF0)>>4) | \
- ((byte & 0x0F)<<4) )
-
- #else
-
- extern uint bit_swap(uint);
- extern uint bit2_swap(uint);
- extern uint bit4_swap(uint);
- extern uint swap_endian(uint);
- extern ushort swap_endian_word(ushort);
- extern uint endian(int, uint);
- extern ushort endian_w(int, ushort);
-
- #endif
-
- /* function prototypes */
-
- extern void fputwLE(WORD, FILE*);
- extern ushort fgetwLE(FILE*);
- extern void fputwBE(WORD, FILE*);
- extern ushort fgetwBE(FILE*);
- extern void fputdLE(DWORD, FILE*);
- extern uint fgetdLE(FILE*);
- extern void fputdBE(DWORD, FILE*);
- extern uint fgetdBE(FILE*);
- extern void file_args(int, char**, FILE**, FILE**, FILE**);
- extern void read_struct(int, BYTE*, int*, FILE*);
- extern void write_struct(int, BYTE*, int*, FILE*);
- extern void progress_start(char*);
- extern void progress(int, int);
- extern void progress_finish(void);
-
- #endif
-