Browse code

core, lib, modules: restructured source code tree

- 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)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
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
Browse code

core: _strnstr() and _strnistr() defined in core

- alternative to strnstr() which is not in all OSes, pluse the
insensitive option

Daniel-Constantin Mierla authored on 15/03/2016 11:37:37
Showing 1 changed files
... ...
@@ -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
Browse code

core: Modify doxygen, remove history, remove SVN IDs, change "ser" and "sip-router" to "KAMAILIO"

Olle E. Johansson authored on 16/01/2015 16:38:46
Showing 1 changed files
... ...
@@ -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.
Browse code

all: updated FSF address in GPL text

Anthony Messina authored on 04/07/2014 09:36:37 • Daniel-Constantin Mierla committed on 04/07/2014 09:37:36
Showing 1 changed files
... ...
@@ -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
Browse code

core: add str_append helper function

Victor Seva authored on 28/04/2014 14:20:57
Showing 1 changed files
... ...
@@ -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
Browse code

core: small spelling fix and cleanup in doxygen docs

Henning Westerholt authored on 05/07/2011 21:34:41
Showing 1 changed files
... ...
@@ -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;
Browse code

core: str.h - s/NULL/0/

Replace NULL with 0 (saves an extra #include).

Andrei Pelinescu-Onciul authored on 27/05/2010 18:00:25
Showing 1 changed files
... ...
@@ -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 
Browse code

str: kamailio str_init compatibility macro

Andrei Pelinescu-Onciul authored on 21/11/2008 00:03:51
Showing 1 changed files
... ...
@@ -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:
Browse code

Various warnings fixed (mostly appearing with 64b compiles).

Closes issue SER-343.

Bogdan Pintea authored on 31/03/2008 18:57:54
Showing 1 changed files
... ...
@@ -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.
Browse code

- added macro STR_EQ - doxygen documentation added

Jan Janak authored on 29/01/2008 08:14:27
Showing 1 changed files
... ...
@@ -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
Browse code

- str formatting macro by Bogdan Pintea closes SER-127

Jan Janak authored on 22/11/2006 18:13:40
Showing 1 changed files
... ...
@@ -40,4 +40,7 @@ typedef struct _str str;
40 40
 #define STR_STATIC_INIT(v) {(v), sizeof(v) - 1}
41 41
 #define STR_NULL {NULL, 0}
42 42
 
43
+#define STR_FMT(_pstr_)	\
44
+  ((_pstr_) ? (_pstr_)->len : 0), ((_pstr_) ? (_pstr_)->s : "")
45
+
43 46
 #endif
Browse code

Provide two useful macros for str initialization: STR_STATIC_INIT() and STR_NULL. Adjust all modules to use those macros where appropriate.

Verified by: md5(1) (those modules, which actually compile)

Maxim Sobolev authored on 17/11/2005 03:49:37
Showing 1 changed files
... ...
@@ -37,5 +37,7 @@ struct _str{
37 37
 
38 38
 typedef struct _str str;
39 39
 
40
+#define STR_STATIC_INIT(v) {(v), sizeof(v) - 1}
41
+#define STR_NULL {NULL, 0}
40 42
 
41 43
 #endif
Browse code

- Spelling checked - READMEs updated

Jan Janak authored on 24/08/2004 08:45:09
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * $Id$
3 3
  *
4
- * Copyright (C) 2001-2003 Fhg Fokus
4
+ * Copyright (C) 2001-2003 FhG Fokus
5 5
  *
6 6
  * This file is part of ser, a free SIP server.
7 7
  *
Browse code

- fixed comment

Andrei Pelinescu-Onciul authored on 11/05/2004 07:48:36
Showing 1 changed files
... ...
@@ -31,7 +31,7 @@
31 31
 
32 32
 
33 33
 struct _str{
34
-	char* s; /* null terminated string*/
34
+	char* s; /*string*/
35 35
 	int len; /*string len*/
36 36
 };
37 37
 
Browse code

GPLization banner introduced to *.[hc] files

Jiri Kuthan authored on 19/09/2002 12:23:52
Showing 1 changed files
... ...
@@ -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
 
Browse code

*** empty log message ***

Andrei Pelinescu-Onciul authored on 19/11/2001 12:44:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,17 @@
1
+/*
2
+ * $Id$
3
+ */
4
+
5
+#ifndef str_h
6
+#define str_h
7
+
8
+
9
+struct _str{
10
+	char* s; /* null terminated string*/
11
+	int len; /*string len*/
12
+};
13
+
14
+typedef struct _str str;
15
+
16
+
17
+#endif