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,423 +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
-
22
-/*! \file
23
- * \brief Parser :: Content-Disposition header
24
- *
25
- * \ingroup parser
26
- */
27
-
28
-
29
-#include <stdio.h>
30
-#include <stdlib.h>
31
-#include <sys/types.h>
32
-#include <unistd.h>
33
-#include "../mem/mem.h"
34
-#include "../dprint.h"
35
-#include "../ut.h"
36
-#include "parse_disposition.h"
37
-
38
-
39
-
40
-/*! \brief parse a string that supposed to be a disposition and fills up the structure
41
- * Returns: -1 : error
42
- *           o : success */
43
-int parse_disposition( str *s, struct disposition *disp)
44
-{
45
-	enum { FIND_TYPE, TYPE, END_TYPE, FIND_PARAM, PARAM, END_PARAM, FIND_VAL,
46
-	       FIND_QUOTED_VAL, QUOTED_VAL, SKIP_QUOTED_VAL, VAL, END_VAL,
47
-	       F_LF, F_CR, F_CRLF};
48
-	struct disposition_param *disp_p;
49
-	struct disposition_param *new_p;
50
-	int  state;
51
-	int  saved_state;
52
-	char *tmp;
53
-	char *end;
54
-
55
-	if(s==NULL || s->s==NULL || s->len<=0) {
56
-		LM_ERR("invalid parameters\n");
57
-		return -1;
58
-	}
59
-
60
-	state = saved_state = FIND_TYPE;
61
-	end = s->s + s->len;
62
-	disp_p = 0;
63
-
64
-	for( tmp=s->s; tmp<end; tmp++) {
65
-		switch(*tmp) {
66
-			case ' ':
67
-			case '\t':
68
-				switch (state) {
69
-					case FIND_QUOTED_VAL:
70
-						disp_p->body.s = tmp;
71
-						state = QUOTED_VAL;
72
-						break;
73
-					case SKIP_QUOTED_VAL:
74
-						state = QUOTED_VAL;
75
-						break;
76
-					case TYPE:
77
-						disp->type.len = tmp - disp->type.s;
78
-						state = END_TYPE;
79
-						break;
80
-					case PARAM:
81
-						disp_p->name.len = tmp - disp_p->name.s;
82
-						state = END_PARAM;
83
-						break;
84
-					case VAL:
85
-						disp_p->body.len = tmp - disp_p->body.s;
86
-						state = END_VAL;
87
-						break;
88
-					case F_CRLF:
89
-					case F_LF:
90
-					case F_CR:
91
-						/*previous=crlf and now =' '*/
92
-						state=saved_state;
93
-						break;
94
-				}
95
-				break;
96
-			case '\n':
97
-				switch (state) {
98
-					case TYPE:
99
-						disp->type.len = tmp - disp->type.s;
100
-						saved_state = END_TYPE;
101
-						state = F_LF;
102
-						break;
103
-					case PARAM:
104
-						disp_p->name.len = tmp - disp_p->name.s;
105
-						saved_state = END_PARAM;
106
-						state = F_LF;
107
-						break;
108
-					case VAL:
109
-						disp_p->body.len = tmp - disp_p->body.s;
110
-						saved_state = END_VAL;
111
-						state = F_CR;
112
-						break;
113
-					case FIND_TYPE:
114
-					case FIND_PARAM:
115
-						saved_state=state;
116
-						state=F_LF;
117
-						break;
118
-					case F_CR:
119
-						state=F_CRLF;
120
-						break;
121
-					default:
122
-						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
123
-							*tmp,state, (int)(tmp-s->s), s->s);
124
-						goto error;
125
-				}
126
-				break;
127
-			case '\r':
128
-				switch (state) {
129
-					case TYPE:
130
-						disp->type.len = tmp - disp->type.s;
131
-						saved_state = END_TYPE;
132
-						state = F_CR;
133
-						break;
134
-					case PARAM:
135
-						disp_p->name.len = tmp - disp_p->name.s;
136
-						saved_state = END_PARAM;
137
-						state = F_CR;
138
-						break;
139
-					case VAL:
140
-						disp_p->body.len = tmp - disp_p->body.s;
141
-						saved_state = END_VAL;
142
-						state = F_CR;
143
-						break;
144
-					case FIND_TYPE:
145
-					case FIND_PARAM:
146
-						saved_state=state;
147
-						state=F_CR;
148
-						break;
149
-					default:
150
-						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
151
-							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
152
-						goto error;
153
-				}
154
-				break;
155
-			case 0:
156
-				LM_ERR("nexpected char [%c] in status %d: <<%.*s>>.\n",
157
-					*tmp,state, (int)(tmp-s->s), ZSW(s->s));
158
-				goto error;
159
-				break;
160
-			case ';':
161
-				switch (state) {
162
-					case FIND_QUOTED_VAL:
163
-						disp_p->body.s = tmp;
164
-						state = QUOTED_VAL;
165
-						break;
166
-					case SKIP_QUOTED_VAL:
167
-						state = QUOTED_VAL;
168
-					case QUOTED_VAL:
169
-						break;
170
-					case VAL:
171
-						disp_p->body.len = tmp - disp_p->body.s;
172
-						state = FIND_PARAM;
173
-						break;
174
-					case PARAM:
175
-						disp_p->name.len = tmp - disp_p->name.s;
176
-						state = FIND_PARAM;
177
-						break;
178
-					case TYPE:
179
-						disp->type.len = tmp - disp->type.s;
180
-					case END_TYPE:
181
-					case END_VAL:
182
-						state = FIND_PARAM;
183
-						break;
184
-					default:
185
-						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
186
-							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
187
-						goto error;
188
-				}
189
-				break;
190
-			case '=':
191
-				switch (state) {
192
-					case FIND_QUOTED_VAL:
193
-						disp_p->body.s = tmp;
194
-						state = QUOTED_VAL;
195
-						break;
196
-					case SKIP_QUOTED_VAL:
197
-						state = QUOTED_VAL;
198
-					case QUOTED_VAL:
199
-						break;
200
-					case PARAM:
201
-						disp_p->name.len = tmp - disp_p->name.s;
202
-					case END_PARAM:
203
-						state = FIND_VAL;
204
-						break;
205
-					default:
206
-						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
207
-							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
208
-						goto error;
209
-				}
210
-				break;
211
-			case '\"':
212
-				switch (state) {
213
-					case SKIP_QUOTED_VAL:
214
-						state = QUOTED_VAL;
215
-						break;
216
-					case FIND_VAL:
217
-						state = FIND_QUOTED_VAL;
218
-						break;
219
-					case QUOTED_VAL:
220
-						disp_p->body.len = tmp - disp_p->body.s;
221
-						disp_p->is_quoted = 1;
222
-						state = END_VAL;
223
-						break;
224
-					default:
225
-						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
226
-							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
227
-						goto error;
228
-				}
229
-				break;
230
-			case '\\':
231
-				switch (state) {
232
-					case FIND_QUOTED_VAL:
233
-						disp_p->body.s = tmp;
234
-						state = SKIP_QUOTED_VAL;
235
-						break;
236
-					case SKIP_QUOTED_VAL:
237
-						state = QUOTED_VAL;
238
-						break;
239
-					case QUOTED_VAL:
240
-						state = SKIP_QUOTED_VAL;
241
-						break;
242
-					default:
243
-						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
244
-							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
245
-						goto error;
246
-				}
247
-				break;
248
-			case '(':
249
-			case ')':
250
-			case '<':
251
-			case '>':
252
-			case '@':
253
-			case ',':
254
-			case ':':
255
-			case '/':
256
-			case '[':
257
-			case ']':
258
-			case '?':
259
-			case '{':
260
-			case '}':
261
-				switch (state) {
262
-					case FIND_QUOTED_VAL:
263
-						disp_p->body.s = tmp;
264
-						state = QUOTED_VAL;
265
-						break;
266
-					case SKIP_QUOTED_VAL:
267
-						state = QUOTED_VAL;
268
-					case QUOTED_VAL:
269
-						break;
270
-					default:
271
-						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
272
-							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
273
-						goto error;
274
-				}
275
-				break;
276
-			default:
277
-				switch (state) {
278
-					case SKIP_QUOTED_VAL:
279
-						state = QUOTED_VAL;
280
-					case QUOTED_VAL:
281
-						break;
282
-					case FIND_TYPE:
283
-						disp->type.s = tmp;
284
-						state = TYPE;
285
-						break;
286
-					case FIND_PARAM:
287
-						new_p=(struct disposition_param*)pkg_malloc
288
-							(sizeof(struct disposition_param));
289
-						if (new_p==0) {
290
-							LM_ERR("no more pkg mem\n");
291
-							goto error;
292
-						}
293
-						memset(new_p,0,sizeof(struct disposition_param));
294
-						if (disp_p==0)
295
-							disp->params = new_p;
296
-						else
297
-							disp_p->next = new_p;
298
-						disp_p = new_p;
299
-						disp_p->name.s = tmp;
300
-						state = PARAM;
301
-						break;
302
-					case FIND_VAL:
303
-						disp_p->body.s = tmp;
304
-						state = VAL;
305
-						break;
306
-					case FIND_QUOTED_VAL:
307
-						disp_p->body.s = tmp;
308
-						state = QUOTED_VAL;
309
-						break;
310
-				}
311
-		}/*switch*/
312
-	}/*for*/
313
-
314
-	/* check which was the last parser state */
315
-	switch (state) {
316
-		case END_PARAM:
317
-		case END_TYPE:
318
-		case END_VAL:
319
-			break;
320
-		case TYPE:
321
-			disp->type.len = tmp - disp->type.s;
322
-			break;
323
-		case PARAM:
324
-			disp_p->name.len = tmp - disp_p->name.s;
325
-			break;
326
-		case VAL:
327
-			disp_p->body.len = tmp - disp_p->body.s;
328
-			break;
329
-		default:
330
-			LM_ERR("wrong final state (%d)\n",
331
-				state);
332
-			goto error;
333
-	}
334
-	return 0;
335
-error:
336
-	return -1;
337
-}
338
-
339
-
340
-
341
-/*! \brief Frees the entire disposition structure (params + itself) */
342
-void free_disposition( struct disposition **disp)
343
-{
344
-	struct disposition_param *param;
345
-
346
-	/* free the params */
347
-	while((*disp)->params) {
348
-		param = (*disp)->params->next;
349
-		pkg_free( (*disp)->params);
350
-		(*disp)->params = param;
351
-	}
352
-	pkg_free( *disp );
353
-	*disp = 0;
354
-}
355
-
356
-
357
-
358
-/*! \brief looks inside the message, gets the Content-Disposition hdr, parse it, builds
359
- * and fills a disposition structure for it what will be attached to hdr as
360
- * parsed link.
361
- * Returns:  -1 : error
362
- *            0 : success
363
- *            1 : hdr not found
364
- */
365
-int parse_content_disposition( struct sip_msg *msg )
366
-{
367
-	struct disposition *disp;
368
-
369
-	/* look for Content-Disposition header */
370
-	if (msg->content_disposition==0) {
371
-		if (parse_headers(msg, HDR_CONTENTDISPOSITION_F, 0)==-1)
372
-			goto error;
373
-		if (msg->content_disposition==0) {
374
-			DBG("hdr not found\n");
375
-			return 1;
376
-		}
377
-	}
378
-
379
-	/* now, we have the header -> look if it isn't already parsed */
380
-	if (msg->content_disposition->parsed!=0) {
381
-		/* already parsed, nothing more to be done */
382
-		return 0;
383
-	}
384
-
385
-	/* parse the body */
386
-	disp = (struct disposition*)pkg_malloc(sizeof(struct disposition));
387
-	if (disp==0) {
388
-		LM_ERR("no more pkg memory\n");
389
-		goto error;
390
-	}
391
-	memset(disp,0,sizeof(struct disposition));
392
-
393
-	if (parse_disposition( &(msg->content_disposition->body), disp)==-1) {
394
-		/* error when parsing the body */
395
-		free_disposition( &disp );
396
-		goto error;
397
-	}
398
-
399
-	/* attach the parsed form to the header */
400
-	msg->content_disposition->parsed = (void*)disp;
401
-
402
-	return 0;
403
-error:
404
-	return -1;
405
-}
406
-
407
-
408
-/*! \brief Prints recursive a disposition structure */
409
-void print_disposition( struct disposition *disp)
410
-{
411
-	struct disposition_param *param;
412
-
413
-	DBG("*** Disposition type=<%.*s>[%d]\n",
414
-		disp->type.len,disp->type.s,disp->type.len);
415
-	for( param=disp->params; param; param=param->next) {
416
-		DBG("*** Disposition param: <%.*s>[%d]=<%.*s>[%d] is_quoted=%d\n",
417
-			param->name.len,param->name.s, param->name.len,
418
-			param->body.len,param->body.s, param->body.len,
419
-			param->is_quoted);
420
-	}
421
-}
422
-
423
-
Browse code

