/**************************************************************************************/ /* Header for Cycfcntl.c */ /* Copyright(C)1999 Peter Armstrong */ /* Release 2.0 */ /**************************************************************************************/ /* structure for PC file & directory information, values returned by cyc_findfirst/next() */ struct c_find { int attrib; /* attribute bits, see CA_ macros below */ u_int wr_time; /* time file was last written to */ u_int wr_date; /* date file was last written to */ int size; /* size in bytes */ char name[13]; /* name in dos 8.3 format */ }; /* attribute bit values */ #define CA_NORMAL 0x0000 /* ordinary file, no attributes */ #define CA_RDONLY 0x0001 /* read only */ #define CA_HIDDEN 0x0002 /* hidden file */ #define CA_SYSTEM 0x0004 /* system file */ #define CA_VOLID 0x0008 /* volume label */ #define CA_SUBDIR 0x0010 /* sub-directory */ #define CA_ARCH 0x0020 /* archive bit set */ /* cyc_creat() file creation flags */ #define C_IREAD 0x0100 /* read mode */ #define C_IWRITE 0x0080 /* write mode */ #define C_IRDWR C_IREAD|C_IWRITE /* read/write mode */ /* cyc_open() file opening flags */ #define C_RDONLY 0x0001 #define C_WRONLY 0x0002 #define C_RDWR 0x0004 #define C_CREAT 0x0100 /* create and open file (new files are read-only) */ #define C_TRUNC 0x0200 /* open with truncation */ #define C_EXCL 0x0400 /* open only if non-existant */ #define C_APPEND 0x0800 /* append data to end of file */ #define C_BINARY 0x8000 /* open with this for all non-text files */ #define C_TEXT 0x4000 /* CR-LF translation */ /* macros for cyc_lseek() origin */ #define C_SEEK_CUR 1 /* current file position */ #define C_SEEK_END 2 /* end of file */ #define C_SEEK_SET 0 /* start of file */ /* return values for cyc_ping() */ #define PNG_PC 1 /* connected to PC */ #define PNG_PSX 0 /* connected to psx */ #define PNG_NG -1 /* no response, not connected (at time of calling) */ #define BLK_SIZE 4096 /* max write-out block size */ #define RLE_BUF_SIZE 4096 /* size of RLE data buffer to allocate */ #define RLE_BLK 0x8000 /* RLE block flag */ #define RLE_HDR 0x8000 /* RLE in-block header */ #define RLE_END 0x4000 /* RLE block end marker */ /* return values for block_read/write() */ #define B_OK 1 /* read/write successful */ #define B_CNT_ERROR 0 /* not connected to other psx */ #define B_TIMEOUT -1 /* communications error (serial port time-out) */ #define B_CMD_MISMATCH -2 /* write not matched by read & vice versa */ #define B_ID_MISMATCH -3 /* different data identifiers */ #define B_SIZE_MISMATCH -4 /* invalid block size */ #define B_MEM_FAIL -5 /* malloc() failure on block_read()ing psx */ /* block commands from remote */ #define B_READ 'R' /* read block */ #define B_WRITE 'W' /* write block */ #define B_CANX 'X' /* cancel block command */ /* prototypes */ int cyc_ping(void); int cyc_printf(char *format_str, ...); int cyc_findfirst(char *fname,int attr,struct c_find *ptr); int cyc_findnext(struct c_find *ptr); int cyc_getfileattr(char *fname, u_int *attrib); int cyc_setfileattr(char *fname, u_int attrib); int cyc_creat(char *fname,int pmode); int cyc_open(char *fname,int mode); int cyc_close(int fd); long cyc_lseek(int fd,int offset,int origin); int cyc_unlink(char *fname); int cyc_system(char *cmd); long cyc_tell(int fd); int cyc_eof(int fd); int cyc_read(int fd,char *buf,u_int num); int RLEtoRaw(int data_size); int cyc_write(int fd,char *buf,u_int num); int block_read(int id, char **buf, int size); int Send_RdBlockCmd(int id); int ReadIn_Block(char **buf, int size); int Read_Block(char *buf, int size); int block_write(int id, char *buf, int size); int Send_WrBlockCmd(int id); int WriteOut_Block(char *buf, int size); int Write_Block(char *buf, int size); int cyc_exit(void);