- 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,149 +0,0 @@ |
1 |
-/* |
|
2 |
- * Expires header field body parser |
|
3 |
- * |
|
4 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
5 |
- * |
|
6 |
- * This file is part of Kamailio, a free SIP server. |
|
7 |
- * |
|
8 |
- * Kamailio 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 |
- * Kamailio is distributed in the hope that it will be useful, |
|
14 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
- * GNU General Public License for more details. |
|
17 |
- * |
|
18 |
- * You should have received a copy of the GNU General Public License |
|
19 |
- * along with this program; if not, write to the Free Software |
|
20 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
21 |
- * |
|
22 |
- */ |
|
23 |
- |
|
24 |
-/*! \file |
|
25 |
- * \brief Parser :: Expires header field body parser. |
|
26 |
- * |
|
27 |
- * |
|
28 |
- * \ingroup parser |
|
29 |
- */ |
|
30 |
- |
|
31 |
- |
|
32 |
- |
|
33 |
-#include "parse_expires.h" |
|
34 |
-#include <stdio.h> /* printf */ |
|
35 |
-#include "../mem/mem.h" /* pkg_malloc, pkg_free */ |
|
36 |
-#include "../dprint.h" |
|
37 |
-#include "../trim.h" /* trim_leading */ |
|
38 |
-#include <string.h> /* memset */ |
|
39 |
-#include "../ut.h" |
|
40 |
- |
|
41 |
- |
|
42 |
-static inline int expires_parser(char* _s, int _l, exp_body_t* _e) |
|
43 |
-{ |
|
44 |
- int i; |
|
45 |
- str tmp; |
|
46 |
- |
|
47 |
- tmp.s = _s; |
|
48 |
- tmp.len = _l; |
|
49 |
- |
|
50 |
- trim(&tmp); |
|
51 |
- |
|
52 |
- if (tmp.len == 0) { |
|
53 |
- LOG(L_ERR, "expires_parser(): Empty body\n"); |
|
54 |
- _e->valid = 0; |
|
55 |
- return -1; |
|
56 |
- } |
|
57 |
- |
|
58 |
- _e->text.s = tmp.s; |
|
59 |
- _e->text.len = tmp.len; |
|
60 |
- |
|
61 |
- /* more then 32bit/maxuint cant be valid */ |
|
62 |
- if (tmp.len > 10) { |
|
63 |
- _e->valid = 0; |
|
64 |
- return 0; |
|
65 |
- } |
|
66 |
- |
|
67 |
- for(i = 0; i < tmp.len; i++) { |
|
68 |
- if ((tmp.s[i] >= '0') && (tmp.s[i] <= '9')) { |
|
69 |
- _e->val *= 10; |
|
70 |
- _e->val += tmp.s[i] - '0'; |
|
71 |
- } else { |
|
72 |
- switch(tmp.s[i]) { |
|
73 |
- case ' ': |
|
74 |
- case '\t': |
|
75 |
- case '\r': |
|
76 |
- case '\n': |
|
77 |
- _e->text.len = i; |
|
78 |
- _e->valid = 1; |
|
79 |
- return 0; |
|
80 |
- |
|
81 |
- default: |
|
82 |
- /* Exit normally here, we want to be backwards compatible with |
|
83 |
- * RFC2543 entities that can put absolute time here |
|
84 |
- */ |
|
85 |
- /* |
|
86 |
- LOG(L_ERR, "expires_parser(): Invalid character\n"); |
|
87 |
- return -2; |
|
88 |
- */ |
|
89 |
- _e->valid = 0; |
|
90 |
- return 0; |
|
91 |
- } |
|
92 |
- } |
|
93 |
- } |
|
94 |
- |
|
95 |
- _e->valid = 1; |
|
96 |
- return 0; |
|
97 |
-} |
|
98 |
- |
|
99 |
- |
|
100 |
-/*! \brief |
|
101 |
- * Parse expires header field body |
|
102 |
- */ |
|
103 |
-int parse_expires(struct hdr_field* _h) |
|
104 |
-{ |
|
105 |
- exp_body_t* e; |
|
106 |
- |
|
107 |
- if (_h->parsed) { |
|
108 |
- return 0; /* Already parsed */ |
|
109 |
- } |
|
110 |
- |
|
111 |
- e = (exp_body_t*)pkg_malloc(sizeof(exp_body_t)); |
|
112 |
- if (e == 0) { |
|
113 |
- LOG(L_ERR, "parse_expires(): No memory left\n"); |
|
114 |
- return -1; |
|
115 |
- } |
|
116 |
- |
|
117 |
- memset(e, 0, sizeof(exp_body_t)); |
|
118 |
- |
|
119 |
- if (expires_parser(_h->body.s, _h->body.len, e) < 0) { |
|
120 |
- LOG(L_ERR, "parse_expires(): Error while parsing\n"); |
|
121 |
- pkg_free(e); |
|
122 |
- return -2; |
|
123 |
- } |
|
124 |
- |
|
125 |
- _h->parsed = (void*)e; |
|
126 |
- return 0; |
|
127 |
-} |
|
128 |
- |
|
129 |
- |
|
130 |
-/*! \brief |
|
131 |
- * Free all memory associated with exp_body_t |
|
132 |
- */ |
|
133 |
-void free_expires(exp_body_t** _e) |
|
134 |
-{ |
|
135 |
- pkg_free(*_e); |
|
136 |
- *_e = 0; |
|
137 |
-} |
|
138 |
- |
|
139 |
- |
|
140 |
-/*! \brief |
|
141 |
- * Print exp_body_t content, for debugging only |
|
142 |
- */ |
|
143 |
-void print_expires(exp_body_t* _e) |
|
144 |
-{ |
|
145 |
- printf("===Expires===\n"); |
|
146 |
- printf("text: \'%.*s\'\n", _e->text.len, ZSW(_e->text.s)); |
|
147 |
- printf("val : %d\n", _e->val); |
|
148 |
- printf("===/Expires===\n"); |
|
149 |
-} |
... | ... |
@@ -3,19 +3,14 @@ |
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2001-2003 FhG Fokus |
5 | 5 |
* |
6 |
- * This file is part of ser, a free SIP server. |
|
6 |
+ * This file is part of Kamailio, a free SIP server. |
|
7 | 7 |
* |
8 |
- * ser is free software; you can redistribute it and/or modify |
|
8 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
9 | 9 |
* it under the terms of the GNU General Public License as published by |
10 | 10 |
* the Free Software Foundation; either version 2 of the License, or |
11 | 11 |
* (at your option) any later version |
12 | 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, |
|
13 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
19 | 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | 16 |
* GNU General Public License for more details. |
... | ... |
@@ -24,9 +19,6 @@ |
24 | 19 |
* along with this program; if not, write to the Free Software |
25 | 20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
26 | 21 |
* |
27 |
- * History: |
|
28 |
- * -------- |
|
29 |
- * 2003-04-26 ZSW (jiri) |
|
30 | 22 |
*/ |
31 | 23 |
|
32 | 24 |
/*! \file |
... | ... |
@@ -22,7 +22,7 @@ |
22 | 22 |
* |
23 | 23 |
* You should have received a copy of the GNU General Public License |
24 | 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 |
|
25 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
26 | 26 |
* |
27 | 27 |
* History: |
28 | 28 |
* -------- |
... | ... |
@@ -31,6 +31,14 @@ |
31 | 31 |
* 2003-04-26 ZSW (jiri) |
32 | 32 |
*/ |
33 | 33 |
|
34 |
+/*! \file |
|
35 |
+ * \brief Parser :: Expires header field body parser. |
|
36 |
+ * |
|
37 |
+ * |
|
38 |
+ * \ingroup parser |
|
39 |
+ */ |
|
40 |
+ |
|
41 |
+ |
|
34 | 42 |
|
35 | 43 |
#include "parse_expires.h" |
36 | 44 |
#include <stdio.h> /* printf */ |
... | ... |
@@ -99,7 +107,7 @@ static inline int expires_parser(char* _s, int _l, exp_body_t* _e) |
99 | 107 |
} |
100 | 108 |
|
101 | 109 |
|
102 |
-/* |
|
110 |
+/*! \brief |
|
103 | 111 |
* Parse expires header field body |
104 | 112 |
*/ |
105 | 113 |
int parse_expires(struct hdr_field* _h) |
... | ... |
@@ -129,7 +137,7 @@ int parse_expires(struct hdr_field* _h) |
129 | 137 |
} |
130 | 138 |
|
131 | 139 |
|
132 |
-/* |
|
140 |
+/*! \brief |
|
133 | 141 |
* Free all memory associated with exp_body_t |
134 | 142 |
*/ |
135 | 143 |
void free_expires(exp_body_t** _e) |
... | ... |
@@ -139,7 +147,7 @@ void free_expires(exp_body_t** _e) |
139 | 147 |
} |
140 | 148 |
|
141 | 149 |
|
142 |
-/* |
|
150 |
+/*! \brief |
|
143 | 151 |
* Print exp_body_t content, for debugging only |
144 | 152 |
*/ |
145 | 153 |
void print_expires(exp_body_t* _e) |
... | ... |
@@ -49,7 +49,7 @@ static inline int expires_parser(char* _s, int _l, exp_body_t* _e) |
49 | 49 |
tmp.s = _s; |
50 | 50 |
tmp.len = _l; |
51 | 51 |
|
52 |
- trim_leading(&tmp); |
|
52 |
+ trim(&tmp); |
|
53 | 53 |
|
54 | 54 |
if (tmp.len == 0) { |
55 | 55 |
LOG(L_ERR, "expires_parser(): Empty body\n"); |
... | ... |
@@ -58,6 +58,13 @@ static inline int expires_parser(char* _s, int _l, exp_body_t* _e) |
58 | 58 |
} |
59 | 59 |
|
60 | 60 |
_e->text.s = tmp.s; |
61 |
+ _e->text.len = tmp.len; |
|
62 |
+ |
|
63 |
+ /* more then 32bit/maxuint cant be valid */ |
|
64 |
+ if (tmp.len > 10) { |
|
65 |
+ _e->valid = 0; |
|
66 |
+ return 0; |
|
67 |
+ } |
|
61 | 68 |
|
62 | 69 |
for(i = 0; i < tmp.len; i++) { |
63 | 70 |
if ((tmp.s[i] >= '0') && (tmp.s[i] <= '9')) { |
... | ... |
@@ -87,7 +94,6 @@ static inline int expires_parser(char* _s, int _l, exp_body_t* _e) |
87 | 94 |
} |
88 | 95 |
} |
89 | 96 |
|
90 |
- _e->text.len = _l; |
|
91 | 97 |
_e->valid = 1; |
92 | 98 |
return 0; |
93 | 99 |
} |
... | ... |
@@ -25,6 +25,10 @@ |
25 | 25 |
* You should have received a copy of the GNU General Public License |
26 | 26 |
* along with this program; if not, write to the Free Software |
27 | 27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
+ * |
|
29 |
+ * History: |
|
30 |
+ * -------- |
|
31 |
+ * 2003-04-26 ZSW (jiri) |
|
28 | 32 |
*/ |
29 | 33 |
|
30 | 34 |
|
... | ... |
@@ -34,6 +38,7 @@ |
34 | 38 |
#include "../dprint.h" |
35 | 39 |
#include "../trim.h" /* trim_leading */ |
36 | 40 |
#include <string.h> /* memset */ |
41 |
+#include "../ut.h" |
|
37 | 42 |
|
38 | 43 |
|
39 | 44 |
static inline int expires_parser(char* _s, int _l, exp_body_t* _e) |
... | ... |
@@ -134,7 +139,7 @@ void free_expires(exp_body_t** _e) |
134 | 139 |
void print_expires(exp_body_t* _e) |
135 | 140 |
{ |
136 | 141 |
printf("===Expires===\n"); |
137 |
- printf("text: \'%.*s\'\n", _e->text.len, _e->text.s); |
|
142 |
+ printf("text: \'%.*s\'\n", _e->text.len, ZSW(_e->text.s)); |
|
138 | 143 |
printf("val : %d\n", _e->val); |
139 | 144 |
printf("===/Expires===\n"); |
140 | 145 |
} |
... | ... |
@@ -48,6 +48,7 @@ static inline int expires_parser(char* _s, int _l, exp_body_t* _e) |
48 | 48 |
|
49 | 49 |
if (tmp.len == 0) { |
50 | 50 |
LOG(L_ERR, "expires_parser(): Empty body\n"); |
51 |
+ _e->valid = 0; |
|
51 | 52 |
return -1; |
52 | 53 |
} |
53 | 54 |
|
... | ... |
@@ -64,16 +65,25 @@ static inline int expires_parser(char* _s, int _l, exp_body_t* _e) |
64 | 65 |
case '\r': |
65 | 66 |
case '\n': |
66 | 67 |
_e->text.len = i; |
68 |
+ _e->valid = 1; |
|
67 | 69 |
return 0; |
68 | 70 |
|
69 | 71 |
default: |
72 |
+ /* Exit normally here, we want to be backwards compatible with |
|
73 |
+ * RFC2543 entities that can put absolute time here |
|
74 |
+ */ |
|
75 |
+ /* |
|
70 | 76 |
LOG(L_ERR, "expires_parser(): Invalid character\n"); |
71 | 77 |
return -2; |
78 |
+ */ |
|
79 |
+ _e->valid = 0; |
|
80 |
+ return 0; |
|
72 | 81 |
} |
73 | 82 |
} |
74 | 83 |
} |
75 | 84 |
|
76 | 85 |
_e->text.len = _l; |
86 |
+ _e->valid = 1; |
|
77 | 87 |
return 0; |
78 | 88 |
} |
79 | 89 |
|
... | ... |
@@ -2,8 +2,32 @@ |
2 | 2 |
* $Id$ |
3 | 3 |
* |
4 | 4 |
* Expires header field body parser |
5 |
+ * |
|
6 |
+ * Copyright (C) 2001-2003 Fhg Fokus |
|
7 |
+ * |
|
8 |
+ * This file is part of ser, a free SIP server. |
|
9 |
+ * |
|
10 |
+ * ser is free software; you can redistribute it and/or modify |
|
11 |
+ * it under the terms of the GNU General Public License as published by |
|
12 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
13 |
+ * (at your option) any later version |
|
14 |
+ * |
|
15 |
+ * For a license to use the ser software under conditions |
|
16 |
+ * other than those described here, or to purchase support for this |
|
17 |
+ * software, please contact iptel.org by e-mail at the following addresses: |
|
18 |
+ * info@iptel.org |
|
19 |
+ * |
|
20 |
+ * ser is distributed in the hope that it will be useful, |
|
21 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
+ * GNU General Public License for more details. |
|
24 |
+ * |
|
25 |
+ * You should have received a copy of the GNU General Public License |
|
26 |
+ * along with this program; if not, write to the Free Software |
|
27 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
5 | 28 |
*/ |
6 | 29 |
|
30 |
+ |
|
7 | 31 |
#include "parse_expires.h" |
8 | 32 |
#include <stdio.h> /* printf */ |
9 | 33 |
#include "../mem/mem.h" /* pkg_malloc, pkg_free */ |
... | ... |
@@ -100,7 +100,7 @@ void free_expires(exp_body_t** _e) |
100 | 100 |
void print_expires(exp_body_t* _e) |
101 | 101 |
{ |
102 | 102 |
printf("===Expires===\n"); |
103 |
- printf("text: %.*s\n", _e->text.len, _e->text.s); |
|
103 |
+ printf("text: \'%.*s\'\n", _e->text.len, _e->text.s); |
|
104 | 104 |
printf("val : %d\n", _e->val); |
105 | 105 |
printf("===/Expires===\n"); |
106 | 106 |
} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,106 @@ |
1 |
+/* |
|
2 |
+ * $Id$ |
|
3 |
+ * |
|
4 |
+ * Expires header field body parser |
|
5 |
+ */ |
|
6 |
+ |
|
7 |
+#include "parse_expires.h" |
|
8 |
+#include <stdio.h> /* printf */ |
|
9 |
+#include "../mem/mem.h" /* pkg_malloc, pkg_free */ |
|
10 |
+#include "../dprint.h" |
|
11 |
+#include "../trim.h" /* trim_leading */ |
|
12 |
+#include <string.h> /* memset */ |
|
13 |
+ |
|
14 |
+ |
|
15 |
+static inline int expires_parser(char* _s, int _l, exp_body_t* _e) |
|
16 |
+{ |
|
17 |
+ int i; |
|
18 |
+ str tmp; |
|
19 |
+ |
|
20 |
+ tmp.s = _s; |
|
21 |
+ tmp.len = _l; |
|
22 |
+ |
|
23 |
+ trim_leading(&tmp); |
|
24 |
+ |
|
25 |
+ if (tmp.len == 0) { |
|
26 |
+ LOG(L_ERR, "expires_parser(): Empty body\n"); |
|
27 |
+ return -1; |
|
28 |
+ } |
|
29 |
+ |
|
30 |
+ _e->text.s = tmp.s; |
|
31 |
+ |
|
32 |
+ for(i = 0; i < tmp.len; i++) { |
|
33 |
+ if ((tmp.s[i] >= '0') && (tmp.s[i] <= '9')) { |
|
34 |
+ _e->val *= 10; |
|
35 |
+ _e->val += tmp.s[i] - '0'; |
|
36 |
+ } else { |
|
37 |
+ switch(tmp.s[i]) { |
|
38 |
+ case ' ': |
|
39 |
+ case '\t': |
|
40 |
+ case '\r': |
|
41 |
+ case '\n': |
|
42 |
+ _e->text.len = i; |
|
43 |
+ return 0; |
|
44 |
+ |
|
45 |
+ default: |
|
46 |
+ LOG(L_ERR, "expires_parser(): Invalid character\n"); |
|
47 |
+ return -2; |
|
48 |
+ } |
|
49 |
+ } |
|
50 |
+ } |
|
51 |
+ |
|
52 |
+ _e->text.len = _l; |
|
53 |
+ return 0; |
|
54 |
+} |
|
55 |
+ |
|
56 |
+ |
|
57 |
+/* |
|
58 |
+ * Parse expires header field body |
|
59 |
+ */ |
|
60 |
+int parse_expires(struct hdr_field* _h) |
|
61 |
+{ |
|
62 |
+ exp_body_t* e; |
|
63 |
+ |
|
64 |
+ if (_h->parsed) { |
|
65 |
+ return 0; /* Already parsed */ |
|
66 |
+ } |
|
67 |
+ |
|
68 |
+ e = (exp_body_t*)pkg_malloc(sizeof(exp_body_t)); |
|
69 |
+ if (e == 0) { |
|
70 |
+ LOG(L_ERR, "parse_expires(): No memory left\n"); |
|
71 |
+ return -1; |
|
72 |
+ } |
|
73 |
+ |
|
74 |
+ memset(e, 0, sizeof(exp_body_t)); |
|
75 |
+ |
|
76 |
+ if (expires_parser(_h->body.s, _h->body.len, e) < 0) { |
|
77 |
+ LOG(L_ERR, "parse_expires(): Error while parsing\n"); |
|
78 |
+ pkg_free(e); |
|
79 |
+ return -2; |
|
80 |
+ } |
|
81 |
+ |
|
82 |
+ _h->parsed = (void*)e; |
|
83 |
+ return 0; |
|
84 |
+} |
|
85 |
+ |
|
86 |
+ |
|
87 |
+/* |
|
88 |
+ * Free all memory associated with exp_body_t |
|
89 |
+ */ |
|
90 |
+void free_expires(exp_body_t** _e) |
|
91 |
+{ |
|
92 |
+ pkg_free(*_e); |
|
93 |
+ *_e = 0; |
|
94 |
+} |
|
95 |
+ |
|
96 |
+ |
|
97 |
+/* |
|
98 |
+ * Print exp_body_t content, for debugging only |
|
99 |
+ */ |
|
100 |
+void print_expires(exp_body_t* _e) |
|
101 |
+{ |
|
102 |
+ printf("===Expires===\n"); |
|
103 |
+ printf("text: %.*s\n", _e->text.len, _e->text.s); |
|
104 |
+ printf("val : %d\n", _e->val); |
|
105 |
+ printf("===/Expires===\n"); |
|
106 |
+} |