(mu_header_append,mu_header_prepend): New function
Showing
2 changed files
with
47 additions
and
0 deletions
... | @@ -85,6 +85,10 @@ extern int mu_header_clear_modified (mu_header_t); | ... | @@ -85,6 +85,10 @@ extern int mu_header_clear_modified (mu_header_t); |
85 | /* Set and get field values by field name. */ | 85 | /* Set and get field values by field name. */ |
86 | extern int mu_header_set_value (mu_header_t, const char *, const char *, int); | 86 | extern int mu_header_set_value (mu_header_t, const char *, const char *, int); |
87 | extern int mu_header_remove (mu_header_t, const char *, int); | 87 | extern int mu_header_remove (mu_header_t, const char *, int); |
88 | extern int mu_header_append (mu_header_t header, const char *fn, | ||
89 | const char *fv); | ||
90 | extern int mu_header_prepend (mu_header_t header, const char *fn, | ||
91 | const char *fv); | ||
88 | extern int mu_header_insert (mu_header_t, const char *, const char *, | 92 | extern int mu_header_insert (mu_header_t, const char *, const char *, |
89 | const char *, int, int); | 93 | const char *, int, int); |
90 | 94 | ... | ... |
... | @@ -584,6 +584,48 @@ mu_header_remove (mu_header_t header, const char *fn, int n) | ... | @@ -584,6 +584,48 @@ mu_header_remove (mu_header_t header, const char *fn, int n) |
584 | } | 584 | } |
585 | 585 | ||
586 | int | 586 | int |
587 | mu_header_append (mu_header_t header, const char *fn, const char *fv) | ||
588 | { | ||
589 | int status; | ||
590 | struct mu_hdrent *ent; | ||
591 | |||
592 | if (header == NULL || fn == NULL || fv == NULL) | ||
593 | return EINVAL; | ||
594 | |||
595 | status = mu_header_fill (header); | ||
596 | if (status) | ||
597 | return status; | ||
598 | |||
599 | ent = mu_hdrent_create (header, NULL, fn, strlen (fn), fv, strlen (fv)); | ||
600 | if (!ent) | ||
601 | return ENOMEM; | ||
602 | mu_hdrent_append (header, ent); | ||
603 | HEADER_SET_MODIFIED (header); | ||
604 | return 0; | ||
605 | } | ||
606 | |||
607 | int | ||
608 | mu_header_prepend (mu_header_t header, const char *fn, const char *fv) | ||
609 | { | ||
610 | int status; | ||
611 | struct mu_hdrent *ent; | ||
612 | |||
613 | if (header == NULL || fn == NULL || fv == NULL) | ||
614 | return EINVAL; | ||
615 | |||
616 | status = mu_header_fill (header); | ||
617 | if (status) | ||
618 | return status; | ||
619 | |||
620 | ent = mu_hdrent_create (header, NULL, fn, strlen (fn), fv, strlen (fv)); | ||
621 | if (!ent) | ||
622 | return ENOMEM; | ||
623 | mu_hdrent_prepend (header, ent); | ||
624 | HEADER_SET_MODIFIED (header); | ||
625 | return 0; | ||
626 | } | ||
627 | |||
628 | int | ||
587 | mu_header_insert (mu_header_t header, | 629 | mu_header_insert (mu_header_t header, |
588 | const char *fn, const char *fv, | 630 | const char *fn, const char *fv, |
589 | const char *ref, int n, int flags) | 631 | const char *ref, int n, int flags) |
... | @@ -1189,3 +1231,4 @@ mu_header_clear_modified (mu_header_t header) | ... | @@ -1189,3 +1231,4 @@ mu_header_clear_modified (mu_header_t header) |
1189 | return 0; | 1231 | return 0; |
1190 | } | 1232 | } |
1191 | 1233 | ||
1234 | ... | ... |
-
Please register or sign in to post a comment