core: parser - safety check and clean log messages for disposition header

Daniel-Constantin Mierla authored on 26/08/2016 07:26:47
Showing 1 changed files
... ...
@@ -52,6 +52,11 @@ int parse_disposition( str *s, struct disposition *disp)
52 52
 	char *tmp;
53 53
 	char *end;
54 54
 
55
+	if(s==NULL || s->s==NULL || s->len<=0) {
56
+		LM_ERR("invalid parameters\n");
57
+		return -1;
58
+	}
59
+
55 60
 	state = saved_state = FIND_TYPE;
56 61
 	end = s->s + s->len;
57 62
 	disp_p = 0;
... ...
@@ -114,8 +119,7 @@ int parse_disposition( str *s, struct disposition *disp)
114 119
 						state=F_CRLF;
115 120
 						break;
116 121
 					default:
117
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
118
-							"char [%c] in status %d: <<%.*s>> .\n",
122
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
119 123
 							*tmp,state, (int)(tmp-s->s), s->s);
120 124
 						goto error;
121 125
 				}
... ...
@@ -143,15 +147,13 @@ int parse_disposition( str *s, struct disposition *disp)
143 147
 						state=F_CR;
144 148
 						break;
145 149
 					default:
146
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
147
-							"char [%c] in status %d: <<%.*s>> .\n",
150
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
148 151
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
149 152
 						goto error;
