2013-01-11 01:48:46 +08:00
|
|
|
#ifndef FOUG_C_STREAM_H
|
|
|
|
#define FOUG_C_STREAM_H
|
|
|
|
|
2013-01-16 00:56:24 +08:00
|
|
|
#include "global.h"
|
2013-01-11 01:48:46 +08:00
|
|
|
#include "memory.h"
|
|
|
|
|
|
|
|
/* foug_stream : opaque structure */
|
|
|
|
typedef struct _internal_foug_stream foug_stream_t;
|
|
|
|
|
|
|
|
/* foug_stream_manip */
|
2013-02-21 21:51:29 +08:00
|
|
|
typedef struct foug_stream_manip
|
2013-01-11 01:48:46 +08:00
|
|
|
{
|
2013-02-21 21:51:29 +08:00
|
|
|
foug_bool_t (*at_end_func)(foug_stream_t*);
|
|
|
|
int32_t (*error_func)(foug_stream_t*);
|
|
|
|
size_t (*read_func)(foug_stream_t*, void*, size_t, size_t);
|
|
|
|
size_t (*write_func)(foug_stream_t*, const void*, size_t, size_t);
|
2013-01-11 01:48:46 +08:00
|
|
|
} foug_stream_manip_t;
|
|
|
|
|
2013-01-15 23:45:01 +08:00
|
|
|
FOUG_LIB_EXPORT foug_stream_manip_t foug_stream_manip_null();
|
|
|
|
FOUG_LIB_EXPORT foug_stream_manip_t foug_stream_manip_stdio();
|
2013-01-11 01:48:46 +08:00
|
|
|
|
|
|
|
/* Services */
|
2013-02-21 21:51:29 +08:00
|
|
|
|
2013-01-15 23:45:01 +08:00
|
|
|
FOUG_LIB_EXPORT foug_stream_t* foug_stream_create(foug_malloc_func_t func,
|
|
|
|
void* data,
|
|
|
|
foug_stream_manip_t manip);
|
2013-01-11 01:48:46 +08:00
|
|
|
|
2013-01-15 23:45:01 +08:00
|
|
|
FOUG_LIB_EXPORT foug_bool_t foug_stream_at_end(foug_stream_t* stream);
|
2013-02-21 21:51:29 +08:00
|
|
|
|
2013-01-15 23:45:01 +08:00
|
|
|
FOUG_LIB_EXPORT int foug_stream_error(foug_stream_t* stream);
|
2013-02-21 21:51:29 +08:00
|
|
|
|
2013-01-15 23:45:01 +08:00
|
|
|
FOUG_LIB_EXPORT size_t foug_stream_read(foug_stream_t* stream,
|
2013-02-21 21:51:29 +08:00
|
|
|
void* ptr,
|
|
|
|
size_t item_size,
|
|
|
|
size_t item_count);
|
|
|
|
|
2013-01-15 23:45:01 +08:00
|
|
|
FOUG_LIB_EXPORT size_t foug_stream_write(foug_stream_t* stream,
|
2013-02-21 21:51:29 +08:00
|
|
|
const void* ptr,
|
|
|
|
size_t item_size,
|
|
|
|
size_t item_count);
|
|
|
|
|
2013-01-15 23:45:01 +08:00
|
|
|
FOUG_LIB_EXPORT void* foug_stream_get_cookie(const foug_stream_t* stream);
|
2013-02-21 21:51:29 +08:00
|
|
|
|
2013-02-05 19:24:13 +08:00
|
|
|
FOUG_LIB_EXPORT void foug_stream_set_cookie(foug_stream_t* stream, void* data);
|
2013-01-11 01:48:46 +08:00
|
|
|
|
|
|
|
#endif /* FOUG_C_STREAM_H */
|