Browse code

#define clean-up

Jiri Kuthan authored on 05/12/2001 23:00:08
Showing 8 changed files
... ...
@@ -16,17 +16,12 @@ modules=$(filter-out $(addprefix modules/, $(exclude_modules)), \
16 16
 NAME=ser
17 17
 
18 18
 # compile-time options
19
-# NOCR disables seeking for CRs -- breaks standard but is fast
20
-# recommended: on (speed-up, no implementation really sends CR)
21
-# MACROEATER replaces frequently called parser helper functions
22
-# with macros
23
-# recommanded: on (speed-up)
19
+# 
24 20
 # STATS allows to print out number of packets processed on CTRL-C; 
25 21
 # implementation still nasty and reports per-process
26 22
 # NO_DEBUG turns off some of the debug messages (DBG(...)).
27 23
 # NO_LOG completely turns of all the logging (and DBG(...))
28 24
 # DEBUG compiles in some extra debugging code
29
-# OLD_PARSER uses the old and stable parser (from ser 8.3.2)
30 25
 # DNS_IP_HACK faster ip address resolver for ip strings (e.g "127.0.0.1")
31 26
 # SHM_MEM    compiles in shared mem. support, needed by some modules and
32 27
 #            by USE_SHM_MEM
... ...
@@ -48,8 +43,8 @@ DEFS=-DTHREAD -DNOCR -DMACROEATER -DDNS_IP_HACK  -DSHM_MEM \
48 43
 #-DNO_LOG
49 44
 
50 45
 PROFILE=  # -pg #set this if you want profiling
51
-#mode = debug
52
-mode = release
46
+mode = debug
47
+#mode = release
53 48
 
54 49
 # platform dependent settings
55 50
 
... ...
@@ -60,10 +55,10 @@ CC=gcc
60 55
 LD=gcc
61 56
 
62 57
 ifeq ($(mode), release)
63
-	CFLAGS=-O2 -Wcast-align $(PROFILE) -Winline#-Wmissing-prototypes 
58
+	CFLAGS=-O2 -fPIC -DPIC -Wcast-align $(PROFILE) -Winline#-Wmissing-prototypes 
64 59
 	LDFLAGS=-Wl,-O2 -Wl,-E $(PROFILE)
65 60
 else
66
-	CFLAGS=-g -Wcast-align -Winline
61
+	CFLAGS=-g -fPIC -DPIC -Wcast-align -Winline
67 62
 	LDFLAGS=-g -Wl,-E
68 63
 endif
69 64
 
... ...
@@ -1,5 +1,5 @@
1 1
 file ./ser
2
-set args -f t_debug.cfg
2
+set args -f td.cfg
3 3
 break main
4 4
 #break dump_all_statistic
5 5
 #break lock_initialize
... ...
@@ -43,19 +43,8 @@
43 43
 
44 44
 static char id[]="@(#) $Id$";
45 45
 static char version[]="ser 0.8.3.9";
46
-static char flags[]="NOCR:"
47
-#ifdef NOCR
48
-"On"
49
-#else
50
-"Off"
51
-#endif
52
-", MACROEATER:"
53
-#ifdef MACROEATER
54
-"On"
55
-#else
56
-"Off"
57
-#endif
58
-", STATS:"
46
+static char flags[]=
47
+"STATS:"
59 48
 #ifdef STATS
60 49
 "On"
61 50
 #else
... ...
@@ -70,9 +59,6 @@ static char flags[]="NOCR:"
70 59
 #ifdef DEBUG
71 60
 ", DEBUG"
72 61
 #endif
73
-#ifdef OLD_PARSER
74
-", OLD_PARSER"
75
-#endif
76 62
 #ifdef DNS_IP_HACK
77 63
 ", DNS_IP_HACK"
78 64
 #endif
... ...
@@ -517,157 +517,6 @@ error:
517 517
 }
518 518
 
519 519
 
