libcmime  
A lightweight C mime library
cmime_header.h
Go to the documentation of this file.
1 /* libcmime - A C mime library
2  * Copyright (C) 2013 SpaceNet AG and Axel Steiner <ast@treibsand.com>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sublicense, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 
29 #ifndef _CMIME_HEADER_H
30 #define _CMIME_HEADER_H
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #include <assert.h>
40 
45 typedef struct {
46  char *name;
47  char **value;
48  size_t count;
49  int parsed;
51 
52 
59 
65 void cmime_header_free(CMimeHeader_T *header);
66 
73 void cmime_header_set_name(CMimeHeader_T *header, const char *name);
74 
79 #define cmime_header_get_name(header) (header->name)
80 
81 
89 void cmime_header_set_value(CMimeHeader_T *header, const char *value, int overwrite);
90 
98 char *cmime_header_get_value(CMimeHeader_T *header,int pos);
99 
104 #define cmime_header_get_count(header) ((int)header->count)
105 
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 #endif /* _CMIME_HEADER_H */
int parsed
Definition: cmime_header.h:49
char * cmime_header_get_value(CMimeHeader_T *header, int pos)
Return header value (at given position, if header appears more than once)
Definition: cmime_header.c:88
char * name
Definition: cmime_header.h:46
void cmime_header_set_name(CMimeHeader_T *header, const char *name)
Set a header name, if aleready exists, name will be overwritten.
Definition: cmime_header.c:55
void cmime_header_set_value(CMimeHeader_T *header, const char *value, int overwrite)
Set/append a header value.
Definition: cmime_header.c:65
char ** value
Definition: cmime_header.h:47
CMimeHeader_T * cmime_header_new(void)
Creates a new CMimeHeader_T object.
Definition: cmime_header.c:29
char * cmime_header_to_string(CMimeHeader_T *header)
Return full header as newly allocated string.
Definition: cmime_header.c:98
size_t count
Definition: cmime_header.h:48
void cmime_header_free(CMimeHeader_T *header)
Free a CMimeHeader_T object.
Definition: cmime_header.c:38
A email header item.
Definition: cmime_header.h:45