150 153
 				}
151 154
 				break;
152 155
 			case 0:
153
-				LOG(L_ERR,"ERROR:parse_disposition: unexpected "
154
-					"char [%c] in status %d: <<%.*s>> .\n",
156
+				LM_ERR("nexpected char [%c] in status %d: <<%.*s>>.\n",
155 157
 					*tmp,state, (int)(tmp-s->s), ZSW(s->s));
156 158
 				goto error;
157 159
 				break;
... ...
@@ -180,8 +182,7 @@ int parse_disposition( str *s, struct disposition *disp)
180 182
 						state = FIND_PARAM;
181 183
 						break;
182 184
 					default:
183
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
184
-							"char [%c] in status %d: <<%.*s>> .\n",
185
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
185 186
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
186 187
 						goto error;
187 188
 				}
... ...
@@ -202,8 +203,7 @@ int parse_disposition( str *s, struct disposition *disp)
202 203
 						state = FIND_VAL;
203 204
 						break;
204 205
 					default:
205
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
206
-							"char [%c] in status %d: <<%.*s>> .\n",
206
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
207 207
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
208 208
 						goto error;
209 209
 				}
... ...
@@ -222,8 +222,7 @@ int parse_disposition( str *s, struct disposition *disp)
222 222
 						state = END_VAL;
