libcmime  
A lightweight C mime library
cmime_util.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 
30 #ifndef _CMIME_UTIL_H
31 #define _CMIME_UTIL_H
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <string.h>
40 #include <assert.h>
41 #include <errno.h>
42 #include <time.h>
43 #include <unistd.h>
44 
49 typedef struct {
50  char *mime_type;
51  char *mime_encoding;
52  char *combined;
53 } CMimeInfo_T;
54 
61 char *cmime_util_get_mimetype(const char *filename);
62 
69 
76 
84 
91 CMimeInfo_T *cmime_util_info_get_from_file(const char *filename);
92 
98 int cmime_util_rand();
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* _CMIME_UTIL_H */
CMimeInfo_T * cmime_util_info_get_from_file(const char *filename)
Get mime type and encoding from file.
Definition: cmime_util.c:165
char * mime_encoding
Definition: cmime_util.h:51
char * cmime_util_get_mimetype(const char *filename)
Get mimetype of file use the &#39;file&#39; tool.
Definition: cmime_util.c:54
CMimeInfo_T * cmime_util_info_new(void)
Creates a new CMimeInfo_T object.
Definition: cmime_util.c:88
CMimeInfo_T * cmime_util_info_get_from_string(const char *s)
Get mime type and encoding from given string.
Definition: cmime_util.c:112
Struct with mime informations.
Definition: cmime_util.h:49
int cmime_util_rand()
Generate a random number from 0 to RAND_MAX.
Definition: cmime_util.c:180
void cmime_util_info_free(CMimeInfo_T *mi)
free a CMimeInfo_T object
Definition: cmime_util.c:97
char * mime_type
Definition: cmime_util.h:50
char * combined
Definition: cmime_util.h:52