- 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,182 +0,0 @@ |
1 |
-/* |
|
2 |
- * Handling of the q value |
|
3 |
- * |
|
4 |
- * Copyright (C) 2004 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 |
-/*! |
|
25 |
- * \file |
|
26 |
- * \brief Kamailio core :: Handling of the q value |
|
27 |
- * \ingroup core |
|
28 |
- * Module: \ref core |
|
29 |
- */ |
|
30 |
- |
|
31 |
- |
|
32 |
-#include "error.h" |
|
33 |
-#include "qvalue.h" |
|
34 |
- |
|
35 |
- |
|
36 |
-/* |
|
37 |
- * Convert string representation of q parameter in qvalue_t |
|
38 |
- */ |
|
39 |
-int str2q(qvalue_t* q, char* s, int len) |
|
40 |
-{ |
|
41 |
- int i, digits, order; |
|
42 |
- |
|
43 |
- /* States and equivalent regular expressions of input */ |
|
44 |
- enum { |
|
45 |
- ST_START, /* (SPC|TAB)* */ |
|
46 |
- ST_0, /* 0+ */ |
|
47 |
- ST_1, /* 1 */ |
|
48 |
- ST_0_PT, /* 0*\. */ |
|
49 |
- ST_1_PT, /* 1\. */ |
|
50 |
- ST_1_PT_0, /* 1\.0+ */ |
|
51 |
- ST_0_PT_N /* 0*\.[0-9]+ */ |
|
52 |
- } state = ST_START; |
|
53 |
- |
|
54 |
- if (!q || !s) { |
|
55 |
- return E_INVALID_PARAMS; |
|
56 |
- } |
|
57 |
- |
|
58 |
- digits = 1; |
|
59 |
- order = 100; |
|
60 |
- for(i = 0; i < len; i++) { |
|
61 |
- switch(state) { |
|
62 |
- case ST_START: |
|
63 |
- switch(s[i]) { |
|
64 |
- case ' ': |
|
65 |
- case '\t': |
|
66 |
- break; |
|
67 |
- |
|
68 |
- case '0': |
|
69 |
- *q = 0; |
|
70 |
- state = ST_0; |
|
71 |
- break; |
|
72 |
- |
|
73 |
- case '1': |
|
74 |
- *q = 1000; |
|
75 |
- state = ST_1; |
|
76 |
- break; |
|
77 |
- |
|
78 |
- case '.': |
|
79 |
- state = ST_0_PT; |
|
80 |
- break; |
|
81 |
- |
|
82 |
- default: |
|
83 |
- return E_Q_INV_CHAR; |
|
84 |
- } |
|
85 |
- break; |
|
86 |
- |
|
87 |
- case ST_0: |
|
88 |
- switch(s[i]) { |
|
89 |
- case '0': |
|
90 |
- break; |
|
91 |
- |
|
92 |
- case '.': |
|
93 |
- state = ST_0_PT; |
|
94 |
- break; |
|
95 |
- |
|
96 |
- case '1': |
|
97 |
- *q = 1000; |
|
98 |
- state = ST_1; |
|
99 |
- break; |
|
100 |
- |
|
101 |
- default: |
|
102 |
- if (s[i] >= '2' && s[i] <= '9') { |
|
103 |
- return E_Q_TOO_BIG; |
|
104 |
- } else { |
|
105 |
- return E_Q_INV_CHAR; |
|
106 |
- } |
|
107 |
- } |
|
108 |
- break; |
|
109 |
- |
|
110 |
- case ST_1: |
|
111 |
- if (s[i] == '.') { |
|
112 |
- state = ST_1_PT; |
|
113 |
- break; |
|
114 |
- } else { |
|
115 |
- if (s[i] >= '0' && s[i] <= '9') { |
|
116 |
- return E_Q_TOO_BIG; |
|
117 |
- } else { |
|
118 |
- return E_Q_INV_CHAR; |
|
119 |
- } |
|
120 |
- } |
|
121 |
- break; |
|
122 |
- |
|
123 |
- case ST_0_PT: |
|
124 |
- if (s[i] >= '0' && s[i] <= '9') { |
|
125 |
- *q = (s[i] - '0') * order; |
|
126 |
- order /= 10; |
|
127 |
- state = ST_0_PT_N; |
|
128 |
- } else { |
|
129 |
- return E_Q_INV_CHAR; |
|
130 |
- } |
|
131 |
- break; |
|
132 |
- |
|
133 |
- case ST_1_PT: |
|
134 |
- if (s[i] == '0') { |
|
135 |
- state = ST_1_PT_0; |
|
136 |
- } else { |
|
137 |
- if (s[i] >= '1' && s[i] <= '9') { |
|
138 |
- return E_Q_TOO_BIG; |
|
139 |
- } else { |
|
140 |
- return E_Q_INV_CHAR; |
|
141 |
- } |
|
142 |
- } |
|
143 |
- break; |
|
144 |
- |
|
145 |
- case ST_1_PT_0: |
|
146 |
- if (s[i] == '0') { |
|
147 |
- break; |
|
148 |
- } else { |
|
149 |
- if (s[i] >= '1' && s[i] <= '9') { |
|
150 |
- return E_Q_TOO_BIG; |
|
151 |
- } else { |
|
152 |
- return E_Q_INV_CHAR; |
|
153 |
- } |
|
154 |
- } |
|
155 |
- break; |
|
156 |
- |
|
157 |
- case ST_0_PT_N: |
|
158 |
- if (s[i] >= '0' && s[i] <= '9') { |
|
159 |
- if (digits <= 3) { |
|
160 |
- *q += (s[i] - '0') * order; |
|
161 |
- order /= 10; |
|
162 |
- digits++; |
|
163 |
- } |
|
164 |
- } else { |
|
165 |
- return E_Q_INV_CHAR; |
|
166 |
- } |
|
167 |
- break; |
|
168 |
- } |
|
169 |
- } |
|
170 |
- |
|
171 |
- switch(state) { |
|
172 |
- case ST_START: |
|
173 |
- return E_Q_EMPTY; |
|
174 |
- |
|
175 |
- case ST_0_PT: |
|
176 |
- case ST_1_PT: |
|
177 |
- return E_Q_DEC_MISSING; |
|
178 |
- |
|
179 |
- default: |
|
180 |
- return 0; |
|
181 |
- } |
|
182 |
-} |
... | ... |
@@ -10,11 +10,6 @@ |
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 | 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 |
... | ... |
@@ -1,13 +1,11 @@ |
1 | 1 |
/* |
2 |
- * $Id$ |
|
3 |
- * |
|
4 | 2 |
* Handling of the q value |
5 | 3 |
* |
6 | 4 |
* Copyright (C) 2004 FhG FOKUS |
7 | 5 |
* |
8 |
- * This file is part of ser, a free SIP server. |
|
6 |
+ * This file is part of Kamailio, a free SIP server. |
|
9 | 7 |
* |
10 |
- * ser is free software; you can redistribute it and/or modify |
|
8 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
11 | 9 |
* it under the terms of the GNU General Public License as published by |
12 | 10 |
* the Free Software Foundation; either version 2 of the License, or |
13 | 11 |
* (at your option) any later version |
... | ... |
@@ -17,7 +15,7 @@ |
17 | 15 |
* software, please contact iptel.org by e-mail at the following addresses: |
18 | 16 |
* info@iptel.org |
19 | 17 |
* |
20 |
- * ser is distributed in the hope that it will be useful, |
|
18 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
21 | 19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | 20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | 21 |
* GNU General Public License for more details. |
... | ... |
@@ -26,14 +24,11 @@ |
26 | 24 |
* along with this program; if not, write to the Free Software |
27 | 25 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
28 | 26 |
* |
29 |
- * History |
|
30 |
- * ------ |
|
31 |
- * 2004-04-25 created (janakj) |
|
32 | 27 |
*/ |
33 | 28 |
|
34 | 29 |
/*! |
35 | 30 |
* \file |
36 |
- * \brief SIP-router core :: Handling of the q value |
|
31 |
+ * \brief Kamailio core :: Handling of the q value |
|
37 | 32 |
* \ingroup core |
38 | 33 |
* Module: \ref core |
39 | 34 |
*/ |
... | ... |
@@ -24,7 +24,7 @@ |
24 | 24 |
* |
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 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
27 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
28 | 28 |
* |
29 | 29 |
* History |
30 | 30 |
* ------ |
Please fill in after the :: to explain the function of this file.
... | ... |
@@ -40,7 +40,7 @@ |
40 | 40 |
*/ |
41 | 41 |
int str2q(qvalue_t* q, char* s, int len) |
42 | 42 |
{ |
43 |
- int i, digits; |
|
43 |
+ int i, digits, order; |
|
44 | 44 |
|
45 | 45 |
/* States and equivalent regular expressions of input */ |
46 | 46 |
enum { |
... | ... |
@@ -58,6 +58,7 @@ int str2q(qvalue_t* q, char* s, int len) |
58 | 58 |
} |
59 | 59 |
|
60 | 60 |
digits = 1; |
61 |
+ order = 100; |
|
61 | 62 |
for(i = 0; i < len; i++) { |
62 | 63 |
switch(state) { |
63 | 64 |
case ST_START: |
... | ... |
@@ -123,7 +124,8 @@ int str2q(qvalue_t* q, char* s, int len) |
123 | 124 |
|
124 | 125 |
case ST_0_PT: |
125 | 126 |
if (s[i] >= '0' && s[i] <= '9') { |
126 |
- *q = s[i] - '0'; |
|
127 |
+ *q = (s[i] - '0') * order; |
|
128 |
+ order /= 10; |
|
127 | 129 |
state = ST_0_PT_N; |
128 | 130 |
} else { |
129 | 131 |
return E_Q_INV_CHAR; |
... | ... |
@@ -156,8 +158,9 @@ int str2q(qvalue_t* q, char* s, int len) |
156 | 158 |
|
157 | 159 |
case ST_0_PT_N: |
158 | 160 |
if (s[i] >= '0' && s[i] <= '9') { |
159 |
- if (digits < 3) { |
|
160 |
- *q = *q * 10 + s[i] - '0'; |
|
161 |
+ if (digits <= 3) { |
|
162 |
+ *q += (s[i] - '0') * order; |
|
163 |
+ order /= 10; |
|
161 | 164 |
digits++; |
162 | 165 |
} |
163 | 166 |
} else { |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,181 @@ |
1 |
+/* |
|
2 |
+ * $Id$ |
|
3 |
+ * |
|
4 |
+ * Handling of the q value |
|
5 |
+ * |
|
6 |
+ * Copyright (C) 2004 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 |
|
28 |
+ * |
|
29 |
+ * History |
|
30 |
+ * ------ |
|
31 |
+ * 2004-04-25 created (janakj) |
|
32 |
+ */ |
|
33 |
+ |
|
34 |
+#include "error.h" |
|
35 |
+#include "qvalue.h" |
|
36 |
+ |
|
37 |
+ |
|
38 |
+/* |
|
39 |
+ * Convert string representation of q parameter in qvalue_t |
|
40 |
+ */ |
|
41 |
+int str2q(qvalue_t* q, char* s, int len) |
|
42 |
+{ |
|
43 |
+ int i, digits; |
|
44 |
+ |
|
45 |
+ /* States and equivalent regular expressions of input */ |
|
46 |
+ enum { |
|
47 |
+ ST_START, /* (SPC|TAB)* */ |
|
48 |
+ ST_0, /* 0+ */ |
|
49 |
+ ST_1, /* 1 */ |
|
50 |
+ ST_0_PT, /* 0*\. */ |
|
51 |
+ ST_1_PT, /* 1\. */ |
|
52 |
+ ST_1_PT_0, /* 1\.0+ */ |
|
53 |
+ ST_0_PT_N /* 0*\.[0-9]+ */ |
|
54 |
+ } state = ST_START; |
|
55 |
+ |
|
56 |
+ if (!q || !s) { |
|
57 |
+ return E_INVALID_PARAMS; |
|
58 |
+ } |
|
59 |
+ |
|
60 |
+ digits = 1; |
|
61 |
+ for(i = 0; i < len; i++) { |
|
62 |
+ switch(state) { |
|
63 |
+ case ST_START: |
|
64 |
+ switch(s[i]) { |
|
65 |
+ case ' ': |
|
66 |
+ case '\t': |
|
67 |
+ break; |
|
68 |
+ |
|
69 |
+ case '0': |
|
70 |
+ *q = 0; |
|
71 |
+ state = ST_0; |
|
72 |
+ break; |
|
73 |
+ |
|
74 |
+ case '1': |
|
75 |
+ *q = 1000; |
|
76 |
+ state = ST_1; |
|
77 |
+ break; |
|
78 |
+ |
|
79 |
+ case '.': |
|
80 |
+ state = ST_0_PT; |
|
81 |
+ break; |
|
82 |
+ |
|
83 |
+ default: |
|
84 |
+ return E_Q_INV_CHAR; |
|
85 |
+ } |
|
86 |
+ break; |
|
87 |
+ |
|
88 |
+ case ST_0: |
|
89 |
+ switch(s[i]) { |
|
90 |
+ case '0': |
|
91 |
+ break; |
|
92 |
+ |
|
93 |
+ case '.': |
|
94 |
+ state = ST_0_PT; |
|
95 |
+ break; |
|
96 |
+ |
|
97 |
+ case '1': |
|
98 |
+ *q = 1000; |
|
99 |
+ state = ST_1; |
|
100 |
+ break; |
|
101 |
+ |
|
102 |
+ default: |
|
103 |
+ if (s[i] >= '2' && s[i] <= '9') { |
|
104 |
+ return E_Q_TOO_BIG; |
|
105 |
+ } else { |
|
106 |
+ return E_Q_INV_CHAR; |
|
107 |
+ } |
|
108 |
+ } |
|
109 |
+ break; |
|
110 |
+ |
|
111 |
+ case ST_1: |
|
112 |
+ if (s[i] == '.') { |
|
113 |
+ state = ST_1_PT; |
|
114 |
+ break; |
|
115 |
+ } else { |
|
116 |
+ if (s[i] >= '0' && s[i] <= '9') { |
|
117 |
+ return E_Q_TOO_BIG; |
|
118 |
+ } else { |
|
119 |
+ return E_Q_INV_CHAR; |
|
120 |
+ } |
|
121 |
+ } |
|
122 |
+ break; |
|
123 |
+ |
|
124 |
+ case ST_0_PT: |
|
125 |
+ if (s[i] >= '0' && s[i] <= '9') { |
|
126 |
+ *q = s[i] - '0'; |
|
127 |
+ state = ST_0_PT_N; |
|
128 |
+ } else { |
|
129 |
+ return E_Q_INV_CHAR; |
|
130 |
+ } |
|
131 |
+ break; |
|
132 |
+ |
|
133 |
+ case ST_1_PT: |
|
134 |
+ if (s[i] == '0') { |
|
135 |
+ state = ST_1_PT_0; |
|
136 |
+ } else { |
|
137 |
+ if (s[i] >= '1' && s[i] <= '9') { |
|
138 |
+ return E_Q_TOO_BIG; |
|
139 |
+ } else { |
|
140 |
+ return E_Q_INV_CHAR; |
|
141 |
+ } |
|
142 |
+ } |
|
143 |
+ break; |
|
144 |
+ |
|
145 |
+ case ST_1_PT_0: |
|
146 |
+ if (s[i] == '0') { |
|
147 |
+ break; |
|
148 |
+ } else { |
|
149 |
+ if (s[i] >= '1' && s[i] <= '9') { |
|
150 |
+ return E_Q_TOO_BIG; |
|
151 |
+ } else { |
|
152 |
+ return E_Q_INV_CHAR; |
|
153 |
+ } |
|
154 |
+ } |
|
155 |
+ break; |
|
156 |
+ |
|
157 |
+ case ST_0_PT_N: |
|
158 |
+ if (s[i] >= '0' && s[i] <= '9') { |
|
159 |
+ if (digits < 3) { |
|
160 |
+ *q = *q * 10 + s[i] - '0'; |
|
161 |
+ digits++; |
|
162 |
+ } |
|
163 |
+ } else { |
|
164 |
+ return E_Q_INV_CHAR; |
|
165 |
+ } |
|
166 |
+ break; |
|
167 |
+ } |
|
168 |
+ } |
|
169 |
+ |
|
170 |
+ switch(state) { |
|
171 |
+ case ST_START: |
|
172 |
+ return E_Q_EMPTY; |
|
173 |
+ |
|
174 |
+ case ST_0_PT: |
|
175 |
+ case ST_1_PT: |
|
176 |
+ return E_Q_DEC_MISSING; |
|
177 |
+ |
|
178 |
+ default: |
|
179 |
+ return 0; |
|
180 |
+ } |
|
181 |
+} |