00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _ABLE_CLIB_INTERNAL_FILE_H
00030 #define _ABLE_CLIB_INTERNAL_FILE_H 1
00031
00032
00033 #include <sys/types.h>
00034 #include <able/databuffer.h>
00035
00036
00037
00038
00039 struct __sbuf {
00040 unsigned char *_base;
00041 int _size;
00042 };
00043
00044 struct file_s {
00045 struct buffer *rd_buff;
00046 int fd;
00047 unsigned int flags;
00048
00049
00050 struct __sbuf _bf;
00051 unsigned char *_p;
00052 unsigned int _w;
00053 unsigned int _r;
00054 unsigned int _lbfsize;
00055 unsigned int _blksize;
00056
00057 unsigned char _nbuf[1];
00058
00059 void *_cookie;
00060 int (*_write)(void *, const char *, int);
00061 int (*_seek)(void *, int, int);
00062 };
00063
00064 struct buffered_file_s {
00065 struct file_s file;
00066 struct buffer rd_buff;
00067 };
00068
00069 #define FILEF_EOF (1<<14)
00070 #define FILEF_ERR (1<<15)
00071 #define __FILE_RD (1<<16)
00072 #define __FILE_WR (1<<17)
00073 #define __FILE_RW (1<<18)
00074 #define __FILE_STRINGFUNC (1<<19)
00075 #define __FILE_DYNAMICBUFF (1<<20)
00076 #define __FILE_MALLOCEDBUFF (1<<21)
00077 #define __FILE_NOSEEK (1<<22)
00078
00079 extern int FILE_write(void *cookie, const char *buff, int size);
00080
00081 #define INIT_FILE(__fd, __flags) \
00082 { \
00083 .rd_buff = NULL, \
00084 .fd = (__fd), \
00085 .flags = (__flags), \
00086 ._w = 0, \
00087 ._p = NULL, \
00088 ._lbfsize = 0, \
00089 ._cookie = (void *)(__fd), \
00090 ._write = FILE_write \
00091 }
00092
00093
00094
00095 extern FILE __default_stdin;
00096 extern FILE __default_stdout;
00097
00098 #endif