520
-#ifdef OLD_PARSER
521
-/* parses a via body, returns next via (for compact vias) & fills vb,
522
- * the buffer should be null terminated! */
523
-char* parse_via_body(char* buffer,unsigned int len, struct via_body * vb)
524
-{
525
-	/* format: sent-proto sent-by  *(";" params) [comment] 
526
-
527
-	           sent-proto = name"/"version"/"transport
528
-		   sent-by    = host [":" port]
529
-		   
530
-	*/
531
-
532
-	char* tmp;
533
-	char *name,*version, *transport, *comment, *params, *hostport;
534
-	int name_len, version_len, transport_len, comment_len, params_len;
535
-	char * next_via;
536
-	str host;
537
-	short int port;
538
-	int offset;
539
-	
540
-
541
-	name=version=transport=comment=params=hostport=next_via=host.s=0;
542
-	name_len=version_len=transport_len=comment_len=params_len=host.len=0;
543
-	name=eat_space_end(buffer, buffer+len);
544
-	if (name-buffer==len) goto error;
545
-	offset=name-buffer;
546
-	tmp=name;
547
-
548
-	version=eat_token2_end(tmp,tmp+len-offset,'/');
549
-	if (version+1-buffer>=len) goto error;
550
-	*version=0;
551
-	name_len=version-name;
552
-	version++;
553
-	offset+=version-tmp;
554
-	
555
-	transport=eat_token2_end(tmp,tmp+len-offset,'/');
556
-	if (transport+1-buffer>=len) goto error;
557
-	*transport=0;
558
-	version_len=transport-version;
559
-	transport++;
560
-	offset+=transport-tmp;
561
-	
562
-	tmp=eat_token_end(transport,transport+len-offset);
563
-	if (tmp+1-buffer>=len) goto error;
564
-	*tmp=0;
565
-	transport_len=tmp-transport;
566
-	tmp++;
567
-	offset+=tmp-transport;
568
-	
569
-	hostport=eat_space_end(tmp,tmp+len-offset);
570
-	if (hostport+1-buffer>=len) goto error;
571
-	offset+=hostport-tmp;
572
-
573
-	/* find end of hostport */
574
- 	for(tmp=hostport; (tmp-buffer)<len &&
575
-			(*tmp!=' ')&&(*tmp!=';')&&(*tmp!=','); tmp++);
576
-	if (tmp-buffer<len){
577
-		switch (*tmp){
578
-			case ' ':
579
-				*tmp=0;
580
-				tmp++;
581
-				/*the rest is comment? */
582
-				if (tmp-buffer<len){
583
-					comment=tmp;
584
-					/* eat the comment */
585
-					for(;((tmp-buffer)<len)&&
586
-						(*tmp!=',');tmp++);
587
-					/* mark end of compact via (also end of comment)*/
588
-					comment_len=tmp-comment;
589
-					if (tmp-buffer<len){
590
-						*tmp=0;
591
-					}else break;
592
-					/* eat space & ',' */
593
-					for(tmp=tmp+1;((tmp-buffer)<len)&&
594
-						(*tmp==' '|| *tmp==',');tmp++);
595
-					
596
-				}
597
-				break;
598
-
599
-			case ';':
600
-				*tmp=0;
601
-				tmp++;
602
-				if (tmp-buffer>=len) goto error;
603
-				params=tmp;
604
-				/* eat till end, first space  or ',' */
605
-				for(;((tmp-buffer)<len)&&
606
-					(*tmp!=' '&& *tmp!=',');tmp++);
607
-				params_len=tmp-params;
608
-				if (tmp-buffer==len)  break;
609
-				if (*tmp==' '){
610
-					/* eat comment */
611
-					*tmp=0;
612
-					tmp++;
613
-					comment=tmp;
614
-					for(;((tmp-buffer)<len)&&
615
-						(*tmp!=',');tmp++);
616
-					comment_len=tmp-comment;
617
-					if (tmp-buffer==len)  break;
618
-				}
619
-				/* mark end of via*/
620
-				*tmp=0;
621
-				
622
-				/* eat space & ',' */
623
-				for(tmp=tmp+1;((tmp-buffer)<len)&&
624
-					(*tmp==' '|| *tmp==',');tmp++);
625
-				break;
626
-
627
-			case ',':
628
-				*tmp=0;
629
-				tmp++;
630
-				if (tmp-buffer<len){
631
-					/* eat space and ',' */
632
-					for(;((tmp-buffer)<len)&&
633
-						(*tmp==' '|| *tmp==',');
634
-					   tmp++);
635
-				}
636
-		}
637
-	}
638
-	/* if we are not at the end of the body => we found another compact via */
639
-	if (tmp-buffer<len) next_via=tmp;
640
-	
641
-	/* parse hostport */
642
-	parse_hostport(hostport, &host, &port);
643
-	vb->name.s=name;
644
-	vb->name.len=name_len;
645
-	vb->version.s=version;
646
-	vb->version.len=version_len;
647
-	vb->transport.s=transport;
648
-	vb->transport.len=transport_len;
649
-	vb->host.s=host.s;
650
-	vb->host.len=host.len;
651
-	vb->port=port;
652
-	vb->params.s=params;
653
-	vb->params.len=params_len;
654
-	vb->comment.s=comment;
655
-	vb->comment.len=comment_len;
656
-	vb->next=next_via;
657
-	vb->error=VIA_PARSE_OK;
658
-
659
-	
660
-	/* tmp points to end of body or to next via (if compact)*/
661
-	
662
-	return tmp;
663
-
664
-error:
665
-	vb->error=VIA_PARSE_ERROR;
666
-	return tmp;
667
-}
668
-#endif
669
-
670
-
671 520
 /* parse the headers and adds them to msg->headers and msg->to, from etc.
672 521
  * It stops when all the headers requested in flags were parsed, on error
673 522
  * (bad header) or end of headers */
... ...
@@ -195,15 +195,8 @@ struct sip_uri{
195 195
 
196 196
 char* parse_fline(char* buffer, char* end, struct msg_start* fl);
197 197
 char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl);
