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

header.h

Go to the documentation of this file.
00001 /*
00002  * $Id: header.h,v 1.5 2005/11/09 19:16:53 cbiere Exp $
00003  *
00004  * Copyright (c) 2001-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 _header_h_
00037 #define _header_h_
00038 
00039 #include <stdio.h>
00040 #include <glib.h>
00041 
00055 typedef struct header {
00056     GHashTable *headers;        
00057     GSList *fields;             
00058     gint flags;                 
00059     gint size;                  
00060     gint lines;                 
00061 } header_t;
00062 
00063 #define HEADER_SIZE(h)      ((h)->size)
00064 #define HEADER_LINES(h)     ((h)->lines)
00065 
00085 typedef struct {
00086     gchar *name;                
00087     GSList *lines;              
00088 } header_field_t;
00089 
00090 /*
00091  * Error codes.
00092  */
00093 
00094 #define HEAD_OK             0       
00095 #define HEAD_CONTINUATION   1       
00096 #define HEAD_MALFORMED      2       
00097 #define HEAD_BAD_CHARS      3       
00098 #define HEAD_EOH_REACHED    4       
00099 #define HEAD_SKIPPED        5       
00100 #define HEAD_TOO_LARGE      6       
00101 #define HEAD_MANY_LINES     7       
00102 #define HEAD_EOH            8       
00104 /*
00105  * Our sanity limits
00106  */
00107 
00108 #define HEAD_MAX_LINES      128     
00109 #define HEAD_MAX_SIZE       16384   
00111 /*
00112  * Public interface.
00113  */
00114 
00115 header_t *header_make(void);
00116 void header_free(header_t *o);
00117 void header_reset(header_t *o);
00118 gint header_append(header_t *o, const gchar *text, gint len);
00119 void header_dump(const header_t *o, FILE *out);
00120 const gchar *header_strerror(guint errnum);
00121 gchar *header_get(const header_t *o, const gchar *field);
00122 gchar *header_getdup(const header_t *o, const gchar *field);
00123 
00124 gpointer header_fmt_make(const gchar *field, const gchar *separator,
00125     gint len_hint);
00126 void header_fmt_free(gpointer o);
00127 void header_fmt_set_line_length(gpointer o, gint maxlen);
00128 gboolean header_fmt_value_fits(gpointer o, gint len, gint maxlen);
00129 void header_fmt_append(gpointer o, const gchar *str, const gchar *separator);
00130 void header_fmt_append_value(gpointer o, const gchar *str);
00131 gint header_fmt_length(gpointer o);
00132 void header_fmt_end(gpointer o);
00133 gchar *header_fmt_string(gpointer o);
00134 gchar *header_fmt_to_string(gpointer o);
00135 
00136 #endif  /* _header_h_ */
00137 
00138 /* vi: set ts=4 sw=4 cindent: */

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