(mh_context_destroy,mh_context_merge): New functions.
Showing
1 changed file
with
39 additions
and
0 deletions
... | @@ -42,6 +42,45 @@ mh_context_create (char *name, int copy) | ... | @@ -42,6 +42,45 @@ mh_context_create (char *name, int copy) |
42 | return ctx; | 42 | return ctx; |
43 | } | 43 | } |
44 | 44 | ||
45 | void | ||
46 | mh_context_destroy (mh_context_t **pctx) | ||
47 | { | ||
48 | mh_context_t *ctx = *pctx; | ||
49 | |||
50 | free (ctx->name); | ||
51 | if (ctx->header) | ||
52 | mu_header_destroy (&ctx->header, mu_header_get_owner (ctx->header)); | ||
53 | free (ctx); | ||
54 | *pctx = NULL; | ||
55 | } | ||
56 | |||
57 | void | ||
58 | mh_context_merge (mh_context_t *dst, mh_context_t *src) | ||
59 | { | ||
60 | if (!dst->header) | ||
61 | { | ||
62 | dst->header = src->header; | ||
63 | src->header = NULL; | ||
64 | } | ||
65 | else | ||
66 | { | ||
67 | size_t i, count; | ||
68 | |||
69 | mu_header_get_field_count (src->header, &count); | ||
70 | for (i = 1; i <= count; i++) | ||
71 | { | ||
72 | char *name = NULL; | ||
73 | char *value = NULL; | ||
74 | |||
75 | mu_header_aget_field_name (src->header, i, &name); | ||
76 | mu_header_aget_field_value (src->header, i, &value); | ||
77 | mu_header_set_value (dst->header, name, value, 1); | ||
78 | free (name); | ||
79 | free (value); | ||
80 | } | ||
81 | } | ||
82 | } | ||
83 | |||
45 | int | 84 | int |
46 | mh_context_read (mh_context_t *ctx) | 85 | mh_context_read (mh_context_t *ctx) |
47 | { | 86 | { | ... | ... |
-
Please register or sign in to post a comment