/* $Header: /CVSROOT/tinolib/old/io.h,v 1.3 2005/03/05 19:42:54 tino Exp $ * * Generic IO layer. For the moment this only includes tino/file.h * IF YOU WANT TO DEPEND ON THS, USE IT AS THE FIRST INCLUDE! * * In some distant future this will handle *all* IO the same way, * regardless if it is a file, directory, device, socket or telepathy. * YKWIM. * * Please read io.txt for more information. * * $Log: io.h,v $ * Revision 1.3 2005/03/05 19:42:54 tino * tino_file_mmap_anon added * * Revision 1.2 2005/01/04 13:23:49 tino * see ChangeLog, mainly changes for "make test" * * Revision 1.1 2004/10/05 02:05:11 tino * added (prototypes) */ #ifndef tino_INC_io_h #define tino_INC_io_h #define TINO_FILE_EXCEPTION #include "file.h" #include "exception.h" #include "alloc.h" #include "hash.h" #include #include /* Never even try to access or predict this. * It will be renamed/renumbered unconditionally! */ #define N 123123 #define I tino_io_##N /* Note that 0 always is stdin, 1 always is stdout and 2 always is stderr * Even if you close it ;) */ static struct tino_io_glob { int fd; /* -1: unused, -2:freed due to fd shortage */ int type; /* internal type, 0 if not set */ } *I; static int tino_io_fds; static void tino_io_init(int fds, void *thread_key) { 000; } static int tino_io_new(const char *type) { int fd; int i; /* Try to dup something */ fd = dup(2); if (fd<0) fd = socket(PF_LOCAL, SOCK_DGRAM, 0); if (fd<0 || fd>0x10000000) tino_throw(TINO_EX_IO, "new"); /* expand the working array */ if (fd>=tino_io_fds) { int i; i = fd+256; I = tino_realloc(I, i*sizeof *I); while (tino_io_fds=tino_io_fds) return -1; return I[io].fd; } /* Tell if EOF or ERROR condition: * Returns: * 1 if EOF, * 0 if no EOF and OK, * -1 if error state. */ static int tino_io_eof(int io) { 000; return 1; } /* Close IO: * Returns: * 0 if OK, * -1 if error state. */ static int tino_io_close(int io) { 000; return -1; } /* Do some processing. * Return if something is processed. * Returns number of signals received (EINTR) while everything is processed. * This function blocks maximum timeout seconds. * With timeout=0 it does not block at all. * With timeout=-1 it does block forever. */ static int tino_io_process(int timeout) { sleep(timeout); 000; return 0; } static int tino_io_open(const char *s, const char *mode, ...) { 000; return -1; } static int tino_io_set(int io, int token, const void *p, size_t len) { 000; return -1; } static int tino_io_set_ul(int io, int token, unsigned long ul) { return tino_io_set(io, token, &ul, sizeof ul); } static int tino_io_token(const char *s) { return tino_token(s)+N; } static void tino_io_copy(int in, int out) { 000; } #undef I #undef N #endif