- 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,133 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
3 |
- * |
|
4 |
- * This file is part of Kamailio, a free SIP server. |
|
5 |
- * |
|
6 |
- * Kamailio 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 |
- * Kamailio is distributed in the hope that it will be useful, |
|
12 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
- * GNU General Public License for more details. |
|
15 |
- * |
|
16 |
- * You should have received a copy of the GNU General Public License |
|
17 |
- * along with this program; if not, write to the Free Software |
|
18 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
- */ |
|
20 |
- |
|
21 |
-#ifndef str_h |
|
22 |
-#define str_h |
|
23 |
- |
|
24 |
-#include <string.h> |
|
25 |
- |
|
26 |
-/** @defgroup str_string Counted-Length Strings |
|
27 |
- * @{ |
|
28 |
- * |
|
29 |
- * Implementation of counted-length strings. In SER and its modules, strings |
|
30 |
- * are often stored in the ::str structure. In addition to the pointer |
|
31 |
- * pointing to the first character of the string, the structure also contains |
|
32 |
- * the length of the string. |
|
33 |
- * |
|
34 |
- * @section motivation Motivation |
|
35 |
- * Storing the length of the string together with the pointer to the string |
|
36 |
- * has two advantages. First, it makes many string operations faster because |
|
37 |
- * it is not necessary to count the number of characters at runtime. Second, |
|
38 |
- * the pointer can point to arbitrary substrings within a SIP message (which |
|
39 |
- * itself is stored as one long string spanning the whole message) without the |
|
40 |
- * need to make a zero-terminated copy of it. |
|
41 |
- * |
|
42 |
- * @section drawbacks Drawbacks |
|
43 |
- * Note well that the fact that string stored |
|
44 |
- * using this data structure are not zero terminated makes them a little |
|
45 |
- * incovenient to use with many standard libc string functions, because these |
|
46 |
- * usually expect the input to be zero-terminated. In this case you have to |
|
47 |
- * either make a zero-terminated copy or inject the terminating zero behind |
|
48 |
- * the actuall string (if possible). Note that injecting a zero terminating |
|
49 |
- * characters is considered to be dangerous. |
|
50 |
- */ |
|
51 |
- |
|
52 |
-/** @file |
|
53 |
- * This header field defines the ::str data structure that is used across |
|
54 |
- * SER sources to store counted-length strings. The file also defines several |
|
55 |
- * convenience macros. |
|
56 |
- */ |
|
57 |
- |
|
58 |
-/** Data structure used across SER sources to store counted-length strings. |
|
59 |
- * This is the data structure that is used to store counted-length |
|
60 |
- * strings in SER core and modules. |
|
61 |
- */ |
|
62 |
-struct _str{ |
|
63 |
- char* s; /**< Pointer to the first character of the string */ |
|
64 |
- int len; /**< Length of the string */ |
|
65 |
-}; |
|
66 |
- |
|
67 |
- |
|
68 |
-/** Data structure used across SER sources to store counted-length strings. |
|
69 |
- * @see _str |
|
70 |
- */ |
|
71 |
-typedef struct _str str; |
|
72 |
- |
|
73 |
-/** Initializes static ::str string with string literal. |
|
74 |
- * This is a convenience macro that can be used to initialize |
|
75 |
- * static ::str strings with string literals like this: |
|
76 |
- * \code static str var = STR_STATIC_INIT("some_string"); \endcode |
|
77 |
- * @param v is a string literal |
|
78 |
- * @sa STR_NULL |
|
79 |
- */ |
|
80 |
-#define STR_STATIC_INIT(v) {(v), sizeof(v) - 1} |
|
81 |
- |
|
82 |
-/* kamailio compatibility macro (same thing as above) */ |
|
83 |
-#define str_init(v) STR_STATIC_INIT(v) |
|
84 |
- |
|
85 |
-/** Initializes ::str string with NULL pointer and zero length. |
|
86 |
- * This is a convenience macro that can be used to initialize |
|
87 |
- * ::str string variable to NULL string with zero length: |
|
88 |
- * \code str var = STR_NULL; \endcode |
|
89 |
- * @sa STR_STATIC_INIT |
|
90 |
- */ |
|
91 |
-#define STR_NULL {0, 0} |
|
92 |
- |
|
93 |
-/** Formats ::str string for use in printf-like functions. |
|
94 |
- * This is a macro that prepares a ::str string for use in functions which |
|
95 |
- * use printf-like formatting strings. This macro is necessary because |
|
96 |
- * ::str strings do not have to be zero-terminated and thus it is necessary |
|
97 |
- * to provide printf-like functions with the number of characters in the |
|
98 |
- * string manually. Here is an example how to use the macro: |
|
99 |
- * \code printf("%.*s\n", STR_FMT(var));\endcode Note well that the correct |
|
100 |
- * sequence in the formatting string is %.*, see the man page of printf for |
|
101 |
- * more details. |
|
102 |
- */ |
|
103 |
-#define STR_FMT(_pstr_) \ |
|
104 |
- ((_pstr_ != (str *)0) ? (_pstr_)->len : 0), \ |
|
105 |
- ((_pstr_ != (str *)0) ? (_pstr_)->s : "") |
|
106 |
- |
|
107 |
- |
|
108 |
-/** Compares two ::str strings. |
|
109 |
- * This macro implements comparison of two strings represented using ::str |
|
110 |
- * structures. First it compares the lengths of both string and if and only |
|
111 |
- * if they are same then both strings are compared using memcmp. |
|
112 |
- * @param x is first string to be compared |
|
113 |
- * @param y is second string to be compared |
|
114 |
- * @return 1 if strings are same, 0 otherwise |
|
115 |
- */ |
|
116 |
-#define STR_EQ(x,y) (((x).len == (y).len) && \ |
|
117 |
- (memcmp((x).s, (y).s, (x).len) == 0)) |
|
118 |
- |
|
119 |
-/** @} */ |
|
120 |
- |
|
121 |
-/** Appends a sufffix |
|
122 |
- * @param orig is the original string |
|
123 |
- * @param suffix is the suffix string |
|
124 |
- * @param dest is the result ::str of appending suffix to orig |
|
125 |
- * @return 0 if ok -1 if error |
|
126 |
- * remember to free the dest->s private memory |
|
127 |
- */ |
|
128 |
-int str_append(str *orig, str *suffix, str *dest); |
|
129 |
- |
|
130 |
-char* _strnstr(const char *s, const char *find, size_t slen); |
|
131 |
-char* _strnistr(const char *s, const char *find, size_t slen); |
|
132 |
- |
|
133 |
-#endif |
- alternative to strnstr() which is not in all OSes, pluse the
insensitive option
... | ... |
@@ -21,6 +21,8 @@ |
21 | 21 |
#ifndef str_h |
22 | 22 |
#define str_h |
23 | 23 |
|
24 |
+#include <string.h> |
|
25 |
+ |
|
24 | 26 |
/** @defgroup str_string Counted-Length Strings |
25 | 27 |
* @{ |
26 | 28 |
* |
... | ... |
@@ -125,4 +127,7 @@ typedef struct _str str; |
125 | 127 |
*/ |
126 | 128 |
int str_append(str *orig, str *suffix, str *dest); |
127 | 129 |
|
130 |
+char* _strnstr(const char *s, const char *find, size_t slen); |
|
131 |
+char* _strnistr(const char *s, const char *find, size_t slen); |
|
132 |
+ |
|
128 | 133 |
#endif |
... | ... |
@@ -1,19 +1,14 @@ |
1 | 1 |
/* |
2 | 2 |
* Copyright (C) 2001-2003 FhG Fokus |
3 | 3 |
* |
4 |
- * This file is part of ser, a free SIP server. |
|
4 |
+ * This file is part of Kamailio, a free SIP server. |
|
5 | 5 |
* |
6 |
- * ser is free software; you can redistribute it and/or modify |
|
6 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
7 | 7 |
* it under the terms of the GNU General Public License as published by |
8 | 8 |
* the Free Software Foundation; either version 2 of the License, or |
9 | 9 |
* (at your option) any later version |
10 | 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, |
|
11 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
17 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | 14 |
* GNU General Public License for more details. |
... | ... |
@@ -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 str_h |
... | ... |
@@ -121,4 +121,13 @@ typedef struct _str str; |
121 | 121 |
|
122 | 122 |
/** @} */ |
123 | 123 |
|
124 |
+/** Appends a sufffix |
|
125 |
+ * @param orig is the original string |
|
126 |
+ * @param suffix is the suffix string |
|
127 |
+ * @param dest is the result ::str of appending suffix to orig |
|
128 |
+ * @return 0 if ok -1 if error |
|
129 |
+ * remember to free the dest->s private memory |
|
130 |
+ */ |
|
131 |
+int str_append(str *orig, str *suffix, str *dest); |
|
132 |
+ |
|
124 | 133 |
#endif |
... | ... |
@@ -1,6 +1,4 @@ |
1 | 1 |
/* |
2 |
- * $Id$ |
|
3 |
- * |
|
4 | 2 |
* Copyright (C) 2001-2003 FhG Fokus |
5 | 3 |
* |
6 | 4 |
* This file is part of ser, a free SIP server. |
... | ... |
@@ -70,7 +68,7 @@ struct _str{ |
70 | 68 |
}; |
71 | 69 |
|
72 | 70 |
|
73 |
-/** Data structure used across SER soruces to store counted-length strings. |
|
71 |
+/** Data structure used across SER sources to store counted-length strings. |
|
74 | 72 |
* @see _str |
75 | 73 |
*/ |
76 | 74 |
typedef struct _str str; |
Replace NULL with 0 (saves an extra #include).
... | ... |
@@ -93,7 +93,7 @@ typedef struct _str str; |
93 | 93 |
* \code str var = STR_NULL; \endcode |
94 | 94 |
* @sa STR_STATIC_INIT |
95 | 95 |
*/ |
96 |
-#define STR_NULL {NULL, 0} |
|
96 |
+#define STR_NULL {0, 0} |
|
97 | 97 |
|
98 | 98 |
/** Formats ::str string for use in printf-like functions. |
99 | 99 |
* This is a macro that prepares a ::str string for use in functions which |
... | ... |
@@ -84,6 +84,9 @@ typedef struct _str str; |
84 | 84 |
*/ |
85 | 85 |
#define STR_STATIC_INIT(v) {(v), sizeof(v) - 1} |
86 | 86 |
|
87 |
+/* kamailio compatibility macro (same thing as above) */ |
|
88 |
+#define str_init(v) STR_STATIC_INIT(v) |
|
89 |
+ |
|
87 | 90 |
/** Initializes ::str string with NULL pointer and zero length. |
88 | 91 |
* This is a convenience macro that can be used to initialize |
89 | 92 |
* ::str string variable to NULL string with zero length: |
... | ... |
@@ -103,7 +103,8 @@ typedef struct _str str; |
103 | 103 |
* more details. |
104 | 104 |
*/ |
105 | 105 |
#define STR_FMT(_pstr_) \ |
106 |
- ((_pstr_) ? (_pstr_)->len : 0), ((_pstr_) ? (_pstr_)->s : "") |
|
106 |
+ ((_pstr_ != (str *)0) ? (_pstr_)->len : 0), \ |
|
107 |
+ ((_pstr_ != (str *)0) ? (_pstr_)->s : "") |
|
107 | 108 |
|
108 | 109 |
|
109 | 110 |
/** Compares two ::str strings. |
... | ... |
@@ -25,22 +25,98 @@ |
25 | 25 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
26 | 26 |
*/ |
27 | 27 |
|
28 |
- |
|
29 | 28 |
#ifndef str_h |
30 | 29 |
#define str_h |
31 | 30 |
|
31 |
+/** @defgroup str_string Counted-Length Strings |
|
32 |
+ * @{ |
|
33 |
+ * |
|
34 |
+ * Implementation of counted-length strings. In SER and its modules, strings |
|
35 |
+ * are often stored in the ::str structure. In addition to the pointer |
|
36 |
+ * pointing to the first character of the string, the structure also contains |
|
37 |
+ * the length of the string. |
|
38 |
+ * |
|
39 |
+ * @section motivation Motivation |
|
40 |
+ * Storing the length of the string together with the pointer to the string |
|
41 |
+ * has two advantages. First, it makes many string operations faster because |
|
42 |
+ * it is not necessary to count the number of characters at runtime. Second, |
|
43 |
+ * the pointer can point to arbitrary substrings within a SIP message (which |
|
44 |
+ * itself is stored as one long string spanning the whole message) without the |
|
45 |
+ * need to make a zero-terminated copy of it. |
|
46 |
+ * |
|
47 |
+ * @section drawbacks Drawbacks |
|
48 |
+ * Note well that the fact that string stored |
|
49 |
+ * using this data structure are not zero terminated makes them a little |
|
50 |
+ * incovenient to use with many standard libc string functions, because these |
|
51 |
+ * usually expect the input to be zero-terminated. In this case you have to |
|
52 |
+ * either make a zero-terminated copy or inject the terminating zero behind |
|
53 |
+ * the actuall string (if possible). Note that injecting a zero terminating |
|
54 |
+ * characters is considered to be dangerous. |
|
55 |
+ */ |
|
56 |
+ |
|
57 |
+/** @file |
|
58 |
+ * This header field defines the ::str data structure that is used across |
|
59 |
+ * SER sources to store counted-length strings. The file also defines several |
|
60 |
+ * convenience macros. |
|
61 |
+ */ |
|
32 | 62 |
|
63 |
+/** Data structure used across SER sources to store counted-length strings. |
|
64 |
+ * This is the data structure that is used to store counted-length |
|
65 |
+ * strings in SER core and modules. |
|
66 |
+ */ |
|
33 | 67 |
struct _str{ |
34 |
- char* s; /*string*/ |
|
35 |
- int len; /*string len*/ |
|
68 |
+ char* s; /**< Pointer to the first character of the string */ |
|
69 |
+ int len; /**< Length of the string */ |
|
36 | 70 |
}; |
37 | 71 |
|
72 |
+ |
|
73 |
+/** Data structure used across SER soruces to store counted-length strings. |
|
74 |
+ * @see _str |
|
75 |
+ */ |
|
38 | 76 |
typedef struct _str str; |
39 | 77 |
|
78 |
+/** Initializes static ::str string with string literal. |
|
79 |
+ * This is a convenience macro that can be used to initialize |
|
80 |
+ * static ::str strings with string literals like this: |
|
81 |
+ * \code static str var = STR_STATIC_INIT("some_string"); \endcode |
|
82 |
+ * @param v is a string literal |
|
83 |
+ * @sa STR_NULL |
|
84 |
+ */ |
|
40 | 85 |
#define STR_STATIC_INIT(v) {(v), sizeof(v) - 1} |
86 |
+ |
|
87 |
+/** Initializes ::str string with NULL pointer and zero length. |
|
88 |
+ * This is a convenience macro that can be used to initialize |
|
89 |
+ * ::str string variable to NULL string with zero length: |
|
90 |
+ * \code str var = STR_NULL; \endcode |
|
91 |
+ * @sa STR_STATIC_INIT |
|
92 |
+ */ |
|
41 | 93 |
#define STR_NULL {NULL, 0} |
42 | 94 |
|
95 |
+/** Formats ::str string for use in printf-like functions. |
|
96 |
+ * This is a macro that prepares a ::str string for use in functions which |
|
97 |
+ * use printf-like formatting strings. This macro is necessary because |
|
98 |
+ * ::str strings do not have to be zero-terminated and thus it is necessary |
|
99 |
+ * to provide printf-like functions with the number of characters in the |
|
100 |
+ * string manually. Here is an example how to use the macro: |
|
101 |
+ * \code printf("%.*s\n", STR_FMT(var));\endcode Note well that the correct |
|
102 |
+ * sequence in the formatting string is %.*, see the man page of printf for |
|
103 |
+ * more details. |
|
104 |
+ */ |
|
43 | 105 |
#define STR_FMT(_pstr_) \ |
44 | 106 |
((_pstr_) ? (_pstr_)->len : 0), ((_pstr_) ? (_pstr_)->s : "") |
45 | 107 |
|
108 |
+ |
|
109 |
+/** Compares two ::str strings. |
|
110 |
+ * This macro implements comparison of two strings represented using ::str |
|
111 |
+ * structures. First it compares the lengths of both string and if and only |
|
112 |
+ * if they are same then both strings are compared using memcmp. |
|
113 |
+ * @param x is first string to be compared |
|
114 |
+ * @param y is second string to be compared |
|
115 |
+ * @return 1 if strings are same, 0 otherwise |
|
116 |
+ */ |
|
117 |
+#define STR_EQ(x,y) (((x).len == (y).len) && \ |
|
118 |
+ (memcmp((x).s, (y).s, (x).len) == 0)) |
|
119 |
+ |
|
120 |
+/** @} */ |
|
121 |
+ |
|
46 | 122 |
#endif |
Verified by: md5(1) (those modules, which actually compile)
... | ... |
@@ -1,7 +1,31 @@ |
1 | 1 |
/* |
2 | 2 |
* $Id$ |
3 |
+ * |
|
4 |
+ * Copyright (C) 2001-2003 Fhg Fokus |
|
5 |
+ * |
|
6 |
+ * This file is part of ser, a free SIP server. |
|
7 |
+ * |
|
8 |
+ * ser is free software; you can redistribute it and/or modify |
|
9 |
+ * it under the terms of the GNU General Public License as published by |
|
10 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
11 |
+ * (at your option) any later version |
|
12 |
+ * |
|
13 |
+ * For a license to use the ser software under conditions |
|
14 |
+ * other than those described here, or to purchase support for this |
|
15 |
+ * software, please contact iptel.org by e-mail at the following addresses: |
|
16 |
+ * info@iptel.org |
|
17 |
+ * |
|
18 |
+ * ser is distributed in the hope that it will be useful, |
|
19 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 |
+ * GNU General Public License for more details. |
|
22 |
+ * |
|
23 |
+ * You should have received a copy of the GNU General Public License |
|
24 |
+ * along with this program; if not, write to the Free Software |
|
25 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
3 | 26 |
*/ |
4 | 27 |
|
28 |
+ |
|
5 | 29 |
#ifndef str_h |
6 | 30 |
#define str_h |
7 | 31 |
|