00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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
00106
00107
00108 #define HEAD_MAX_LINES 128
00109 #define HEAD_MAX_SIZE 16384
00111
00112
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
00137
00138