JD2022-TU1/main/extern/rfphio/rfphio_lib/include/rfp.h

124 lines
No EOL
4 KiB
C

#ifndef _DRFP_H
#define _DRFP_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
u_int requestOrReplyCode; //file operation request or reply
u_int requestSequenceNumber; //reply should match this number from the request
} DRFP_HDR;
typedef struct {
u_int flag; //flag bits to use for opening a file
char filename[0];
} DRFP_OPEN_BLOCK;
//valid open flags
#define DRFP_OPEN_RDONLY 0x0001 //read only mode
#define DRFP_OPEN_WRONLY 0x0002 //write only mode
#define DRFP_OPEN_RDWR 0x0003 //read/write mode
#define DRFP_OPEN_CREAT 0x0200 //create a file when none exists
#define DRFP_OPEN_TRUNC 0x0400 //truncate and set to zero
#define DRFP_OPEN_EXCL 0x0800 //error if file already exists on create
typedef struct {
u_int result; //flag bits to show result of the open
u_int fd; //file descriptor for the opened file
} DRFP_OPEN_R_BLOCK;
//valid open reply result flags
#define DRFP_OPENR_OKAY 0 //open okay
#define DRFP_OPENR_ENOENT 2 //file not found
#define DRFP_OPENR_EACCES 13 //violation of permissions
#define DRFP_OPENR_EEXIST 17 //file already exists
#define DRFP_OPENR_ENFILE 23 //max files already opened
#define DRFP_OPENR_ENOSPC 28 //no space on disk
#define DRFP_OPENR_EROFS 30 //trying to open a read-only file by writing to it
#define DRFP_OPENR_EDQUOT 122 //no space in directory
#define DRFP_OPENR_UNKNOWN 0xffff //unknown open error
typedef struct {
u_int fd; //file descriptor for the file to close
}DRFP_CLOSE_BLOCK;
typedef struct {
u_int result; //flag bits to show result of the close
}DRFP_CLOSE_R_BLOCK;
//valid close reply result flags
#define DRFP_CLOSER_OKAY 0 //file closed
#define DRFP_CLOSER_EBADF 9 //the given fd has not been opened
#define DRFP_CLOSER_UNKNOWN 0xffff //unknown close error
typedef struct {
u_int fd; //file descriptor for the file to read
u_int numBytes; //num bytes to read
}DRFP_READ_BLOCK;
typedef struct {
u_int result; //flag bits to show result of the read
u_int numBytes; //num bytes in buffer
char data[0];
}DRFP_READ_R_BLOCK;
//valid read reply result flags
#define DRFP_READR_OKAY 0 //read okay
#define DRFP_READR_EIO 5 //error on read
#define DRFP_READR_EBADF 9 //the given fd has not been opened
#define DRFP_READR_UNKNOWN 0xffff //unknown read error
typedef struct {
u_int fd; //file descriptor for the file to write to
u_int numBytes; //num bytes to write
char data[0]; //data passed from the PS2 that we need to write out to a file
}DRFP_WRITE_BLOCK;
typedef struct {
u_int result; //flag bits to show result of the write
u_int numBytes; //num bytes written
}DRFP_WRITE_R_BLOCK;
//valid write reply result flags
#define DRFP_WRITER_OKAY 0 //write okay
#define DRFP_WRITER_EIO 5 //error on write
#define DRFP_WRITER_EBADF 9 //the given fd has not been opened
#define DRFP_WRITER_ENOSPC 28 //the given fd has not been opened
#define DRFP_WRITER_UNKNOWN 0xffff //unknown write error
typedef struct
{
u_int fd; //file descriptor for the file to seek in
u_int offset; //amount to move file pointer, in bytes
u_int base; //flag for where to start seek from
} DRFP_SEEK_BLOCK;
typedef struct {
u_int result; //flag bits to show result of the seek
u_int filePos; //position of the file pointer after seek
} DRFP_SEEK_R_BLOCK;
//valid seek reply result flags
#define DRFP_SEEKR_OKAY 0 //seek okay
#define DRFP_SEEKR_EBADF 9 //the given fd has not been opened
#define DRFP_SEEKR_UNKNOWN 0xffff //unknown seek error
//message type codes (request and replies)
#define DRFP_CODE_OPEN 0 //open request
#define DRFP_CODE_OPENR 1 //open reply
#define DRFP_CODE_CLOSE 2 //close request
#define DRFP_CODE_CLOSER 3 //close reply
#define DRFP_CODE_READ 4 //read request
#define DRFP_CODE_READR 5 //read reply
#define DRFP_CODE_WRITE 6 //write request
#define DRFP_CODE_WRITER 7 //write reply
#define DRFP_CODE_SEEK 8 //seek request
#define DRFP_CODE_SEEKR 9 //seek reply
#ifdef __cplusplus
}
#endif
#endif /* _DRFP_H */