#include "common.h"
#include "header.h"
#include "glib-missing.h"
#include "misc.h"
#include "walloc.h"
#include "getline.h"
#include "override.h"
Data Structures | |
struct | header_fmt |
Header formatting context. More... | |
Defines | |
#define | HEAD_F_EOH 0x00000001 /**< EOH reached */ |
EOH reached. | |
#define | HEAD_F_SKIP 0x00000002 /**< Skip continuations */ |
Skip continuations. | |
#define | HEADER_FMT_MAGIC 0xf7a91c |
#define | HEADER_FMT_DFLT_LEN 256 /**< Default field length if no hint */ |
Default field length if no hint. | |
#define | HEADER_FMT_LINE_LEN 78 /**< Try to never emit longer lines */ |
Try to never emit longer lines. | |
#define | HEADER_FMT_MAX_SIZE 1024 /**< Max line size for header */ |
Max line size for header. | |
Functions | |
RCSID ("$Id:header.c, v 1.10 2005/11/09 19:16:53 cbiere Exp $") | |
const gchar * | header_strerror (guint errnum) |
void | normalize (gchar *field) |
In-place normalize the header field name: all letters starting a word are upper-cased, the others are lowercased. | |
header_field_t * | hfield_make (const gchar *name) |
Create a new empty header field, whose normalized name is `name'. | |
void | hfield_free (header_field_t *h) |
hfield_free | |
void | hfield_append (header_field_t *h, const gchar *text) |
Append line of text to given header field. | |
void | hfield_dump (const header_field_t *h, FILE *out) |
Dump field on specified file descriptor. | |
header_t * | header_make (void) |
Create a new header object. | |
gboolean | free_header_data (gpointer key, gpointer value, gpointer unused_udata) |
htable callback | |
void | header_free (header_t *o) |
Destroy header object. | |
void | header_reset (header_t *o) |
Reset header object, for new header parsing. | |
gchar * | header_get (const header_t *o, const gchar *field) |
Get field value, or NULL if not present. | |
gchar * | header_getdup (const header_t *o, const gchar *field) |
Get field value, or NULL if not present. | |
void | add_header (header_t *o, const gchar *field, const gchar *text) |
Add header line to the `headers' hash for specified field name. | |
void | add_continuation (header_t *o, const gchar *field, const gchar *text) |
Add continuation line to the `headers' hash for specified field name. | |
gint | header_append (header_t *o, const gchar *text, gint len) |
Append a new line of text at the end of the header. | |
void | header_dump (const header_t *o, FILE *out) |
Dump whole header on specified file. | |
gint | stripped_strlen (const gchar *s, gint len) |
Compute the length of the string `s' whose length is `len' with trailing whitespace ignored. | |
gpointer | header_fmt_make (const gchar *field, const gchar *separator, gint len_hint) |
Create a new formatting context for a header line. | |
void | header_fmt_set_line_length (gpointer o, gint maxlen) |
Set max line length. | |
void | header_fmt_free (gpointer o) |
Dispose of header formatting context. | |
gboolean | header_fmt_value_fits (gpointer o, gint len, gint maxlen) |
Checks whether appending `len' bytes of data to the header would fit within the `maxlen' total header size requirement in case a continuation is emitted, and using the configured separator. | |
void | header_fmt_append_full (struct header_fmt *hf, const gchar *str, const gchar *separator, gint slen, gint sslen) |
Append data `str' to the header line, atomically. | |
void | header_fmt_append (gpointer o, const gchar *str, const gchar *separator) |
Append data `str' to the header line, atomically. | |
void | header_fmt_append_value (gpointer o, const gchar *str) |
Append data `str' to the header line, atomically. | |
gint | header_fmt_length (gpointer o) |
void | header_fmt_end (gpointer o) |
Terminate header, emitting the trailing "\r\n". | |
gchar * | header_fmt_string (gpointer o) |
gchar * | header_fmt_to_string (gpointer o) |
Convert current header to a string. | |
Variables | |
const char * | error_str [] |
|
EOH reached.
|
|
Skip continuations.
|
|
Default field length if no hint.
|
|
Try to never emit longer lines.
|
|
|
|
Max line size for header.
|
|
Add continuation line to the `headers' hash for specified field name. A private copy of the data is made. |
|
Add header line to the `headers' hash for specified field name. A private copy of the `field' name and of the `text' data is made. |
|
htable callback Frees the key/values from the headers hash. |
|
Append a new line of text at the end of the header. A private copy of the text is made.
|
|
Dump whole header on specified file.
|
|
Append data `str' to the header line, atomically. `separator' is an optional separator string that will be emitted BEFORE outputting the data, and only when nothing has been emitted already. Any trailing space will be stripped out of `separator' if emitting at the end of a line. It supersedes any separator configured at make time. To use the standard separator, use header_fmt_append_value(). |
|
Append data `str' to the header line, atomically.
|
|
Append data `str' to the header line, atomically. Values are separated using the string specified at make time, if any. If emitted before a continuation, the version with stripped trailing whitespaces is used. To supersede the default separator, use header_fmt_append(). |
|
Terminate header, emitting the trailing "\r\n". Further appending is forbidden. |
|
Dispose of header formatting context.
|
|
|
|
Create a new formatting context for a header line.
|
|
Set max line length.
|
|
|
|
Convert current header to a string.
|
|
Checks whether appending `len' bytes of data to the header would fit within the `maxlen' total header size requirement in case a continuation is emitted, and using the configured separator.
|
|
Destroy header object.
|
|
Get field value, or NULL if not present. The value returned is a pointer to the internals of the header structure, so it must not be kept around. The requested header field must be in normalized form since they are stored that way. |
|
Get field value, or NULL if not present. The value returned is a copy of the internal value, so it may be kept around, but must be freed by the caller. |
|
Create a new header object.
|
|
Reset header object, for new header parsing.
|
|
|
|
Append line of text to given header field. A private copy of the data is made. |
|
Dump field on specified file descriptor.
|
|
hfield_free Dispose of the header field. |
|
Create a new empty header field, whose normalized name is `name'. A private copy of `name' is done. |
|
In-place normalize the header field name: all letters starting a word are upper-cased, the others are lowercased.
|
|
|
|
Compute the length of the string `s' whose length is `len' with trailing whitespace ignored.
|
|
Initial value: { "OK", "Unexpected continuation line", "Malformed header line", "Invalid characters in field name", "End of header already reached", "Skipped continuation line", "Header too large", "Header has too many lines", "End of header", } |