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