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

extensions.h

Go to the documentation of this file.
00001 /*
00002  * $Id: extensions.h 13831 2007-06-16 01:22:39Z cbiere $
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_extensions_h_
00037 #define _core_extensions_h_
00038 
00039 #include "common.h"
00040 
00045 typedef enum ext_type {
00046     EXT_UNKNOWN = 0,    
00047     EXT_XML,            
00048     EXT_HUGE,           
00049     EXT_GGEP,           
00050     EXT_NONE,           
00052     EXT_TYPE_COUNT
00053 } ext_type_t;
00054 
00067 typedef enum ext_token {
00068     EXT_T_UNKNOWN = 0,      
00069     EXT_T_URN_BITPRINT,     
00070     EXT_T_URN_SHA1,         
00071     EXT_T_URN_EMPTY,        
00072     EXT_T_URN_BAD,          
00073     EXT_T_XML,              
00074     EXT_T_UNKNOWN_GGEP,     
00075     EXT_T_OVERHEAD,         
00076     EXT_T_GGEP_LIME_XML,    
00077     /* sort below */
00078     EXT_T_GGEP_A,           
00079     EXT_T_GGEP_ALT,         
00080     EXT_T_GGEP_ALT_TLS,     
00081     EXT_T_GGEP_BH,          
00082     EXT_T_GGEP_C,           
00083     EXT_T_GGEP_CT,          
00084     EXT_T_GGEP_DU,          
00085     EXT_T_GGEP_F,           
00086     EXT_T_GGEP_FW,          
00087     EXT_T_GGEP_GGEP,        
00088     EXT_T_GGEP_GTKG_IPV6,   
00089     EXT_T_GGEP_GTKG_TLS,    
00090     /* watch out, below is off-order */
00091     EXT_T_GGEP_GTKGV1,      
00092     EXT_T_GGEP_GUE,         
00093     EXT_T_GGEP_H,           
00094     EXT_T_GGEP_HNAME,       
00095     EXT_T_GGEP_IP,          
00096     EXT_T_GGEP_IPP,         
00097     EXT_T_GGEP_IPP_TLS,     
00098     EXT_T_GGEP_LF,          
00099     EXT_T_GGEP_LOC,         
00100     EXT_T_GGEP_NP,          
00101     EXT_T_GGEP_P,           
00102     EXT_T_GGEP_PATH,        
00103     EXT_T_GGEP_PHC,         
00104     EXT_T_GGEP_PUSH,        
00105     EXT_T_GGEP_PUSH_TLS,    
00106     EXT_T_GGEP_Q,           
00107     EXT_T_GGEP_SCP,         
00108     EXT_T_GGEP_SO,          
00109     EXT_T_GGEP_T,           
00110     EXT_T_GGEP_TLS,         
00111     EXT_T_GGEP_UA,          
00112     EXT_T_GGEP_UDPHC,       
00113     EXT_T_GGEP_UP,          
00114     EXT_T_GGEP_V,           
00115     EXT_T_GGEP_VC,          
00116     EXT_T_GGEP_VMSG,        
00117     EXT_T_GGEP_u,           
00119     EXT_T_TOKEN_COUNT
00120 } ext_token_t;
00121 
00122 #define GGEP_NAME(x) ext_ggep_name(EXT_T_GGEP_ ## x)
00123 #define GGEP_GTKG_NAME(x) ext_ggep_name(EXT_T_GGEP_GTKG_ ## x)
00124 
00147 typedef struct extvec {
00148     const gchar *ext_name;  
00149     ext_token_t ext_token;  
00150     ext_type_t ext_type;    
00151     gpointer opaque;        
00152 } extvec_t;
00153 
00154 #define MAX_EXTVEC      32  
00156 /*
00157  * Public interface.
00158  */
00159 
00160 void ext_init(void);
00161 void ext_close(void);
00162 
00163 void ext_prepare(extvec_t *exv, gint exvcnt);
00164 gint ext_parse(const gchar *buf, gint len, extvec_t *exv, gint exvcnt);
00165 void ext_reset(extvec_t *exv, gint exvcnt);
00166 
00167 gboolean ext_is_printable(const extvec_t *e);
00168 gboolean ext_is_ascii(const extvec_t *e);
00169 gboolean ext_has_ascii_word(const extvec_t *e);
00170 
00171 void ext_dump(FILE *fd, const extvec_t *extvec, gint extcnt,
00172     const gchar *prefix, const gchar *postfix, gboolean payload);
00173 
00174 gconstpointer ext_payload(const extvec_t *e);
00175 guint16 ext_paylen(const extvec_t *e);
00176 const gchar *ext_base(const extvec_t *e);
00177 guint16 ext_headlen(const extvec_t *e);
00178 guint16 ext_len(const extvec_t *e);
00179 const gchar *ext_ggep_id_str(const extvec_t *e);
00180 const gchar *ext_ggep_name(ext_token_t id);
00181 
00182 #endif  /* _core_extensions_h_ */
00183 
00184 /* vi: set ts=4 sw=4 cindent: */
00185 

Generated on Sat Jun 30 17:53:23 2007 for gtk-gnutella by  doxygen 1.3.9.1