Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

ioprv.h

Go to the documentation of this file.
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.12 2006/05/12 09:02:58 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_term_op) (io_t*);
00036 
00037 struct io_s
00038 {
00039     char *name;
00040     codec_chain_t codec_chain; 
00041     int eof;
00042     size_t size;
00043 
00044     /* reference count (used by dup'd io_t) */
00045     unsigned int refcnt; 
00046 
00047     /* !0 for encrypted connections */
00048     int is_secure;
00049 
00050     /* io ops */
00051     io_read_op read;
00052     io_write_op write;
00053     io_seek_op seek;
00054     io_tell_op tell;
00055     io_term_op term;
00056 
00057     /* input buffer */
00058 
00059     char *rbuf;     /* read buffer                                            */
00060     size_t rbsz;    /* read buffer size                                       */
00061     size_t rcount;  /* available bytes in the buffer                          */
00062     size_t roff;    /* offset of the first byte to return                     */
00063 
00064     /* underflow buffer */
00065     char *ubuf;     /* underflow buffer                                       */
00066     size_t ucount;  /* available bytes in the ubuffer                         */
00067     size_t uoff;    /* offset of the first byte to return                     */
00068 
00069 
00070     /* output buffer */
00071 
00072     char *wbuf;     /* write buffer                                           */
00073     size_t wbsz;    /* write buffer size                                      */
00074     size_t wcount;  /* # of non-empty bytes in the buffer                     */
00075     size_t woff;    /* offset of the head of the buffer                       */
00076 
00077 };
00078 
00079 #ifdef __cplusplus
00080 }
00081 #endif 
00082 
00083 #endif

←Products
© 2005-2006 - KoanLogic S.r.l. - All rights reserved