#include "common.h"
#include "header.h"
#include "glib-missing.h"
#include "misc.h"
#include "walloc.h"
#include "getline.h"
#include "slist.h"
#include "override.h"
Data Structures | |
| struct | header |
| struct | header_field_t |
| A header field. More... | |
| struct | header_fmt |
| Header formatting context. More... | |
Defines | |
| #define | HEADER_FMT_MAGIC 0xf7a91c |
| #define | HEADER_FMT_DFLT_LEN 256 |
| Default field length if no hint. | |
| #define | HEADER_FMT_LINE_LEN 78 |
| Try to never emit longer lines. | |
| #define | HEADER_FMT_MAX_SIZE 1024 |
| Max line size for header. | |
Enumerations | |
| enum | { HEAD_F_EOH = 0x00000001, HEAD_F_SKIP = 0x00000002 } |
Functions | |
| const gchar * | header_strerror (guint errnum) |
| gint | header_num_lines (const header_t *h) |
| header_field_t * | hfield_make (const gchar *name) |
| Create a new empty header field, whose name is `name'. | |
| void | hfield_free_item (gpointer p, gpointer unused_data) |
| void | hfield_free (header_field_t *h) |
| Dispose of the header field. | |
| 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. | |
| GHashTable * | header_get_table (header_t *o) |
| header_t * | header_make (void) |
| Create a new header object. | |
| gboolean | free_header_data (gpointer key, gpointer value, gpointer unused_udata) |
| Frees the key/values from the headers hash. | |
| void | header_free (header_t *o) |
| Destroy header object. | |
| void | header_reset_item (gpointer p, gpointer unused_data) |
| 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_item (gpointer p, gpointer user_data) |
| 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 [] |
|
|
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. |
|
||||||||||||||||
|
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. |
|
|
|
|
||||||||||||
|
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.
|
|
|
Dispose of the header field.
|
|
||||||||||||
|
|
|
|
Create a new empty header field, whose name is `name'. A private copy of `name' is done. |
|
||||||||||||
|
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",
}
|
1.3.9.1