Browse code

- update TODO - added test files for the new automaton based parsing (work in progress)

Andrei Pelinescu-Onciul authored on 02/11/2001 21:22:24
Showing 3 changed files
... ...
@@ -5,6 +5,7 @@ $Id$
5 5
 - better Via parsing (handle ' ' in uri, eg: foo.bar : 1234 ; received=) and
6 6
  ipv6 addresses ([fec0:aa::01]).
7 7
 - fix format string vulnerability in log()
8
+- fix alignement access problems (warning on Sun)
8 9
 
9 10
 High priority:
10 11
 x if () {} else {}
11 12
new file mode 100644
... ...
@@ -0,0 +1,418 @@
0
+
1
+/* test program -> switch speed */
2
+
3
+
4
+/* parsing:           compact form:
5
+ * Via:               v:
6
+ * From:              f:
7
+ * To:                t:
8
+ * Cseq:              n/a
9
+ * Call-ID:           i:
10
+ * Contact:           m:
11
+ * Max-Forwards:      n/a
12
+ * Route:             n/a
13
+ */
14
+
15
+enum { INITIAL=0,
16
+		VIA1, VIA2,
17
+		FROM1, FROM2, FROM3,
18
+		TO1,
19
+		C_START, CSEQ2, CSEQ3,
20
+		         CALLID2, CALLID3, CALLID4, CALLID5, CALLID6,
21
+		         CONTACT2, CONTACT3, CONTACT4, CONTACT5, CONTACT6,
22
+		M_START,      MAXFORWARDS2, MAXFORWARDS3, MAXFORWARDS4, MAXFORWARDS5,
23
+		MAXFORWARDS6, MAXFORWARDS7, MAXFORWARDS8, MAXFORWARDS9, MAXFORWARDS10,
24
+		MAXFORWARDS11,
25
+		ROUTE1, ROUTE2, ROUTE3, ROUTE4,
26
+		/* final states*/
27
+		F_VIA=1000, F_FROM, F_TO, F_CSEQ, F_CALLID, F_CONTACT, F_MAXFORWARDS,
28
+		F_ROUTE,
29
+		I_START,
30
+
31
+		UNKNOWN_HEADER=200,
32
+		BODY=220,
33
+		LF=25000,
34
+	};
35
+
36
+#include <stdio.h>
37
+
38
+int main(int argc, char** argv)
39
+{
40
+
41
+	char* t;
42
+	register int state;
43
+	int i;
44
+	int err;
45
+	err=0;
46
+
47
+	state=INITIAL;
48
+	printf(" %s (%d)\n", argv[0], argc);
49
+	if (argc<2){
50
+			fprintf(stderr, " no parameters\n");
51
+			exit(-1);
52
+	}
53
+	
54
+	for (i=0;i<10000000;i++){
55
+		
56
+	for(t=argv[1];*t;t++){
57
+		switch(*t){
58
+			case 'V':
59
+			case 'v':
60
+					switch(state){
61
+						case INITIAL:
62
+							state=VIA1;
63
+							break;
64
+						case UNKNOWN_HEADER: break;
65
+						default:
66
+							state=UNKNOWN_HEADER;
67
+					}
68
+					break;
69
+			case 'I':
70
+			case 'i':
71
+					switch(state){
72
+						case VIA1:
73
+							state=VIA2;
74
+							break;
75
+						case CALLID5:
76
+							state=CALLID6;
77
+							break;
78
+						case INITIAL:
79
+							state=I_START;
80
+							break;
81
+						case UNKNOWN_HEADER: break;
82
+						default:
83
+							state=UNKNOWN_HEADER;
84
+					}
85
+					break;
86
+			case 'A':
87
+			case 'a':
88
+					switch(state){
89
+						case VIA2:
90
+								state=F_VIA;
91
+								break;
92
+						case C_START:  /*CALLID1*/
93
+								state=CALLID2;
94
+								break;
95
+						case CONTACT4:
96
+								state=CONTACT5;
97
+								break;
98
+						case M_START:
99
+								state=MAXFORWARDS2;
100
+								break;
101
+						case MAXFORWARDS8:
102
+								state=MAXFORWARDS9;
103
+								break;
104
+						case UNKNOWN_HEADER: break;
105
+						default:
106
+								state=UNKNOWN_HEADER;
107
+					}
108
+					break;
109
+			case 'F':
110
+			case 'f':
111
+					switch(state){
112
+						case INITIAL:
113
+								state=FROM1;
114
+								break;
115
+						case MAXFORWARDS4:
116
+								state=MAXFORWARDS5;
117
+								break;
118
+						case UNKNOWN_HEADER: break;
119
+						default:
120
+								state=UNKNOWN_HEADER;
121
+					}
122
+					break;
123
+			case 'R':
124
+			case 'r':
125
+					switch(state){
126
+						case INITIAL:
127
+							state=ROUTE1;
128
+							break;
129
+						case FROM1:
130
+							state=FROM2;
131
+							break;
132
+						case MAXFORWARDS6:
133
+							state=MAXFORWARDS7;
134
+							break;
135
+						case MAXFORWARDS9:
136
+							state=MAXFORWARDS10;
137
+							break;
138
+						case UNKNOWN_HEADER: break;
139
+						default:
140
+							state=UNKNOWN_HEADER;
141
+					}
142
+					break;
143
+			case 'O':
144
+			case 'o':
145
+					switch(state){
146
+						case FROM2:
147
+							state=FROM3;
148
+							break;
149
+						case TO1:
150
+							state=F_TO;
151
+							break;
152
+						case C_START: /*CONTACT1 */
153
+							state=CONTACT2;
154
+							break;
155
+						case ROUTE1:
156
+							state=ROUTE2;
157
+							break;
158
+						case MAXFORWARDS5:
159
+							state=MAXFORWARDS6;
160
+							break;
161
+						case UNKNOWN_HEADER: break;
162
+						default:
163
+							state=UNKNOWN_HEADER;
164
+					}
165
+					break;
166
+			case 'M':
167
+			case 'm':
168
+						switch(state){
169
+							case INITIAL:
170
+								state=M_START;
171
+								break;
172
+							case FROM3:
173
+								state=F_FROM;
174
+								break;
175
+							case UNKNOWN_HEADER: break;
176
+							default:
177
+								state=UNKNOWN_HEADER;
178
+						}
179
+						break;
180
+			case 'T':
181
+			case 't':
182
+						switch(state){
183
+							case INITIAL:
184
+								state=TO1;
185
+								break;
186
+							case CONTACT3:
187
+								state=CONTACT4;
188
+								break;
189
+							case CONTACT6:
190
+								state=F_CONTACT;
191
+								break;
192
+							case ROUTE3:
193
+								state=ROUTE4;
194
+								break;
195
+							case UNKNOWN_HEADER: break;
196
+							default:
197
+								state=UNKNOWN_HEADER;
198
+						}
199
+						break;
200
+			case 'C':
201
+			case 'c':
202
+						switch(state){
203
+							case INITIAL:
204
+								state=C_START;
205
+								break;
206
+							case CONTACT5:
207
+								state=CONTACT6;
208
+								break;
209
+							case UNKNOWN_HEADER: break;
210
+							default:
211
+								state=UNKNOWN_HEADER;
212
+						}
213
+						break;
214
+			case 'S':
215
+			case 's':
216
+						switch(state){
217
+							case C_START:
218
+								state=CSEQ2;
219
+								break;
220
+							case MAXFORWARDS11:
221
+								state=F_MAXFORWARDS;
222
+								break;
223
+							case UNKNOWN_HEADER: break;
224
+							default:
225
+								state=UNKNOWN_HEADER;
226
+						}
227
+						break;
228
+			case 'E':
229
+			case 'e':
230
+						switch(state){
231
+							case CSEQ2:
232
+								state=CSEQ3;
233
+								break;
234
+							case ROUTE4:
235
+								state=F_ROUTE;
236
+								break;
237
+							case UNKNOWN_HEADER: break;
238
+							default:
239
+								state=UNKNOWN_HEADER;
240
+						}
241
+						break;
242
+			case 'Q':
243
+			case 'q':
244
+						switch(state){
245
+							case CSEQ3:
246
+								state=F_CSEQ;
247
+								break;
248
+							case UNKNOWN_HEADER: break;
249
+							default:
250
+								state=UNKNOWN_HEADER;
251
+						}
252
+						break;
253
+			case 'L':
254
+			case 'l':
255
+						switch(state){
256
+							case CALLID2:
257
+								state=CALLID3;
258
+								break;
259
+							case CALLID3:
260
+								state=CALLID4;
261
+								break;
262
+							case UNKNOWN_HEADER: break;
263
+							default:
264
+								state=UNKNOWN_HEADER;
265
+						}
266
+						break;
267
+			case 'D':
268
+			case 'd':
269
+						switch(state){
270
+							case CALLID6:
271
+								state=F_CALLID;
272
+								break;
273
+							case MAXFORWARDS10:
274
+								state=MAXFORWARDS11;
275
+								break;
276
+							case UNKNOWN_HEADER: break;
277
+							default:
278
+								state=UNKNOWN_HEADER;
279
+						}
280
+						break;
281
+			case 'N':
282
+			case 'n':
283
+						switch(state){
284
+							case CONTACT2:
285
+								state=CONTACT3;
286
+								break;
287
+							case UNKNOWN_HEADER: break;
288
+							default:
289
+								state=UNKNOWN_HEADER;
290
+						}
291
+						break;
292
+			case 'X':
293
+			case 'x':
294
+						switch(state){
295
+							case MAXFORWARDS2:
296
+								state=MAXFORWARDS3;
297
+								break;
298
+							case UNKNOWN_HEADER: break;
299
+							default:
300
+								state=UNKNOWN_HEADER;
301
+						}
302
+						break;
303
+			case '-':
304
+						switch(state){
305
+							case CALLID4:
306
+								state=CALLID5;
307
+								break;
308
+							case MAXFORWARDS3:
309
+								state=MAXFORWARDS4;
310
+								break;
311
+							case UNKNOWN_HEADER: break;
312
+							default:
313
+								state=UNKNOWN_HEADER;
314
+						}
315
+						break;
316
+			case 'W':
317
+			case 'w':
318
+						switch(state){
319
+							case MAXFORWARDS7:
320
+								state=MAXFORWARDS8;
321
+								break;
322
+							case UNKNOWN_HEADER: break;
323
+							default:
324
+								state=UNKNOWN_HEADER;
325
+						}
326
+						break;
327
+			case 'U':
328
+			case 'u':
329
+						switch(state){
330
+							case ROUTE2:
331
+								state=ROUTE3;
332
+								break;
333
+							case UNKNOWN_HEADER: break;
334
+							default:
335
+								state=UNKNOWN_HEADER;
336
+						}
337
+						break;
338
+			case ' ':
339
+						switch(state){
340
+							case INITIAL:
341
+								break; /*eat space */
342
+							case F_VIA:
343
+							case F_FROM:
344
+							case F_TO:
345
+							case F_CSEQ:
346
+							case F_CALLID:
347
+							case F_CONTACT:
348
+							case F_MAXFORWARDS:
349
+							case F_ROUTE:
350
+								break; /* eat trailing space*/
351
+							case VIA1:
352
+								/*compact form: v: */
353
+								state=F_VIA;
354
+								break;
355
+							case FROM1:
356
+								/*compact form f:*/
357
+								state=F_FROM;
358
+								break;
359
+							case TO1:
360
+								/*compact form t:*/
361
+								state=F_TO;
362
+								break;
363
+							case I_START:
364
+								/*compact form i: (Call-ID)*/
365
+								state=F_CALLID;
366
+								break;
367
+							case M_START:
368
+								/*compact form m: (Contact)*/
369
+								state=F_CONTACT;
370
+								break;
371
+							case UNKNOWN_HEADER: break;
372
+							default:
373
+								state=UNKNOWN_HEADER;
374
+						}
375
+						break;
376
+			case ':':
377
+						switch(state){
378
+							case F_VIA:
379
+							case VIA1: /* compact form*/
380
+							case F_FROM:
381
+							case FROM1: /*compact form*/
382
+							case F_TO:
383
+							case TO1: /*compact form*/
384
+							case F_CSEQ:
385
+							case F_CALLID:
386
+							case I_START: /*compact form*/
387
+							case F_CONTACT:
388
+							case M_START: /*compact form*/
389
+							case F_MAXFORWARDS:
390
+							case F_ROUTE:
391
+							//	printf("found header, state=%d\n", state);
392
+								state=INITIAL; /* reset to test*/
393
+								break;
394
+							case UNKNOWN_HEADER:
395
+							default:
396
+								/*printf("found unkown header, state=%d\n", 
397
+											state);*/
398
+								err=1;
399
+								state=INITIAL;
400
+						}
401
+						break;
402
+			default:
403
+					/*fprintf(stderr, "Unexpected char <%c> encountered"
404
+										" state=%d\n", *t, state);
405
+						exit(-1);*/
406
+					state=UNKNOWN_HEADER;
407
+		}
408
+	}
409
+
410
+	} //for i
411
+	if (err) printf("Error unknown header\n");
412
+	printf("final state=%d\n", state);
413
+
414
+	exit(0);
415
+
416
+}
417
+
0 418
new file mode 100644
... ...
@@ -0,0 +1,413 @@
0
+
1
+/* test program -> via parse */
2
+
3
+
4
+/* parsing:           compact form:
5
+ */
6
+
7
+/* 
8
+ * still TODO/test:
9
+ *  - parse next via
10
+ *  - return a list of header structs
11
+ *  - '[' ']' ipv6 parsing!
12
+ *  - return list of params
13
+ *  - test ^\s...'
14
+ *  - add support for parsing via front (SIP/2.0/UDP)
15
+ */
16
+
17
+#include <stdio.h>
18
+
19
+enum{	         F_HOST,    P_HOST,
20
+		L_PORT,  F_PORT,    P_PORT,
21
+		L_PARAM, F_PARAM,   P_PARAM,
22
+		L_VIA,   F_VIA,
23
+		         F_COMMENT, P_COMMENT,
24
+				 F_CRLF,
25
+				 F_LF
26
+	};
27
+
28
+#define LOG(lev, fmt, args...) fprintf(stderr, fmt, ## args)
29
+
30
+int main(int argc, char** argv)
31
+{
32
+
33
+	char* tmp;
34
+	register int state;
35
+	int saved_state;
36
+	int c_nest;
37
+	int i;
38
+	int port;
39
+	char* host;
40
+	char* port_str;
41
+	char* param;
42
+	char* comment;
43
+	char* next_via;
44
+
45
+	host=port_str=param=comment=next_via=0;
46
+
47
+	printf(" %s (%d)\n", argv[0], argc);
48
+	if (argc<2){
49
+			fprintf(stderr, " no parameters\n");
50
+			exit(-1);
51
+	}
52
+	
53
+	
54
+	c_nest=0;
55
+	state=F_HOST;
56
+	for(tmp=argv[1];*tmp;tmp++){
57
+		switch(*tmp){
58
+			case ' ':
59
+				switch(state){
60
+					case F_HOST:/*eat the spaces*/
61
+						break;
62
+					case P_HOST:
63
+						 *tmp=0;/*mark end of host*/
64
+						 state=L_PORT;
65
+						 break;
66
+					case L_PORT: /*eat the spaces*/
67
+					case F_PORT:
68
+						break;
69
+					case P_PORT:
70
+						*tmp=0; /*end of port */
71
+						state=L_PARAM;
72
+						break;
73
+					case L_PARAM: /* eat the space */
74
+					case F_PARAM:
75
+						break;
76
+					case P_PARAM:
77
+					/*	*tmp=0;*/ /*!?end of param*/
78
+						state=L_PARAM;
79
+						break;
80
+					case L_VIA:
81
+					case F_VIA: /* eat the space */
82
+						break;
83
+					case F_COMMENT:
84
+					case P_COMMENT:
85
+						break;
86
+					case F_CRLF:
87
+					case F_LF:
88
+						/*previous=crlf and now =' '*/
89
+						state=saved_state;
90
+						break;
91
+					default:
92
+						LOG(L_CRIT,"BUG: parse_via"
93
+							" on <%c>\n",*tmp);
94
+						goto  error;
95
+				}
96
+			break;
97
+			case '\n':
98
+				switch(state){
99
+					case F_HOST:/*eat the spaces*/
100
+					case L_PORT: /*eat the spaces*/
101
+					case F_PORT:
102
+					case L_PARAM: /* eat the space */
103
+					case F_PARAM:
104
+					case F_VIA: /* eat the space */
105
+					case L_VIA:
106
+					case F_COMMENT:
107
+					case P_COMMENT:
108
+						saved_state=state;
109
+						state=F_LF;
110
+						break;
111
+					case P_HOST:
112
+						 *tmp=0;/*mark end of host*/
113
+						 saved_state=L_PORT;
114
+						 state=F_LF;
115
+						 break;
116
+					case P_PORT:
117
+						*tmp=0; /*end of port */
118
+						saved_state=L_PARAM;
119
+						state=F_LF;
120
+						break;
121
+					case P_PARAM:
122
+					/*	*tmp=0;*/ /*!?end of param*/
123
+						saved_state=L_PARAM;
124
+						state=F_LF;
125
+						break;
126
+					default:
127
+						LOG(L_CRIT,"BUG: parse_via"
128
+							" on <%c>\n",*tmp);
129
+						goto  error;
130
+				}
131
+			break;
132
+			case ':':
133
+				switch(state){
134
+					case F_HOST:
135
+						LOG(L_ERR,"ERROR:parse_via:"
136
+							" no host found\n");
137
+						goto error;
138
+					case P_HOST:
139
+						*tmp=0; /*mark  end of host*/
140
+						state=F_PORT;
141
+						break;
142
+					case L_PORT:
143
+						state=F_PORT;
144
+						break;
145
+					case P_PORT:
146
+						LOG(L_ERR, "ERROR:parse_via:"
147
+							" bad port\n");
148
+						goto error;
149
+					case L_PARAM:
150
+					case F_PARAM:
151
+					case P_PARAM:
152
+					case F_COMMENT:
153
+					case P_COMMENT:
154
+						LOG(L_ERR, "ERROR:parse_via:"
155
+						" bad char <%c> in state %d\n",
156
+							*tmp,state);
157
+						goto error;
158
+					case L_VIA:
159
+					case F_VIA:
160
+						LOG(L_ERR, "ERROR:parse_via:"
161
+						" bad char in compact via\n");
162
+						goto error;
163
+					case F_CRLF:
164
+					case F_LF:
165
+						/*previous=crlf and now !=' '*/
166
+						goto endofheader;
167
+					default:
168
+						LOG(L_CRIT,"BUG: parse_via"
169
+							" on <%c> state %d\n",
170
+							*tmp, state);
171
+						goto error;
172
+				}
173
+				break;
174
+			case ';':
175
+				switch(state){
176
+					case F_HOST:
177
+						LOG(L_ERR,"ERROR:parse_via:"
178
+							" no host found\n");
179
+						goto error;
180
+					case P_HOST:
181
+					case P_PORT:
182
+						*tmp=0; /*mark the end*/
183
+					case L_PORT:
184
+					case L_PARAM:
185
+						state=F_PARAM;
186
+						break;
187
+					case F_PORT:
188
+					case F_COMMENT:
189
+					case P_COMMENT:
190
+						LOG(L_ERR, "ERROR:parse_via:"
191
+						" bad char <%c> in state %d\n",
192
+							*tmp,state);
193
+						goto error;
194
+					case F_PARAM:
195
+						LOG(L_ERR,  "ERROR:parse_via:"
196
+							" null param?\n");
197
+						goto error;
198
+					case P_PARAM:
199
+						/*hmm next, param?*/
200
+						state=F_PARAM;
201
+						break;
202
+					case L_VIA:
203
+					case F_VIA:
204
+						LOG(L_ERR, "ERROR:parse_via:"
205
+						" bad char <%c> in next via\n",
206
+							*tmp);
207
+						goto error;
208
+					case F_CRLF:
209
+					case F_LF:
210
+						/*previous=crlf and now !=' '*/
211
+						goto endofheader;
212
+					
213
+					default:
214
+						LOG(L_CRIT,"BUG: parse_via"
215
+							" on <%c> state %d\n",
216
+							*tmp, state);
217
+						goto  error;
218
+				}
219
+			break;
220
+			case ',':
221
+				switch(state){
222
+					case F_HOST:
223
+						LOG(L_ERR,"ERROR:parse_via:"
224
+							" no host found\n");
225
+						goto error;
226
+					case P_HOST:
227
+					case P_PORT:
228
+						*tmp=0; /*mark the end*/
229
+					case L_PORT:
230
+					case L_PARAM:
231
+					case P_PARAM:
232
+					case L_VIA:
233
+						state=F_VIA;
234
+						break;
235
+					case F_PORT:
236
+					case F_PARAM:
237
+					case F_COMMENT:
238
+					case P_COMMENT:
239
+						LOG(L_ERR, "ERROR:parse_via:"
240
+						" invalid char <%c> in state"
241
+						" %d\n", *tmp,state);
242
+						goto error;
243
+					case F_VIA:
244
+						/* do  nothing,  eat ","*/
245
+						break;	
246
+					case F_CRLF:
247
+					case F_LF:
248
+						/*previous=crlf and now !=' '*/
249
+						goto endofheader;
250
+					default:
251
+						LOG(L_CRIT,"BUG: parse_via"
252
+							" on <%c> state %d\n",
253
+							*tmp, state);
254
+						goto  error;
255
+				}
256
+			break;
257
+			case '(':
258
+				switch(state){
259
+					case F_HOST:
260
+					case F_PORT:
261
+					case F_PARAM:
262
+					case F_VIA:
263
+						LOG(_ERR,"ERROR:parse_via"
264
+							" on <%c> state %d\n",
265
+							*tmp, state);
266
+						goto  error;
267
+					case P_HOST:
268
+					case P_PORT:
269
+					case P_PARAM:
270
+						*tmp=0; /*mark the end*/
271
+					case L_PORT:
272
+					case L_PARAM:
273
+					case L_VIA:
274
+						state=F_COMMENT;
275
+						c_nest++;
276
+						printf("found '(', state=%d, c_nest=%d\n",
277
+								state, c_nest);
278
+						*tmp=0;
279
+						break;
280
+					case P_COMMENT:
281
+					case F_COMMENT:
282
+						c_nest++;
283
+						break;
284
+					case F_CRLF:
285
+					case F_LF:
286
+						/*previous=crlf and now !=' '*/
287
+						goto endofheader;
288
+					default:
289
+						LOG(L_CRIT,"BUG: parse_via"
290
+							" on <%c> state %d\n",
291
+							*tmp, state);
292
+						goto  error;
293
+				}
294
+			break;
295
+			case ')':
296
+				switch(state){
297
+					case F_COMMENT:
298
+					case P_COMMENT:
299
+						if (c_nest){
300
+							c_nest--;
301
+							if(c_nest==0){
302
+								state=L_VIA;
303
+								*tmp=0;
304
+								printf("out of comment\n");
305
+								break;
306
+							}
307
+						}else{
308
+							LOG(L_ERR,"ERROR:"
309
+							    "parse_via: "
310
+							    "missing '(' - "
311
+							    "nesting = %d\n",
312
+							    c_nest);
313
+							 goto error;
314
+						}
315
+						break;
316
+					case F_HOST:
317
+					case F_PORT:
318
+					case F_PARAM:
319
+					case F_VIA:
320
+					case P_HOST:
321
+					case P_PORT:
322
+					case P_PARAM:
323
+					case L_PORT:
324
+					case L_PARAM:
325
+					case L_VIA:
326
+						LOG(L_ERR,"ERROR:parse_via"
327
+							" on <%c> state %d\n",
328
+							*tmp, state);
329
+						goto  error;
330
+					case F_CRLF:
331
+					case F_LF:
332
+						/*previous=crlf and now !=' '*/
333
+						goto endofheader;
334
+					default:
335
+						LOG(L_CRIT,"BUG: parse_via"
336
+							" on <%c> state %d\n",
337
+							*tmp, state);
338
+						goto  error;
339
+				}
340
+				break;
341
+			default:
342
+				switch(state){
343
+					case F_HOST:
344
+						state=P_HOST;
345
+						host=tmp;
346
+						break;
347
+					case P_HOST:
348
+						break;
349
+					case F_PORT:
350
+						state=P_PORT;
351
+						port_str=tmp;
352
+						break;
353
+					case P_PORT:
354
+						/*check if number?*/
355
+						break;
356
+					case F_PARAM:
357
+						state=P_PARAM;
358
+						param=tmp;
359
+						break;
360
+					case P_PARAM:
361
+						break;
362
+					case F_VIA:
363
+						next_via=tmp;
364
+						printf("found new via on <%c>\n", *tmp);
365
+						goto skip;
366
+					case L_PORT:
367
+					case L_PARAM:
368
+					case L_VIA:
369
+						LOG(L_ERR,"ERROR:parse_via"
370
+							" on <%c> state %d (default)\n",
371
+							*tmp, state);
372
+						goto  error;
373
+					case F_COMMENT:
374
+						printf("starting comment parsing on %c \n",*tmp);
375
+						state=P_COMMENT;
376
+						comment=tmp;
377
+						break;
378
+					case P_COMMENT:
379
+						break;
380
+					case F_CRLF:
381
+					case F_LF:
382
+						/*previous=crlf and now !=' '*/
383
+						goto endofheader;
384
+					default:
385
+						LOG(L_ERR, "BUG:parse_via:"
386
+							" invalid char <%c>"
387
+							" in state %d\n",
388
+							*tmp, state);
389
+						goto error;
390
+				}
391
+				
392
+					
393
+		}			
394
+	}
395
+goto endofheader;
396
+error:
397
+	fprintf(stderr, "error\n");
398
+	
399
+skip:
400
+	printf("skipping\n");
401
+endofheader:
402
+	printf("end of header reached, state=%d\n", state);
403
+	if (host) printf("host=%s\n", host);
404
+	if (port) printf("port=%s\n", port_str);
405
+	if (param) printf("params=%s\n", param);
406
+	if (comment) printf("comment=%s\n", comment);
407
+	if(next_via) printf("next_via=%s\n", next_via);
408
+	printf("rest=<%s>\n", tmp);
409
+	
410
+	exit(0);
411
+}
412
+