#ifndef LIBIO_H #define LIBIO_H #define BUFSIZE 131072 struct file_t; struct file_t { long long cur, /* Index of the current symbol. */ end; /* Index of the last symbols. */ unsigned char *buf; /* Buffer. Allocated while I/O. Need to be void*? */ int fd; }; typedef struct file_t FILE_T; extern FILE_T std_streams[3]; #define STDINF (&std_streams[0]) #define STDOUTF (&std_streams[1]) #define STDERRF (&std_streams[2]) FILE_T *file_open( const char* path, int flags ); int file_close( FILE_T* file ); int file_fd( FILE_T *file ); void file_fresh( FILE_T *file ); int fgetchr( FILE_T *file ); int wgetchr( struct file_t *file, char *bytes); /* No buffer. No more. */ int fmt_print( int fd, const char* fmt, ... ); #define print( fmt,... ) fmt_print( STDOUT_FILENO, fmt, __VA_ARGS__ ) #define eprint( fmt,... ) fmt_print( STDERR_FILENO, fmt, __VA_ARGS__ ) #define puts( msg ) fmt_print( STDOUT_FILENO, msg ) #define eputs( msg ) fmt_print( STDERR_FILENO, msg ) int putstr( int fd, const char* str ); #endif /* LIBIO_H*/