00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef GUTHTHILA_READER_H
00019 #define GUTHTHILA_READER_H
00020
00021 #include <stdio.h>
00022 #include <guththila_defines.h>
00023 #include <axutil_utils.h>
00024 EXTERN_C_START() typedef int(
00025 GUTHTHILA_CALL * GUTHTHILA_READ_INPUT_CALLBACK)(
00026 guththila_char_t *buffer,
00027 int size,
00028 void *ctx);
00029 enum guththila_reader_type
00030 {
00031 GUTHTHILA_FILE_READER =
00032 1, GUTHTHILA_IO_READER, GUTHTHILA_MEMORY_READER
00033 };
00034 typedef struct guththila_reader_s
00035 {
00036 int
00037 type;
00038
00039 FILE *
00040 fp;
00041 guththila_char_t *
00042 buff;
00043 int
00044 buff_size;
00045
00046 GUTHTHILA_READ_INPUT_CALLBACK
00047 input_read_callback;
00048 void *
00049 context;
00050
00051 }
00052 guththila_reader_t;
00053
00054 #ifndef GUTHTHILA_READER_SET_LAST_START
00055 #define GUTHTHILA_READER_SET_LAST_START(_reader, _start) ((_reader)->start = _start)
00056 #endif
00057
00058 #ifndef GUTHTHILA_READER_STEP_BACK
00059 #define GUTHTHILA_READER_STEP_BACK(_reader) ((_reader->next--))
00060 #endif
00061 GUTHTHILA_EXPORT guththila_reader_t * GUTHTHILA_CALL
00062 guththila_reader_create_for_file(guththila_char_t *filename,
00063 const axutil_env_t * env);
00064 GUTHTHILA_EXPORT guththila_reader_t * GUTHTHILA_CALL
00065 guththila_reader_create_for_io(GUTHTHILA_READ_INPUT_CALLBACK
00066 input_read_callback, void *ctx,
00067 const axutil_env_t * env);
00068 GUTHTHILA_EXPORT guththila_reader_t * GUTHTHILA_CALL
00069 guththila_reader_create_for_memory(void *buffer,
00070 int size,
00071 const axutil_env_t * env);
00072 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_reader_read(
00073 guththila_reader_t * r,
00074 guththila_char_t * buffer,
00075 int offset,
00076 int length,
00077 const axutil_env_t * env);
00078 GUTHTHILA_EXPORT void GUTHTHILA_CALL guththila_reader_free(
00079 guththila_reader_t * r,
00080 const axutil_env_t * env);
00081 EXTERN_C_END()
00082 #endif
00083