00001 /* 00002 * Copyright (c) 2005, 2006 by KoanLogic s.r.l. <http://www.koanlogic.com> 00003 * All rights reserved. 00004 * 00005 * This file is part of KLone, and as such it is subject to the license stated 00006 * in the LICENSE file which you have received as part of this distribution. 00007 * 00008 * $Id: ioprv.h,v 1.14 2007/07/20 10:24:47 tat Exp $ 00009 */ 00010 00011 #ifndef _KLONE_IO_PRV_H_ 00012 #define _KLONE_IO_PRV_H_ 00013 00014 #include "klone_conf.h" 00015 #ifdef HAVE_STDINT 00016 #include <stdint.h> 00017 #endif /* HAVE_STDINT */ 00018 #include <klone/codec.h> 00019 #include <klone/utils.h> 00020 00021 #ifdef __cplusplus 00022 extern "C" { 00023 #endif 00024 00025 /* functions used by io devices */ 00026 00028 #define io_create(type, pio) io_prv_create(sizeof(type), pio) 00029 int io_prv_create(size_t dev_sz, io_t **pio); 00030 00031 typedef ssize_t (*io_read_op) (io_t*, char*, size_t); 00032 typedef ssize_t (*io_write_op) (io_t*, const char*, size_t); 00033 typedef ssize_t (*io_seek_op) (io_t*, size_t); 00034 typedef ssize_t (*io_tell_op) (io_t*); 00035 typedef int (*io_close_op) (io_t*); 00036 typedef int (*io_free_op) (io_t*); 00037 00038 struct io_s 00039 { 00040 char *name; 00041 codec_chain_t codec_chain; 00042 int eof; 00043 int type; 00044 size_t size; 00045 00046 /* reference count (used by dup'd io_t) */ 00047 unsigned int refcnt; 00048 00049 /* !0 for encrypted connections */ 00050 int is_secure; 00051 00052 /* io ops */ 00053 io_read_op read; 00054 io_write_op write; 00055 io_seek_op seek; 00056 io_tell_op tell; 00057 io_close_op close; 00058 io_free_op free; 00059 00060 /* input buffer */ 00061 00062 char *rbuf; /* read buffer */ 00063 size_t rbsz; /* read buffer size */ 00064 size_t rcount; /* available bytes in the buffer */ 00065 size_t roff; /* offset of the first byte to return */ 00066 00067 /* underflow buffer */ 00068 char *ubuf; /* underflow buffer */ 00069 size_t ucount; /* available bytes in the ubuffer */ 00070 size_t uoff; /* offset of the first byte to return */ 00071 00072 00073 /* output buffer */ 00074 00075 char *wbuf; /* write buffer */ 00076 size_t wbsz; /* write buffer size */ 00077 size_t wcount; /* # of non-empty bytes in the buffer */ 00078 size_t woff; /* offset of the head of the buffer */ 00079 00080 }; 00081 00082 #ifdef __cplusplus 00083 } 00084 #endif 00085 00086 #endif