223 223
 						break;
224 224
 					default:
225
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
226
-							"char [%c] in status %d: <<%.*s>> .\n",
225
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
227 226
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
228 227
 						goto error;
229 228
 				}
... ...
@@ -241,8 +240,7 @@ int parse_disposition( str *s, struct disposition *disp)
241 240
 						state = SKIP_QUOTED_VAL;
242 241
 						break;
243 242
 					default:
244
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
245
-							"char [%c] in status %d: <<%.*s>> .\n",
243
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
246 244
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
247 245
 						goto error;
248 246
 				}
... ...
@@ -270,8 +268,7 @@ int parse_disposition( str *s, struct disposition *disp)
270 268
 					case QUOTED_VAL:
271 269
 						break;
272 270
 					default:
273
-						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
274
-							"char [%c] in status %d: <<%.*s>> .\n",
271
+						LM_ERR("unexpected char [%c] in status %d: <<%.*s>>.\n",
275 272
 							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
276 273
 						goto error;
277 274
 				}
... ...
@@ -290,8 +287,7 @@ int parse_disposition( str *s, struct disposition *disp)
290 287
 						new_p=(struct disposition_param*)pkg_malloc
291 288
 							(sizeof(struct disposition_param));
292 289
 						if (new_p==0) {
293
-							LOG(L_ERR,"ERROR:parse_disposition: no more "
294
-								"pkg mem\n");
290
+							LM_ERR("no more pkg mem\n");
295 291
 							goto error;
296 292
 						}
