libcmime  
A lightweight C mime library
cmime_part.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_PART_H
30 #define _CMIME_PART_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 <sys/stat.h>
40 #include <assert.h>
41 #include <libgen.h>
42 #include <ctype.h>
43 #include <errno.h>
44 
45 #include "cmime_list.h"
46 
52 typedef struct {
54  char *content;
55  char *boundary;
57  char *postface;
58  short int last;
59 } CMimePart_T;
60 
67 
73 void cmime_part_free(CMimePart_T *part);
74 
81 void cmime_part_set_content_type(CMimePart_T *part, const char *s);
82 
90 
97 void cmime_part_set_content_disposition(CMimePart_T *part, const char *s);
98 
106 
113 void cmime_part_set_content_transfer_encoding(CMimePart_T *part, const char *s);
114 
122 
129 void cmime_part_set_content_id(CMimePart_T *part, const char *s);
130 
138 
145 void cmime_part_set_content(CMimePart_T *part, const char *s);
146 
151 #define cmime_part_get_content(part) (part->content);
152 
159 void cmime_part_set_postface(CMimePart_T *part, const char *s);
160 
165 #define cmime_part_get_postface(part) (part->postface);
166 
175 char *cmime_part_to_string(CMimePart_T *part, const char *nl);
176 
186 int cmime_part_from_file(CMimePart_T **part, char *filename, const char *nl);
187 
195 int cmime_part_to_file(CMimePart_T *part, char *filename);
196 
204 int cmime_part_from_string(CMimePart_T **part, const char *content);
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif /* _CMIME_PART_H */
void cmime_part_set_content(CMimePart_T *part, const char *s)
Set content for mime part.
Definition: cmime_part.c:158
char * boundary
Definition: cmime_part.h:55
char * cmime_part_to_string(CMimePart_T *part, const char *nl)
Return complete mime part as string, inclusive all mime headers.
Definition: cmime_part.c:168
CMimePart_T * cmime_part_new(void)
Creates a new CMimePart_T object.
Definition: cmime_part.c:68
int cmime_part_to_file(CMimePart_T *part, char *filename)
Create a file from CMimePart_T object.
Definition: cmime_part.c:338
char * cmime_part_get_content_type(CMimePart_T *part)
Return content type of mime part.
Definition: cmime_part.c:115
char * postface
Definition: cmime_part.h:57
int cmime_part_from_file(CMimePart_T **part, char *filename, const char *nl)
Create a CMimePart_T object from file.
Definition: cmime_part.c:221
char * cmime_part_get_content_id(CMimePart_T *part)
Return content id of mime part.
Definition: cmime_part.c:154
int cmime_part_from_string(CMimePart_T **part, const char *content)
Parse given string and create a new CMimePart_T object.
Definition: cmime_part.c:383
void cmime_part_set_postface(CMimePart_T *part, const char *s)
Set mime parts postface.
Definition: cmime_part.c:452
char * parent_boundary
Definition: cmime_part.h:56
short int last
Definition: cmime_part.h:58
A mime part.
Definition: cmime_part.h:52
void cmime_part_set_content_id(CMimePart_T *part, const char *s)
Set content id for mime part.
Definition: cmime_part.c:147
void cmime_part_set_content_type(CMimePart_T *part, const char *s)
Set the content type for a mime part.
Definition: cmime_part.c:108
void cmime_part_free(CMimePart_T *part)
Frees a CMimePart_T object.
Definition: cmime_part.c:87
CMimeList_T * headers
Definition: cmime_part.h:53
char * cmime_part_get_content_transfer_encoding(CMimePart_T *part)
Return content transfer encoding of mime part.
Definition: cmime_part.c:141
Double linked list implementation.
Definition: cmime_list.h:55
Defines functions and structs for double linked list.
char * cmime_part_get_content_disposition(CMimePart_T *part)
Return content disposition of mime part.
Definition: cmime_part.c:128
char * content
Definition: cmime_part.h:54
void cmime_part_set_content_disposition(CMimePart_T *part, const char *s)
Set content disposition for mime part.
Definition: cmime_part.c:121
void cmime_part_set_content_transfer_encoding(CMimePart_T *part, const char *s)
Set content transfer encoding for mime part.
Definition: cmime_part.c:134