Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

cobs.h

Go to the documentation of this file.
00001 /*
00002  * $Id: cobs.h,v 1.8 2005/08/16 12:42:13 rmanfredi Exp $
00003  *
00004  * Copyright (c) 2002-2003, Raphael Manfredi
00005  *
00006  *----------------------------------------------------------------------
00007  * This file is part of gtk-gnutella.
00008  *
00009  *  gtk-gnutella is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  gtk-gnutella is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with gtk-gnutella; if not, write to the Free Software
00021  *  Foundation, Inc.:
00022  *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *----------------------------------------------------------------------
00024  */
00025 
00036 #ifndef _cobs_h_
00037 #define _cobs_h_
00038 
00039 #include <glib.h>
00040 
00041 enum cobs_magic { COBS_MAGIC = 0xc0befU };
00042 
00047 typedef struct cobs_stream {
00048     enum cobs_magic magic;  
00049     gchar *outbuf;          
00050     gchar *end;             
00051     gchar *o;               
00052     gchar *cp;              
00053     guchar code;            
00054     guchar last_code;       
00055     gboolean saw_nul;       
00056     gboolean closed;        
00057 } cobs_stream_t;
00058 
00059 /*
00060  * Public interface.
00061  */
00062 
00063 struct iovec;
00064 
00065 gchar *cobs_encode(gchar *buf, size_t len, size_t *retlen);
00066 gchar *cobs_encodev(struct iovec *iov, gint iovcnt, size_t *retlen);
00067 gchar *cobs_decode(gchar *buf, size_t len, size_t *retlen, gboolean inplace);
00068 gboolean cobs_decode_into(
00069     const gchar *buf, size_t len, gchar *out, size_t outlen, size_t *retlen);
00070 
00071 gboolean cobs_is_valid(const gchar *buf, size_t len);
00072 
00073 void cobs_stream_init(cobs_stream_t *cs, gpointer data, size_t len);
00074 size_t cobs_stream_close(cobs_stream_t *cs, gboolean *saw_nul);
00075 gboolean cobs_stream_write(cobs_stream_t *cs, gpointer data, size_t len);
00076 void cobs_stream_invalidate(cobs_stream_t *cs);
00077 gboolean cobs_stream_is_valid(cobs_stream_t *cs);
00078 
00079 #endif  /* _cobs_h_ */
00080 
00081 /* vi: set ts=4 sw=4 cindent: */

Generated on Sun Feb 12 10:49:56 2006 for Gtk-Gnutella by doxygen 1.3.6