297 293
 						memset(new_p,0,sizeof(struct disposition_param));
... ...
@@ -331,7 +327,7 @@ int parse_disposition( str *s, struct disposition *disp)
331 327
 			disp_p->body.len = tmp - disp_p->body.s;
332 328
 			break;
333 329
 		default:
334
-			LOG(L_ERR,"ERROR:parse_disposition: wrong final state (%d)\n",
330
+			LM_ERR("wrong final state (%d)\n",
335 331
 				state);
336 332
 			goto error;
337 333
 	}
... ...
@@ -375,7 +371,7 @@ int parse_content_disposition( struct sip_msg *msg )
375 371
 		if (parse_headers(msg, HDR_CONTENTDISPOSITION_F, 0)==-1)
376 372
 			goto error;
377 373
 		if (msg->content_disposition==0) {
378
-			DBG("DEBUG:parse_content_disposition: hdr not found\n");
374
+			DBG("hdr not found\n");
379 375
 			return 1;
380 376
 		}
381 377
 	}
... ...
@@ -389,7 +385,7 @@ int parse_content_disposition( struct sip_msg *msg )
389 385
 	/* parse the body */
390 386
 	disp = (struct disposition*)pkg_malloc(sizeof(struct disposition));
391 387
 	if (disp==0) {
392
-		LOG(L_ERR,"ERROR:parse_content_disposition: no more pkg memory\n");
388
+		LM_ERR("no more pkg memory\n");
393 389
 		goto error;
394 390
 	}
395 391
 	memset(disp,0,sizeof(struct disposition));
Browse code

core parser - remove svn ID, remove history, change "ser" => "Kamailio"

Olle E. Johansson authored on 18/01/2015 19:36:18
Showing 1 changed files
... ...
@@ -1,14 +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
- * ser is distributed in the hope that it will be useful,
11
+ * Kamailio is distributed in the hope that it will be useful,
12 12
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
  * GNU General Public License for more details.
... ...
@@ -17,8 +17,6 @@
17 17
  * along with this program; if not, write to the Free Software 
18 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 19
  *
20
- * History:
21
- * 2003-09-09 created (bogdan)
22 20
  */
23 21
 
24 22
 /*! \file
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
... ...
@@ -15,7 +15,7 @@
15 15
  *
16 16
  * You should have received a copy of the GNU General Public License 
17 17
  * along with this program; if not, write to the Free Software 
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 19
  *
20 20
  * History:
21 21
  * 2003-09-09 created (bogdan)
Browse code

parser: remove old $Id$ docs header from subversion times, not usable anymore

Henning Westerholt authored on 05/07/2012 21:39:51
Showing 1 changed files
... ...
@@ -1,7 +1,4 @@
1 1
 /*
2
- * $Id$
3
- *
4
- *
5 2
  * Copyright (C) 2001-2003 FhG Fokus
6 3
  *
7 4
  * This file is part of ser, a free SIP server.
Browse code

More parser/ doxygen changes

oej authored on 25/10/2009 17:26:46
Showing 1 changed files
... ...
@@ -11,11 +11,6 @@
11 11
  * the Free Software Foundation; either version 2 of the License, or
12 12
  * (at your option) any later version
13 13
  *
14
- * For a license to use the ser software under conditions
15
- * other than those described here, or to purchase support for this
16
- * software, please contact iptel.org by e-mail at the following addresses:
17
- *    info@iptel.org
18
- *
19 14
  * ser is distributed in the hope that it will be useful,
20 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
... ...
@@ -29,6 +24,12 @@
29 24
  * 2003-09-09 created (bogdan)
30 25
  */
