Commit ff639efd ff639efd3ee44de0e4904c2d8bb7d0de31b932a1 by Sergey Poznyakoff

(mu_header_append,mu_header_prepend): New function

1 parent f532b7b3
......@@ -85,6 +85,10 @@ extern int mu_header_clear_modified (mu_header_t);
/* Set and get field values by field name. */
extern int mu_header_set_value (mu_header_t, const char *, const char *, int);
extern int mu_header_remove (mu_header_t, const char *, int);
extern int mu_header_append (mu_header_t header, const char *fn,
const char *fv);
extern int mu_header_prepend (mu_header_t header, const char *fn,
const char *fv);
extern int mu_header_insert (mu_header_t, const char *, const char *,
const char *, int, int);
......
......@@ -584,6 +584,48 @@ mu_header_remove (mu_header_t header, const char *fn, int n)
}
int
mu_header_append (mu_header_t header, const char *fn, const char *fv)
{
int status;
struct mu_hdrent *ent;
if (header == NULL || fn == NULL || fv == NULL)
return EINVAL;
status = mu_header_fill (header);
if (status)
return status;
ent = mu_hdrent_create (header, NULL, fn, strlen (fn), fv, strlen (fv));
if (!ent)
return ENOMEM;
mu_hdrent_append (header, ent);
HEADER_SET_MODIFIED (header);
return 0;
}
int
mu_header_prepend (mu_header_t header, const char *fn, const char *fv)
{
int status;
struct mu_hdrent *ent;
if (header == NULL || fn == NULL || fv == NULL)
return EINVAL;
status = mu_header_fill (header);
if (status)
return status;
ent = mu_hdrent_create (header, NULL, fn, strlen (fn), fv, strlen (fv));
if (!ent)
return ENOMEM;
mu_hdrent_prepend (header, ent);
HEADER_SET_MODIFIED (header);
return 0;
}
int
mu_header_insert (mu_header_t header,
const char *fn, const char *fv,
const char *ref, int n, int flags)
......@@ -1189,3 +1231,4 @@ mu_header_clear_modified (mu_header_t header)
return 0;
}
......