00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CU_DSOURCE_H
00019 #define CU_DSOURCE_H
00020
00021 #include <cu/fwd.h>
00022 #include <stdarg.h>
00023
00024 CU_BEGIN_DECLARATIONS
00025
00026
00027
00028 #define CU_DSOURCE_FN_CLOSE 1
00029 #define CU_DSOURCE_ST_SUCCESS 0
00030 #define CU_DSOURCE_ST_UNIMPL ((cu_word_t)-1)
00031
00032 struct cu_dsource
00033 {
00034 cu_word_t (*control)(cu_dsource_t source, int op, va_list);
00035 size_t (*read)(cu_dsource_t source, void *buf, size_t max_size);
00036 };
00037
00038 CU_SINLINE void
00039 cu_dsource_init(cu_dsource_t source,
00040 cu_word_t (*control)(cu_dsource_t, int, va_list),
00041 size_t (*read)(cu_dsource_t, void *, size_t))
00042 {
00043 source->read = read;
00044 source->control = control;
00045 }
00046
00047 CU_SINLINE size_t
00048 cu_dsource_read(cu_dsource_t source, void *buf, size_t max_size)
00049 {
00050 return (*source->read)(source, buf, max_size);
00051 }
00052
00053 CU_SINLINE cu_word_t
00054 cu_dsource_control_va(cu_dsource_t source, int op, va_list va)
00055 {
00056 return (*source->control)(source, op, va);
00057 }
00058
00059 cu_word_t cu_dsource_control(cu_dsource_t source, int op, ...);
00060
00061
00062 CU_END_DECLARATIONS
00063
00064 #endif