io.h

00001 /*
00002  * Copyright (c) 2005-2012 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: io.h,v 1.20 2008/07/05 16:41:07 tat Exp $
00009  */
00010 
00011 #ifndef _KLONE_IO_H_ 
00012 #define _KLONE_IO_H_
00013 
00014 #include "klone_conf.h"
00015 #include <sys/types.h>
00016 #include <stdio.h>
00017 #include <stdarg.h>
00018 #ifdef SSL_ON
00019 #include <openssl/ssl.h>
00020 #include <openssl/err.h>
00021 #endif
00022 #include <klone/codec.h>
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif 
00027 
00028 struct io_s;
00029 typedef struct io_s io_t;
00030 
00031 enum io_type_e
00032 {
00033     IO_TYPE_FD,
00034     IO_TYPE_MEM,
00035 #ifdef SSL_ON
00036     IO_TYPE_SSL
00037 #endif
00038 };
00039 
00040 enum io_fd_flags {
00041     IO_FD_NO_FLAGS,
00042     IO_FD_CLOSE /* close(2) fd on io_free           */
00043 };
00044 
00045 enum io_mem_flags {
00046     IO_MEM_NO_FLAGS,
00047     IO_MEM_FREE_BUF     /* free(3) io mem buf on io_free    */
00048 };
00049 
00050 int io_fd_create(int fd, int flags, io_t **pio);
00051 int io_mem_create(char *buf, size_t size, int flags, io_t **pio);
00052 #ifdef SSL_ON
00053 int io_ssl_create(int fd, int flags, int client_mode, 
00054         SSL_CTX *ssl_tx, io_t **pio);
00055 int io_ssl_get_SSL(io_t *io_ssl, SSL **pssl);
00056 #endif
00057 int io_fd_get_d(io_t *);
00058 char* io_mem_get_buf(io_t *);
00059 size_t io_mem_get_bufsz(io_t *io);
00060 
00061 enum io_type_e io_type(io_t *io);
00062 
00063 int io_close(io_t *io);
00064 int io_free(io_t *io);
00065 int io_dup(io_t *io, io_t **pio);
00066 int io_name_set(io_t *io, const char* name);
00067 int io_name_get(io_t *io, char* name, size_t sz);
00068 ssize_t io_read(io_t *io, char* buf, size_t size);
00069 ssize_t io_write(io_t *io, const char* buf, size_t size);
00070 ssize_t io_flush(io_t *io);
00071 ssize_t io_seek(io_t *io, size_t off);
00072 ssize_t io_tell(io_t *io);
00073 ssize_t io_copy(io_t *out, io_t *in, size_t size);
00074 ssize_t io_pipe(io_t *out, io_t *in);
00075 ssize_t io_gets(io_t *io, char *buf, size_t size);
00076 ssize_t io_get_until(io_t *io, char stop_at, char *buf, size_t size);
00077 ssize_t io_getc(io_t *io, char *c);
00078 ssize_t io_printf(io_t *io, const char* fmt, ...);
00079 ssize_t io_vprintf(io_t *io, const char *fmt, va_list ap);
00080 ssize_t io_putc(io_t *io, char c);
00081 int io_codec_add_head(io_t *io, codec_t* codec);
00082 int io_codec_add_tail(io_t *io, codec_t* codec);
00083 int io_codecs_remove(io_t *io);
00084 int io_is_secure(io_t *io);
00085 
00086 #ifdef __cplusplus
00087 }
00088 #endif 
00089 
00090 #endif

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