31 26
 
27
+/*! \file
28
+ * \brief Parser :: Content-Disposition header
29
+ *
30
+ * \ingroup parser
31
+ */
32
+
32 33
 
33 34
 #include <stdio.h>
34 35
 #include <stdlib.h>
... ...
@@ -41,7 +42,7 @@
41 42
 
42 43
 
43 44
 
44
-/* parse a string that supposed to be a disposition and fills up the structure
45
+/*! \brief parse a string that supposed to be a disposition and fills up the structure
45 46
  * Returns: -1 : error
46 47
  *           o : success */
47 48
 int parse_disposition( str *s, struct disposition *disp)
... ...
@@ -346,7 +347,7 @@ error:
346 347
 
347 348
 
348 349
 
349
-/* Frees the entire disposition structure (params + itself) */
350
+/*! \brief Frees the entire disposition structure (params + itself) */
350 351
 void free_disposition( struct disposition **disp)
351 352
 {
352 353
 	struct disposition_param *param;
... ...
@@ -363,7 +364,7 @@ void free_disposition( struct disposition **disp)
363 364
 
364 365
 
365 366
 
366
-/* looks inside the message, gets the Content-Disposition hdr, parse it, builds
367
+/*! \brief looks inside the message, gets the Content-Disposition hdr, parse it, builds
367 368
  * and fills a disposition structure for it what will be attached to hdr as
368 369
  * parsed link.
369 370
  * Returns:  -1 : error
... ...
@@ -413,7 +414,7 @@ error:
413 414
 }
414 415
 
415 416
 
416
-/* Prints recursive a disposition structure */
417
+/*! \brief Prints recursive a disposition structure */
417 418
 void print_disposition( struct disposition *disp)
418 419
 {
419 420
 	struct disposition_param *param;
Browse code

- changed parse_headers api, HDR_xxx split into HDR_xxx_F (hdr_flags_t) and HDR_xxx_T (hdr_types_t), for more info read doc/parse_headers.txt. The header flags were extended top 64 bits. Be carefull not to mix types with flags, they won't work!

Andrei Pelinescu-Onciul authored on 23/02/2005 17:16:01
Showing 1 changed files
... ...
@@ -376,7 +376,7 @@ int parse_content_disposition( struct sip_msg *msg )
376 376
 
377 377
 	/* look for Content-Disposition header */
378 378
 	if (msg->content_disposition==0) {
379
-		if (parse_headers(msg,HDR_CONTENTDISPOSITION,0)==-1)
379
+		if (parse_headers(msg, HDR_CONTENTDISPOSITION_F, 0)==-1)
380 380
 			goto error;
381 381
 		if (msg->content_disposition==0) {
382 382
 			DBG("DEBUG:parse_content_disposition: hdr not found\n");
Browse code

- Spelling checked

Jan Janak authored on 24/08/2004 09:01:24
Showing 1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
  * $Id$
3 3
  *
4 4
  *
5
- * Copyright (C) 2001-2003 Fhg Fokus
5
+ * Copyright (C) 2001-2003 FhG Fokus
6 6
  *
7 7
  * This file is part of ser, a free SIP server.
8 8
  *
... ...
@@ -43,7 +43,7 @@
43 43
 
44 44
 /* parse a string that supposed to be a disposition and fills up the structure
45 45
  * Returns: -1 : error
46
- *           o : sucess */
46
+ *           o : success */
47 47
 int parse_disposition( str *s, struct disposition *disp)
48 48
 {
49 49
 	enum { FIND_TYPE, TYPE, END_TYPE, FIND_PARAM, PARAM, END_PARAM, FIND_VAL,
... ...
@@ -364,7 +364,7 @@ void free_disposition( struct disposition **disp)
364 364
 
365 365
 
366 366
 /* looks inside the message, gets the Content-Disposition hdr, parse it, builds
367
- * and fills a disposition strucure for it what will be attached to hdr as
367
+ * and fills a disposition structure for it what will be attached to hdr as
368 368
  * parsed link.
369 369
  * Returns:  -1 : error
370 370
  *            0 : success
... ...
@@ -384,7 +384,7 @@ int parse_content_disposition( struct sip_msg *msg )
384 384
 		}
385 385
 	}
386 386
 
387
-	/* now, we have the headr -> look if it isn't already parsed */
387
+	/* now, we have the header -> look if it isn't already parsed */
388 388
 	if (msg->content_disposition->parsed!=0) {
389 389
 		/* already parsed, nothing more to be done */
390 390
 		return 0;
... ...
@@ -413,7 +413,7 @@ error:
413 413
 }
414 414
 
415 415
 
416
-/* Prints recursiv a disposition structure */
416
+/* Prints recursive a disposition structure */
417 417
 void print_disposition( struct disposition *disp)
418 418
 {
419 419
 	struct disposition_param *param;
... ...
@@ -421,7 +421,7 @@ void print_disposition( struct disposition *disp)
421 421
 	DBG("*** Disposition type=<%.*s>[%d]\n",
422 422
 		disp->type.len,disp->type.s,disp->type.len);
423 423
 	for( param=disp->params; param; param=param->next) {
424
-		DBG("*** DIsposition param: <%.*s>[%d]=<%.*s>[%d] is_quoted=%d\n",
424
+		DBG("*** Disposition param: <%.*s>[%d]=<%.*s>[%d] is_quoted=%d\n",
425 425
 			param->name.len,param->name.s, param->name.len,
426 426
 			param->body.len,param->body.s, param->body.len,
427 427
 			param->is_quoted);
Browse code

- missing "goto error" added in parse_to() - function for parsing content-disposition added; function available for searching & parsing the header and alos only for parsing a string that's a disposition; parser supports quoted values for params (along with escaped chars inside quoted strings)

Bogdan-Andrei Iancu authored on 10/09/2003 12:07:43
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,431 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ *
5
+ * Copyright (C) 2001-2003 Fhg Fokus
6
+ *
7
+ * This file is part of ser, a free SIP server.
8
+ *
9
+ * ser is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation; either version 2 of the License, or
12
+ * (at your option) any later version
13
+ *
14
+ * For a license to use the ser software under conditions
15
+ * other than those described here, or to purchase support for this
16
+ * software, please contact iptel.org by e-mail at the following addresses:
17
+ *    info@iptel.org
18
+ *
19
+ * ser is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
+ * GNU General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU General Public License 
25
+ * along with this program; if not, write to the Free Software 
26
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
+ *
28
+ * History:
29
+ * 2003-09-09 created (bogdan)
30
+ */
31
+
32
+
33
+#include <stdio.h>
34
+#include <stdlib.h>
35
+#include <sys/types.h>
36
+#include <unistd.h>
37
+#include "../mem/mem.h"
38
+#include "../dprint.h"
39
+#include "../ut.h"
40
+#include "parse_disposition.h"
41
+
42
+
43
+
44
+/* parse a string that supposed to be a disposition and fills up the structure
45
+ * Returns: -1 : error
46
+ *           o : sucess */
47
+int parse_disposition( str *s, struct disposition *disp)
48
+{
49
+	enum { FIND_TYPE, TYPE, END_TYPE, FIND_PARAM, PARAM, END_PARAM, FIND_VAL,
50
+	       FIND_QUOTED_VAL, QUOTED_VAL, SKIP_QUOTED_VAL, VAL, END_VAL,
51
+	       F_LF, F_CR, F_CRLF};
52
+	struct disposition_param *disp_p;
53
+	struct disposition_param *new_p;
54
+	int  state;
55
+	int  saved_state;
56
+	char *tmp;
57
+	char *end;
58
+
59
+	state = saved_state = FIND_TYPE;
60
+	end = s->s + s->len;
61
+	disp_p = 0;
62
+
63
+	for( tmp=s->s; tmp<end; tmp++) {
64
+		switch(*tmp) {
65
+			case ' ':
66
+			case '\t':
67
+				switch (state) {
68
+					case FIND_QUOTED_VAL:
69
+						disp_p->body.s = tmp;
70
+						state = QUOTED_VAL;
71
+						break;
72
+					case SKIP_QUOTED_VAL:
73
+						state = QUOTED_VAL;
74
+						break;
75
+					case TYPE:
76
+						disp->type.len = tmp - disp->type.s;
77
+						state = END_TYPE;
78
+						break;
79
+					case PARAM:
80
+						disp_p->name.len = tmp - disp_p->name.s;
81
+						state = END_PARAM;
82
+						break;
83
+					case VAL:
84
+						disp_p->body.len = tmp - disp_p->body.s;
85
+						state = END_VAL;
86
+						break;
87
+					case F_CRLF:
88
+					case F_LF:
89
+					case F_CR:
90
+						/*previous=crlf and now =' '*/
91
+						state=saved_state;
92
+						break;
93
+				}
94
+				break;
95
+			case '\n':
96
+				switch (state) {
97
+					case TYPE:
98
+						disp->type.len = tmp - disp->type.s;
99
+						saved_state = END_TYPE;
100
+						state = F_LF;
101
+						break;
102
+					case PARAM:
103
+						disp_p->name.len = tmp - disp_p->name.s;
104
+						saved_state = END_PARAM;
105
+						state = F_LF;
106
+						break;
107
+					case VAL:
108
+						disp_p->body.len = tmp - disp_p->body.s;
109
+						saved_state = END_VAL;
110
+						state = F_CR;
111
+						break;
112
+					case FIND_TYPE:
113
+					case FIND_PARAM:
114
+						saved_state=state;
115
+						state=F_LF;
116
+						break;
117
+					case F_CR:
118
+						state=F_CRLF;
119
+						break;
120
+					default:
121
+						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
122
+							"char [%c] in status %d: <<%.*s>> .\n",
123
+							*tmp,state, (int)(tmp-s->s), s->s);
124
+						goto error;
125
+				}
126
+				break;
127
+			case '\r':
128
+				switch (state) {
129
+					case TYPE:
130
+						disp->type.len = tmp - disp->type.s;
131
+						saved_state = END_TYPE;
132
+						state = F_CR;
133
+						break;
134
+					case PARAM:
135
+						disp_p->name.len = tmp - disp_p->name.s;
136
+						saved_state = END_PARAM;
137
+						state = F_CR;
138
+						break;
139
+					case VAL:
140
+						disp_p->body.len = tmp - disp_p->body.s;
141
+						saved_state = END_VAL;
142
+						state = F_CR;
143
+						break;
144
+					case FIND_TYPE:
145
+					case FIND_PARAM:
146
+						saved_state=state;
147
+						state=F_CR;
148
+						break;
149
+					default:
150
+						LOG(L_ERR,"ERROR:parse_disposition: unexpected "
151
+							"char [%c] in status %d: <<%.*s>> .\n",
152
+							*tmp,state, (int)(tmp-s->s), ZSW(s->s));
153
+						goto error;
154
+				}
155
+				break;
156
+			case 0:
157
+				LOG(L_ERR,"ERROR:parse_disposition: unexpected "
158
+					"char [%c] in status %d: <<%.*s>> .\n",
159
+					*tmp,state, (int)(tmp-s->s), ZSW(s->s));
160
+				goto error;
161
+				break;
162
+			case ';':
163
+				switch (state) {
164
+					case FIND_QUOTED_VAL:
165
+						disp_p->body.s = tmp;
166
+						state = QUOTED_VAL;
167
+						break;
168
+					case SKIP_QUOTED_VAL:
169
+						state = QUOTED_VAL;
170
+					case QUOTED_VAL:
171
+						break;
172
+					case VAL:
173
+						disp_p->body.len = tmp - disp_p->body.s;
174
+						state = FIND_PARAM;
175
+						break;
176
+					case PARAM:
177
+						disp_p->name.len = tmp - disp_p->name.s;
178
+						state = FIND_PARAM;
179
+						break;
180
+					case TYPE:
181
+						disp->type.len = tmp - disp->type.s;
182
+					case END_TYPE:
183
+					case END_VAL:
184
+						state = FIND_PARAM;
185
+						break;