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
00025 EXTERN_C_START()
00026
00027 typedef int(GUTHTHILA_CALL * GUTHTHILA_READ_INPUT_CALLBACK)(
00028 guththila_char_t *buffer,
00029 int size,
00030 void *ctx);
00031
00032 enum guththila_reader_type
00033 {
00034 GUTHTHILA_FILE_READER = 1,
00035 GUTHTHILA_IO_READER,
00036 GUTHTHILA_MEMORY_READER
00037 };
00038
00039 typedef struct guththila_reader_s
00040 {
00041 int type;
00042 FILE *fp;
00043 guththila_char_t *buff;
00044 int buff_size;
00045 GUTHTHILA_READ_INPUT_CALLBACK input_read_callback;
00046 void *context;
00047 } guththila_reader_t;
00048
00049 #ifndef GUTHTHILA_READER_SET_LAST_START
00050 #define GUTHTHILA_READER_SET_LAST_START(_reader, _start) ((_reader)->start = _start)
00051 #endif
00052
00053 #ifndef GUTHTHILA_READER_STEP_BACK
00054 #define GUTHTHILA_READER_STEP_BACK(_reader) ((_reader->next--))
00055 #endif
00056
00057
00058
00059
00060
00061
00062 GUTHTHILA_EXPORT guththila_reader_t * GUTHTHILA_CALL
00063 guththila_reader_create_for_file(guththila_char_t *filename,
00064 const axutil_env_t * env);
00065
00066
00067
00068
00069
00070
00071
00072 GUTHTHILA_EXPORT guththila_reader_t * GUTHTHILA_CALL
00073 guththila_reader_create_for_io(GUTHTHILA_READ_INPUT_CALLBACK
00074 input_read_callback, void *ctx,
00075 const axutil_env_t * env);
00076
00077
00078
00079
00080
00081
00082
00083 GUTHTHILA_EXPORT guththila_reader_t * GUTHTHILA_CALL
00084 guththila_reader_create_for_memory(void *buffer,
00085 int size,
00086 const axutil_env_t * env);
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 GUTHTHILA_EXPORT int GUTHTHILA_CALL guththila_reader_read(
00098 guththila_reader_t * r,
00099 guththila_char_t * buffer,
00100 int offset,
00101 int length,
00102 const axutil_env_t * env);
00103
00104
00105
00106
00107
00108
00109 GUTHTHILA_EXPORT void GUTHTHILA_CALL guththila_reader_free(
00110 guththila_reader_t * r,
00111 const axutil_env_t * env);
00112
00113 EXTERN_C_END()
00114 #endif
00115