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

ggep.h

Go to the documentation of this file.
00001 /*
00002  * $Id: ggep.h,v 1.10 2005/08/16 04:15:22 cbiere 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 _core_ggep_h_
00037 #define _core_ggep_h_
00038 
00039 #include "extensions.h"
00040 #include "lib/cobs.h"
00041 #include "lib/zlib_util.h"
00042 
00043 #include <glib.h>
00044 
00045 #define GGEP_MAGIC      '\xc3'      
00047 /*
00048  * GGEP Extension Header Flags.
00049  */
00050 
00051 #define GGEP_F_LAST     0x80U       
00052 #define GGEP_F_COBS     0x40U       
00053 #define GGEP_F_DEFLATE  0x20U       
00054 #define GGEP_F_MBZ      0x10U       
00055 #define GGEP_F_IDLEN    0x0fU       
00057 /*
00058  * GGEP Length Encoding.
00059  */
00060 
00061 #define GGEP_L_CONT     '\x80'      
00062 #define GGEP_L_LAST     '\x40'      
00063 #define GGEP_L_VALUE    '\x3f'      
00064 #define GGEP_L_VSHIFT   6
00065 
00066 #define GGEP_L_XFLAGS   (GGEP_L_CONT | GGEP_L_LAST)
00067 
00068 /*
00069  * The "H" extension
00070  */
00071 
00072 #define GGEP_H_SHA1     0x01        
00073 #define GGEP_H_BITPRINT 0x02        
00074 #define GGEP_H_MD5      0x03        
00075 #define GGEP_H_UUID     0x04        
00076 #define GGEP_H_MD4      0x05        
00078 /*
00079  * Flags for ggep_ext_write() and friends.
00080  */
00081 
00082 #define GGEP_W_LAST     0x00000001  
00083 #define GGEP_W_COBS     0x00000002  
00084 #define GGEP_W_DEFLATE  0x00000004  
00085 #define GGEP_W_FIRST    0x00000008  
00087 enum ggep_magic { GGEP_MAGIC_ID = 0x62961da4U };
00088 
00092 typedef struct ggep_stream {
00093     enum ggep_magic magic;
00094     gchar *outbuf;          
00095     gchar *end;             
00096     gchar *o;               
00097     gchar *fp;              
00098     gchar *lp;              
00099     gchar *last_fp;         
00100     size_t size;            
00101     guint8 flags;           
00102     gboolean magic_emitted; 
00103     gboolean begun;         
00104     cobs_stream_t cs;       
00105     zlib_deflater_t *zd;    
00106 } ggep_stream_t;
00107 
00108 /*
00109  * Public interface.
00110  */
00111 
00112 struct iovec;
00113 
00114 gint ggep_decode_into(extvec_t *exv, gchar *buf, size_t len);
00115 
00116 void ggep_stream_init(ggep_stream_t *gs, gpointer data, size_t len);
00117 gboolean ggep_stream_begin(ggep_stream_t *gs, const char *id, guint32 wflags);
00118 gboolean ggep_stream_writev(ggep_stream_t *gs,
00119     const struct iovec *iov, gint iovcnt);
00120 gboolean ggep_stream_write(ggep_stream_t *gs, gconstpointer data, size_t len);
00121 gboolean ggep_stream_end(ggep_stream_t *gs);
00122 size_t ggep_stream_close(ggep_stream_t *gs);
00123 gboolean ggep_stream_packv(ggep_stream_t *gs,
00124     const gchar *id, const struct iovec *iov, gint iovcnt, guint32 wflags);
00125 gboolean ggep_stream_pack(ggep_stream_t *gs,
00126     const gchar *id, gconstpointer payload, size_t plen, guint32 wflags);
00127 
00128 gboolean ggep_stream_is_valid(ggep_stream_t *gs);
00129 
00130 #endif  /* _core_ggep_h_ */
00131 
00132 /* vi: set ts=4 sw=4 cindent: */
00133 

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