123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- #include <opc/config.h>
- #ifndef OPC_FILE_H
- #define OPC_FILE_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define OPC_FILE_READ (1<<0)
- #define OPC_FILE_WRITE (1<<1)
- #define OPC_FILE_TRUNC (1<<2)
-
- typedef enum OPC_FILESEEKMODE_ENUM {
- opcFileSeekSet = SEEK_SET,
- opcFileSeekCur = SEEK_CUR,
- opcFileSeekEnd = SEEK_END
- } opcFileSeekMode;
-
- typedef int opcFileReadCallback(void *iocontext, char *buffer, int len);
-
- typedef int opcFileWriteCallback(void *iocontext, const char *buffer, int len);
-
- typedef int opcFileCloseCallback(void *iocontext);
-
- typedef opc_ofs_t opcFileSeekCallback(void *iocontext, opc_ofs_t ofs);
-
- typedef int opcFileTrimCallback(void *iocontext, opc_ofs_t new_size);
-
- typedef int opcFileFlushCallback(void *iocontext);
-
- typedef struct OPC_FILERAWSTATE_STRUCT {
- opc_error_t err;
- opc_ofs_t buf_pos;
- } opcFileRawState;
-
- typedef struct OPC_IO_STRUCT {
- opcFileReadCallback *_ioread;
- opcFileWriteCallback *_iowrite;
- opcFileCloseCallback *_ioclose;
- opcFileSeekCallback *_ioseek;
- opcFileTrimCallback *_iotrim;
- opcFileFlushCallback *_ioflush;
- void *iocontext;
- int flags;
- opcFileRawState state;
- opc_ofs_t file_size;
- } opcIO_t;
-
- opc_error_t opcFileInitIO(opcIO_t *io,
- opcFileReadCallback *ioread,
- opcFileWriteCallback *iowrite,
- opcFileCloseCallback *ioclose,
- opcFileSeekCallback *ioseek,
- opcFileTrimCallback *iotrim,
- opcFileFlushCallback *ioflush,
- void *iocontext,
- pofs_t file_size,
- int flags);
-
- opc_error_t opcFileInitIOFile(opcIO_t *io, const xmlChar *filename, int flags);
-
- opc_error_t opcFileInitIOMemory(opcIO_t *io, const opc_uint8_t *data, opc_uint32_t data_len, int flags);
-
- opc_error_t opcFileCleanupIO(opcIO_t *io);
- #ifdef __cplusplus
- }
- #endif
-
- #endif
|