198
-#ifdef OLD_PARSER 
199
-char* get_hdr_field(char *buffer, unsigned int len, struct hdr_field*  hdr_f);
200
-int field_name(char *s, int len);
201
-#endif
202 198
 char* parse_hostport(char* buf, str* host, short int* port);
203 199
 
204
-#ifdef OLD_PARSER 
205
-char* parse_via_body(char* buffer,unsigned int len, struct via_body * vb);
206
-#endif
207 200
 int parse_msg(char* buf, unsigned int len, struct sip_msg* msg);
208 201
 int parse_uri(char *buf, int len, struct sip_uri* uri);
209 202
 int parse_headers(struct sip_msg* msg, int flags);
... ...
@@ -211,11 +204,9 @@ int parse_headers(struct sip_msg* msg, int flags);
211 204
 void free_uri(struct sip_uri* u);
212 205
 
213 206
 
214
-#ifndef OLD_PARSER
215 207
 char* parse_hname(char* buf, char* end, struct hdr_field* hdr);
216 208
 char* parse_via(char* buffer, char* end, struct via_body *vb);
217 209
 char* parse_cseq(char* buffer, char* end, struct cseq_body *cb);
218
-#endif
219 210
 
220 211
 void free_via_param_list(struct via_param *vp);
221 212
 void free_via_list(struct via_body *vb);
... ...
@@ -16,7 +16,6 @@
16 16
  */
17 17
 
18 18
 
19
-#ifndef OLD_PARSER
20 19
 
21 20
 #include <stdlib.h>
22 21
 #include "dprint.h"
... ...
@@ -1736,4 +1735,3 @@ error:
1736 1735
 }
1737 1736
 
1738 1737
 
1739
-#endif
... ...
@@ -17,69 +17,12 @@ char* eat_line(char* buffer, unsigned int len)
17 17
 	/* jku .. replace for search with a library function; not conformant
18 18
  		  as I do not care about CR
19 19
 	*/
20
-#ifdef NOCR
21 20
 	nl=(char *)q_memchr( buffer, '\n', len );
22 21
 	if ( nl ) { 
23 22
 		c=* nl;
24 23
 		if ( nl + 1 < buffer+len)  nl++;
25 24
 		if (( nl+1<buffer+len) && * nl=='\r')  nl++;
26 25
 	} else  nl=buffer+len;
27
-#else
28
-	for(nl=buffer;(nl<buffer+len)&& (*nl!='\r')&&(*nl!='\n') ;nl++);
29
-	c=*nl;
30
-	if (nl+1<buffer+len)  nl++;
31
-	if ((nl+1<buffer+len) &&
32
-			((c=='\r' && *nl=='\n')|| (c=='\n' && *nl=='\r'))) 
33
-		nl++;
34
-#endif
35
-	
36
-	/* end of jku */
37 26
 	return nl;
38 27
 }
39 28
 
40
-
41
-
42
-/* returns pointer to first non  white char or after the end  of the buffer */
43
-
44
-/* MACROEATER no more optional */
45
-
46
-/*
47
-#ifndef MACROEATER
48
-
49
-char* eat_space(char* buffer, unsigned int len)
50
-{
51
-	char* p;
52
-
53
-	for(p=buffer;(p<buffer+len)&& (*p==' ' || *p=='\t') ;p++);
54
-	return p;
55
-}
56
-
57
-
58
-// returns pointer after the token (first whitespace char or CR/LF) 
59
-char* eat_token(char* buffer, unsigned int len)
60
-{
61
-	char *p;
62
-
63
-	for (p=buffer;(p<buffer+len)&&
64
-			(*p!=' ')&&(*p!='\t')&&(*p!='\n')&&(*p!='\r');
65
-		p++);
66
-	return p;
67
-}
68
-
69
-
70
-
71
-// returns pointer after the token (first delim char or CR/LF)
72
-char* eat_token2(char* buffer, unsigned int len, char delim)
73
-{
74
-	char *p;
75
-
76
-	for (p=buffer;(p<buffer+len)&&
77
-			(*p!=delim)&&(*p!='\n')&&(*p!='\r');
78
-		p++);
79
-	return p;
80
-}
81
-#endif
82
-*/
83
-
84
-/* EoMACROEATER */
85
-
... ...
@@ -7,13 +7,6 @@
7 7
 
8 8
 char* eat_line(char* buffer, unsigned int len);
9 9
 
10
-/* macro now
11
-int is_empty(char* buffer, unsigned int len);
12
-*/
13
-
14
-/* MACROEATER no more optional */
15
-/* #ifdef MACROEATER */
16
-
17 10
 /* turn the most frequently called functions into macros */
18 11
 
19 12
 
... ...
@@ -50,16 +43,4 @@ int is_empty(char* buffer, unsigned int len);
50 43
   } )
51 44
 
52 45
 
53
-/*
54
-#else
55
-
56
-
57
-char* eat_space(char* buffer, unsigned int len);
58
-char* eat_token(char* buffer, unsigned int len);
59
-char* eat_token2(char* buffer, unsigned int len, char delim);
60
-
61
-#endif
62
-*/
63
-/* EoMACROEATER */
64
-
65 46
 #endif