- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,152 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2005 iptelorg GmbH |
|
3 |
- * |
|
4 |
- * This file is part of ser, a free SIP server. |
|
5 |
- * |
|
6 |
- * ser is free software; you can redistribute it and/or modify |
|
7 |
- * it under the terms of the GNU General Public License as published by |
|
8 |
- * the Free Software Foundation; either version 2 of the License, or |
|
9 |
- * (at your option) any later version |
|
10 |
- * |
|
11 |
- * For a license to use the ser software under conditions |
|
12 |
- * other than those described here, or to purchase support for this |
|
13 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
14 |
- * info@iptel.org |
|
15 |
- * |
|
16 |
- * ser is distributed in the hope that it will be useful, |
|
17 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
- * GNU General Public License for more details. |
|
20 |
- * |
|
21 |
- * You should have received a copy of the GNU General Public License |
|
22 |
- * along with this program; if not, write to the Free Software |
|
23 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
24 |
- */ |
|
25 |
- |
|
26 |
-#ifndef __SIMPLE_STR_H |
|
27 |
-#define __SIMPLE_STR_H |
|
28 |
- |
|
29 |
-#include <cds/memory.h> |
|
30 |
- |
|
31 |
-#ifdef __cplusplus |
|
32 |
-extern "C" { |
|
33 |
-#endif |
|
34 |
- |
|
35 |
-/* If compiled for SER, use ser internal strings ! */ |
|
36 |
-#ifdef SER |
|
37 |
- |
|
38 |
-#include "str.h" |
|
39 |
-typedef str str_t; |
|
40 |
- |
|
41 |
-#else |
|
42 |
- |
|
43 |
-typedef struct { |
|
44 |
- char *s; |
|
45 |
- int len; |
|
46 |
-} str_t; |
|
47 |
- |
|
48 |
-#define STR_STATIC_INIT(v) {(v), sizeof(v) - 1} |
|
49 |
- |
|
50 |
-#endif |
|
51 |
- |
|
52 |
-#define FMT_STR(str) (str).len,((str).s ? (str).s : "") |
|
53 |
- |
|
54 |
-#define str_len(ptr) ((ptr)?(ptr)->len:0) |
|
55 |
- |
|
56 |
-/** transalate zero-terminated string to str_t (both uses the input buffer!)*/ |
|
57 |
-str_t zt2str(char *str); |
|
58 |
- |
|
59 |
-/** returns 1 if the string is empty */ |
|
60 |
-int is_str_empty(const str_t *s); |
|
61 |
- |
|
62 |
-/** duplicate string into given destination (data region is newly allocated) */ |
|
63 |
-int str_dup_impl(str_t* dst, const str_t* src); |
|
64 |
-int str_dup_dbg(str_t* dst, const str_t* src, const char *file, int line); |
|
65 |
-/*#define str_dup(dst,src) str_dup_dbg(dst,src,__FILE__,__LINE__)*/ |
|
66 |
-#define str_dup(dst,src) str_dup_impl(dst,src) |
|
67 |
- |
|
68 |
- |
|
69 |
-/** duplicate string into newly allocated destination (data and str structure are newly allocated) */ |
|
70 |
-str_t *str_dup_new(const str_t* src); |
|
71 |
- |
|
72 |
-/** duplicate zero-terminated string */ |
|
73 |
-int str_dup_zt(str_t* dst, const char* src); |
|
74 |
- |
|
75 |
-/** duplicate zero-terminated string to zero-terminated string */ |
|
76 |
-char *zt_strdup(const char*src); |
|
77 |
- |
|
78 |
-/** frees string content if allocated */ |
|
79 |
-/* void str_free_content(str_t *s); */ |
|
80 |
-#define str_free_content(str) do { if (str != NULL) { \ |
|
81 |
- if (((str)->len > 0) && ((str)->s)) cds_free((str)->s);\ |
|
82 |
- (str)->len = 0; \ |
|
83 |
- (str)->s = 0; \ |
|
84 |
- } } while (0) |
|
85 |
- |
|
86 |
-/** frees string content if allocated and then the string itself */ |
|
87 |
-/* void str_free(str_t *s); */ |
|
88 |
-#define str_free(str) do { if (str != NULL) { \ |
|
89 |
- if (((str)->len > 0) && ((str)->s)) cds_free((str)->s);\ |
|
90 |
- cds_free(str); \ |
|
91 |
- } } while (0) |
|
92 |
- |
|
93 |
-/* clears string content */ |
|
94 |
-#define str_clear(str) do { if (str != NULL) { \ |
|
95 |
- (str)->len = 0; \ |
|
96 |
- (str)->s = 0; \ |
|
97 |
- } } while (0) |
|
98 |
- |
|
99 |
- |
|
100 |
-/** case sensitive comparation - returns 0 if equal, nonzero otherwise */ |
|
101 |
-int str_case_equals(const str_t *a, const str_t *b); |
|
102 |
-/** case insensitive comparation - returns 0 if equal, nonzero otherwise */ |
|
103 |
-int str_nocase_equals(const str_t *a, const str_t *b); |
|
104 |
- |
|
105 |
-/** compare str_t and zero terminated string */ |
|
106 |
-int str_cmp_zt(const str_t *a, const char *b); /* renamed sz_cmp */ |
|
107 |
- |
|
108 |
-/** is b prefix of a */ |
|
109 |
-int str_prefix(const str_t *a, const str_t *b); /* ss_start */ |
|
110 |
- |
|
111 |
-/* #define ss_cmp(const str_t *a, const str_t *b) ((a->len == b->len)?sz_cmp(a, b->s):(-1)) */ |
|
112 |
- |
|
113 |
-/* void str_clear(str_t *s); */ |
|
114 |
- |
|
115 |
-/** locate character in string */ |
|
116 |
-char *str_strchr(const str_t *s, char c); |
|
117 |
- |
|
118 |
-/** locate string in string */ |
|
119 |
-char *str_str(const str_t *s, const str_t *search_for); |
|
120 |
- |
|
121 |
-/* creates new string as concatenation of a and b */ |
|
122 |
-int str_concat(str_t *dst, str_t *a, str_t *b); |
|
123 |
- |
|
124 |
-int replace_str(const str_t *src, str_t *dst, const str_t *sample, const str_t *value); |
|
125 |
- |
|
126 |
-/** Copies string into another one. The destination string buffer |
|
127 |
- * MUST be allocated in needed size! */ |
|
128 |
-#define str_cpy(dst, src) do { \ |
|
129 |
- memcpy((dst)->s, (src)->s, (src)->len); \ |
|
130 |
- (dst)->len = (src)->len; \ |
|
131 |
- } while (0) |
|
132 |
- |
|
133 |
-/* pointer after given string - often used when strings |
|
134 |
- * allocated together with data structure holding them */ |
|
135 |
-#define after_str_ptr(ss) ((ss)->s + (ss)->len) |
|
136 |
- |
|
137 |
-/* |
|
138 |
- * Append a string app with length app_len |
|
139 |
- * to the end of string str which is a str* pointer |
|
140 |
- * the buffer must be large enough |
|
141 |
- */ |
|
142 |
-#define str_append(str, app, app_len) \ |
|
143 |
- do { \ |
|
144 |
- memcpy((str)->s + (str)->len, (app), (app_len)); \ |
|
145 |
- (str)->len += (app_len); \ |
|
146 |
- } while(0) |
|
147 |
- |
|
148 |
-#ifdef __cplusplus |
|
149 |
-} |
|
150 |
-#endif |
|
151 |
- |
|
152 |
-#endif |
... | ... |
@@ -20,7 +20,7 @@ |
20 | 20 |
* |
21 | 21 |
* You should have received a copy of the GNU General Public License |
22 | 22 |
* along with this program; if not, write to the Free Software |
23 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
23 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
24 | 24 |
*/ |
25 | 25 |
|
26 | 26 |
#ifndef __SIMPLE_STR_H |
... | ... |
@@ -77,7 +77,7 @@ char *zt_strdup(const char*src); |
77 | 77 |
|
78 | 78 |
/** frees string content if allocated */ |
79 | 79 |
/* void str_free_content(str_t *s); */ |
80 |
-#define str_free_content(str) do { if (str) { \ |
|
80 |
+#define str_free_content(str) do { if (str != NULL) { \ |
|
81 | 81 |
if (((str)->len > 0) && ((str)->s)) cds_free((str)->s);\ |
82 | 82 |
(str)->len = 0; \ |
83 | 83 |
(str)->s = 0; \ |
... | ... |
@@ -85,13 +85,13 @@ char *zt_strdup(const char*src); |
85 | 85 |
|
86 | 86 |
/** frees string content if allocated and then the string itself */ |
87 | 87 |
/* void str_free(str_t *s); */ |
88 |
-#define str_free(str) do { if (str) { \ |
|
88 |
+#define str_free(str) do { if (str != NULL) { \ |
|
89 | 89 |
if (((str)->len > 0) && ((str)->s)) cds_free((str)->s);\ |
90 | 90 |
cds_free(str); \ |
91 | 91 |
} } while (0) |
92 | 92 |
|
93 | 93 |
/* clears string content */ |
94 |
-#define str_clear(str) do { if (str) { \ |
|
94 |
+#define str_clear(str) do { if (str != NULL) { \ |
|
95 | 95 |
(str)->len = 0; \ |
96 | 96 |
(str)->s = 0; \ |
97 | 97 |
} } while (0) |
... | ... |
@@ -60,7 +60,11 @@ str_t zt2str(char *str); |
60 | 60 |
int is_str_empty(const str_t *s); |
61 | 61 |
|
62 | 62 |
/** duplicate string into given destination (data region is newly allocated) */ |
63 |
-int str_dup(str_t* dst, const str_t* src); |
|
63 |
+int str_dup_impl(str_t* dst, const str_t* src); |
|
64 |
+int str_dup_dbg(str_t* dst, const str_t* src, const char *file, int line); |
|
65 |
+/*#define str_dup(dst,src) str_dup_dbg(dst,src,__FILE__,__LINE__)*/ |
|
66 |
+#define str_dup(dst,src) str_dup_impl(dst,src) |
|
67 |
+ |
|
64 | 68 |
|
65 | 69 |
/** duplicate string into newly allocated destination (data and str structure are newly allocated) */ |
66 | 70 |
str_t *str_dup_new(const str_t* src); |
... | ... |
@@ -141,7 +145,6 @@ int replace_str(const str_t *src, str_t *dst, const str_t *sample, const str_t * |
141 | 145 |
(str)->len += (app_len); \ |
142 | 146 |
} while(0) |
143 | 147 |
|
144 |
- |
|
145 | 148 |
#ifdef __cplusplus |
146 | 149 |
} |
147 | 150 |
#endif |
... | ... |
@@ -59,10 +59,10 @@ str_t zt2str(char *str); |
59 | 59 |
/** returns 1 if the string is empty */ |
60 | 60 |
int is_str_empty(const str_t *s); |
61 | 61 |
|
62 |
-/** duplicate string into given destination */ |
|
62 |
+/** duplicate string into given destination (data region is newly allocated) */ |
|
63 | 63 |
int str_dup(str_t* dst, const str_t* src); |
64 | 64 |
|
65 |
-/** duplicate string into newly allocated destination */ |
|
65 |
+/** duplicate string into newly allocated destination (data and str structure are newly allocated) */ |
|
66 | 66 |
str_t *str_dup_new(const str_t* src); |
67 | 67 |
|
68 | 68 |
/** duplicate zero-terminated string */ |
... | ... |
@@ -119,6 +119,29 @@ int str_concat(str_t *dst, str_t *a, str_t *b); |
119 | 119 |
|
120 | 120 |
int replace_str(const str_t *src, str_t *dst, const str_t *sample, const str_t *value); |
121 | 121 |
|
122 |
+/** Copies string into another one. The destination string buffer |
|
123 |
+ * MUST be allocated in needed size! */ |
|
124 |
+#define str_cpy(dst, src) do { \ |
|
125 |
+ memcpy((dst)->s, (src)->s, (src)->len); \ |
|
126 |
+ (dst)->len = (src)->len; \ |
|
127 |
+ } while (0) |
|
128 |
+ |
|
129 |
+/* pointer after given string - often used when strings |
|
130 |
+ * allocated together with data structure holding them */ |
|
131 |
+#define after_str_ptr(ss) ((ss)->s + (ss)->len) |
|
132 |
+ |
|
133 |
+/* |
|
134 |
+ * Append a string app with length app_len |
|
135 |
+ * to the end of string str which is a str* pointer |
|
136 |
+ * the buffer must be large enough |
|
137 |
+ */ |
|
138 |
+#define str_append(str, app, app_len) \ |
|
139 |
+ do { \ |
|
140 |
+ memcpy((str)->s + (str)->len, (app), (app_len)); \ |
|
141 |
+ (str)->len += (app_len); \ |
|
142 |
+ } while(0) |
|
143 |
+ |
|
144 |
+ |
|
122 | 145 |
#ifdef __cplusplus |
123 | 146 |
} |
124 | 147 |
#endif |
... | ... |
@@ -73,18 +73,25 @@ char *zt_strdup(const char*src); |
73 | 73 |
|
74 | 74 |
/** frees string content if allocated */ |
75 | 75 |
/* void str_free_content(str_t *s); */ |
76 |
-#define str_free_content(str) if (str) { \ |
|
76 |
+#define str_free_content(str) do { if (str) { \ |
|
77 | 77 |
if (((str)->len > 0) && ((str)->s)) cds_free((str)->s);\ |
78 | 78 |
(str)->len = 0; \ |
79 | 79 |
(str)->s = 0; \ |
80 |
- } |
|
80 |
+ } } while (0) |
|
81 | 81 |
|
82 | 82 |
/** frees string content if allocated and then the string itself */ |
83 | 83 |
/* void str_free(str_t *s); */ |
84 |
-#define str_free(str) if (str) { \ |
|
85 |
- str_free_content(str); \ |
|
84 |
+#define str_free(str) do { if (str) { \ |
|
85 |
+ if (((str)->len > 0) && ((str)->s)) cds_free((str)->s);\ |
|
86 | 86 |
cds_free(str); \ |
87 |
- } |
|
87 |
+ } } while (0) |
|
88 |
+ |
|
89 |
+/* clears string content */ |
|
90 |
+#define str_clear(str) do { if (str) { \ |
|
91 |
+ (str)->len = 0; \ |
|
92 |
+ (str)->s = 0; \ |
|
93 |
+ } } while (0) |
|
94 |
+ |
|
88 | 95 |
|
89 | 96 |
/** case sensitive comparation - returns 0 if equal, nonzero otherwise */ |
90 | 97 |
int str_case_equals(const str_t *a, const str_t *b); |
... | ... |
@@ -99,7 +106,7 @@ int str_prefix(const str_t *a, const str_t *b); /* ss_start */ |
99 | 106 |
|
100 | 107 |
/* #define ss_cmp(const str_t *a, const str_t *b) ((a->len == b->len)?sz_cmp(a, b->s):(-1)) */ |
101 | 108 |
|
102 |
-void str_clear(str_t *s); |
|
109 |
+/* void str_clear(str_t *s); */ |
|
103 | 110 |
|
104 | 111 |
/** locate character in string */ |
105 | 112 |
char *str_strchr(const str_t *s, char c); |
... | ... |
@@ -108,6 +108,8 @@ char *str_str(const str_t *s, const str_t *search_for); |
108 | 108 |
/* creates new string as concatenation of a and b */ |
109 | 109 |
int str_concat(str_t *dst, str_t *a, str_t *b); |
110 | 110 |
|
111 |
+int replace_str(const str_t *src, str_t *dst, const str_t *sample, const str_t *value); |
|
112 |
+ |
|
111 | 113 |
#ifdef __cplusplus |
112 | 114 |
} |
113 | 115 |
#endif |
... | ... |
@@ -102,6 +102,9 @@ void str_clear(str_t *s); |
102 | 102 |
/** locate character in string */ |
103 | 103 |
char *str_strchr(const str_t *s, char c); |
104 | 104 |
|
105 |
+/** locate string in string */ |
|
106 |
+char *str_str(const str_t *s, const str_t *search_for); |
|
107 |
+ |
|
105 | 108 |
/* creates new string as concatenation of a and b */ |
106 | 109 |
int str_concat(str_t *dst, str_t *a, str_t *b); |
107 | 110 |
|
... | ... |
@@ -49,6 +49,8 @@ typedef struct { |
49 | 49 |
|
50 | 50 |
#define FMT_STR(str) (str).len,((str).s ? (str).s : "") |
51 | 51 |
|
52 |
+#define str_len(ptr) ((ptr)?(ptr)->len:0) |
|
53 |
+ |
|
52 | 54 |
/** transalate zero-terminated string to str_t (both uses the input buffer!)*/ |
53 | 55 |
str_t zt2str(char *str); |
54 | 56 |
|
... | ... |
@@ -100,6 +102,9 @@ void str_clear(str_t *s); |
100 | 102 |
/** locate character in string */ |
101 | 103 |
char *str_strchr(const str_t *s, char c); |
102 | 104 |
|
105 |
+/* creates new string as concatenation of a and b */ |
|
106 |
+int str_concat(str_t *dst, str_t *a, str_t *b); |
|
107 |
+ |
|
103 | 108 |
#ifdef __cplusplus |
104 | 109 |
} |
105 | 110 |
#endif |
... | ... |
@@ -26,6 +26,8 @@ |
26 | 26 |
#ifndef __SIMPLE_STR_H |
27 | 27 |
#define __SIMPLE_STR_H |
28 | 28 |
|
29 |
+#include <cds/memory.h> |
|
30 |
+ |
|
29 | 31 |
#ifdef __cplusplus |
30 | 32 |
extern "C" { |
31 | 33 |
#endif |
... | ... |
@@ -66,10 +68,19 @@ int str_dup_zt(str_t* dst, const char* src); |
66 | 68 |
char *zt_strdup(const char*src); |
67 | 69 |
|
68 | 70 |
/** frees string content if allocated */ |
69 |
-void str_free_content(str_t *s); |
|
71 |
+/* void str_free_content(str_t *s); */ |
|
72 |
+#define str_free_content(str) if (str) { \ |
|
73 |
+ if (((str)->len > 0) && ((str)->s)) cds_free((str)->s);\ |
|
74 |
+ (str)->len = 0; \ |
|
75 |
+ (str)->s = 0; \ |
|
76 |
+ } |
|
70 | 77 |
|
71 | 78 |
/** frees string content if allocated and then the string itself */ |
72 |
-void str_free(str_t *s); |
|
79 |
+/* void str_free(str_t *s); */ |
|
80 |
+#define str_free(str) if (str) { \ |
|
81 |
+ str_free_content(str); \ |
|
82 |
+ cds_free(str); \ |
|
83 |
+ } |
|
73 | 84 |
|
74 | 85 |
/** case sensitive comparation - returns 0 if equal, nonzero otherwise */ |
75 | 86 |
int str_case_equals(const str_t *a, const str_t *b); |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,93 @@ |
1 |
+/* |
|
2 |
+ * Copyright (C) 2005 iptelorg GmbH |
|
3 |
+ * |
|
4 |
+ * This file is part of ser, a free SIP server. |
|
5 |
+ * |
|
6 |
+ * ser is free software; you can redistribute it and/or modify |
|
7 |
+ * it under the terms of the GNU General Public License as published by |
|
8 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
9 |
+ * (at your option) any later version |
|
10 |
+ * |
|
11 |
+ * For a license to use the ser software under conditions |
|
12 |
+ * other than those described here, or to purchase support for this |
|
13 |
+ * software, please contact iptel.org by e-mail at the following addresses: |
|
14 |
+ * info@iptel.org |
|
15 |
+ * |
|
16 |
+ * ser is distributed in the hope that it will be useful, |
|
17 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
+ * GNU General Public License for more details. |
|
20 |
+ * |
|
21 |
+ * You should have received a copy of the GNU General Public License |
|
22 |
+ * along with this program; if not, write to the Free Software |
|
23 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
+ */ |
|
25 |
+ |
|
26 |
+#ifndef __SIMPLE_STR_H |
|
27 |
+#define __SIMPLE_STR_H |
|
28 |
+ |
|
29 |
+#ifdef __cplusplus |
|
30 |
+extern "C" { |
|
31 |
+#endif |
|
32 |
+ |
|
33 |
+/* If compiled for SER, use ser internal strings ! */ |
|
34 |
+#ifdef SER |
|
35 |
+ |
|
36 |
+#include "str.h" |
|
37 |
+typedef str str_t; |
|
38 |
+ |
|
39 |
+#else |
|
40 |
+ |
|
41 |
+typedef struct { |
|
42 |
+ char *s; |
|
43 |
+ int len; |
|
44 |
+} str_t; |
|
45 |
+ |
|
46 |
+#endif |
|
47 |
+ |
|
48 |
+#define FMT_STR(str) (str).len,((str).s ? (str).s : "") |
|
49 |
+ |
|
50 |
+/** transalate zero-terminated string to str_t (both uses the input buffer!)*/ |
|
51 |
+str_t zt2str(char *str); |
|
52 |
+ |
|
53 |
+/** returns 1 if the string is empty */ |
|
54 |
+int is_str_empty(const str_t *s); |
|
55 |
+ |
|
56 |
+/** duplicate string into given destination */ |
|
57 |
+int str_dup(str_t* dst, const str_t* src); |
|
58 |
+ |
|
59 |
+/** duplicate string into newly allocated destination */ |
|
60 |
+str_t *str_dup_new(const str_t* src); |
|
61 |
+ |
|
62 |
+/** duplicate zero-terminated string */ |
|
63 |
+int str_dup_zt(str_t* dst, const char* src); |
|
64 |
+ |
|
65 |
+/** duplicate zero-terminated string to zero-terminated string */ |
|
66 |
+char *zt_strdup(const char*src); |
|
67 |
+ |
|
68 |
+/** frees string content if allocated */ |
|
69 |
+void str_free_content(str_t *s); |
|
70 |
+ |
|
71 |
+/** frees string content if allocated and then the string itself */ |
|
72 |
+void str_free(str_t *s); |
|
73 |
+ |
|
74 |
+/** case sensitive comparation - returns 0 if equal, nonzero otherwise */ |
|
75 |
+int str_case_equals(const str_t *a, const str_t *b); |
|
76 |
+/** case insensitive comparation - returns 0 if equal, nonzero otherwise */ |
|
77 |
+int str_nocase_equals(const str_t *a, const str_t *b); |
|
78 |
+ |
|
79 |
+/** compare str_t and zero terminated string */ |
|
80 |
+int str_cmp_zt(const str_t *a, const char *b); /* renamed sz_cmp */ |
|
81 |
+ |
|
82 |
+/** is b prefix of a */ |
|
83 |
+int str_prefix(const str_t *a, const str_t *b); /* ss_start */ |
|
84 |
+ |
|
85 |
+/* #define ss_cmp(const str_t *a, const str_t *b) ((a->len == b->len)?sz_cmp(a, b->s):(-1)) */ |
|
86 |
+ |
|
87 |
+void str_clear(str_t *s); |
|
88 |
+ |
|
89 |
+#ifdef __cplusplus |
|
90 |
+} |
|
91 |
+#endif |
|
92 |
+ |
|
93 |
+#endif |