dc0c77376d293056f75f4088fc86052725305873
[lms] / lightmediascanner / src / lib / lightmediascanner_utils.h
1 /**
2  * Copyright (C) 2007 by INdT
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  * @author Gustavo Sverzut Barbieri <gustavo.barbieri@openbossa.org>
19  */
20
21 #ifndef _LIGHTMEDIASCANNER_UTILS_H_
22 #define _LIGHTMEDIASCANNER_UTILS_H_ 1
23
24 #ifdef API
25 #undef API
26 #endif
27
28 #ifdef __GNUC__
29 # if __GNUC__ >= 4
30 #  define API __attribute__ ((visibility("default")))
31 # else
32 #  define API
33 # endif
34 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
35 #  define GNUC_NON_NULL(...) __attribute__((nonnull(__VA_ARGS__)))
36 # else
37 #  define GNUC_NON_NULL(...)
38 # endif
39 #else
40 #  define API
41 #  define GNUC_NON_NULL(...)
42 #endif
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48
49     struct lms_string_size {
50         char *str;
51         unsigned int len;
52     };
53
54 #define LMS_STATIC_STRING_SIZE(s)  {s, sizeof(s) - 1}
55 #define LMS_ARRAY_SIZE(a)  (sizeof(a) / sizeof(*a))
56
57
58     API void lms_strstrip(char *str, unsigned int *p_len) GNUC_NON_NULL(1, 2);
59     API void lms_strstrip_and_free(char **p_str, unsigned int *p_len) GNUC_NON_NULL(1, 2);
60     API void lms_string_size_strip_and_free(struct lms_string_size *p) GNUC_NON_NULL(1);
61     API int lms_which_extension(const char *name, unsigned int name_len, const struct lms_string_size *exts, unsigned int exts_len) GNUC_NON_NULL(1, 3);
62
63
64
65 #ifdef __cplusplus
66 }
67 #endif
68 #endif /* _LIGHTMEDIASCANNER_UTILS_H_ */