Browse Source

#define clean-up

Jiri Kuthan 24 years ago
parent
commit
7db4ee8d3b
8 changed files with 8 additions and 265 deletions
  1. 5 10
      Makefile
  2. 1 1
      debug.gdb
  3. 2 16
      main.c
  4. 0 151
      msg_parser.c
  5. 0 9
      msg_parser.h
  6. 0 2
      parse_via.c
  7. 0 57
      parser_f.c
  8. 0 19
      parser_f.h

+ 5 - 10
Makefile

@@ -16,17 +16,12 @@ modules=$(filter-out $(addprefix modules/, $(exclude_modules)), \
 NAME=ser
 NAME=ser
 
 
 # compile-time options
 # compile-time options
-# NOCR disables seeking for CRs -- breaks standard but is fast
-# recommended: on (speed-up, no implementation really sends CR)
-# MACROEATER replaces frequently called parser helper functions
-# with macros
-# recommanded: on (speed-up)
+# 
 # STATS allows to print out number of packets processed on CTRL-C; 
 # STATS allows to print out number of packets processed on CTRL-C; 
 # implementation still nasty and reports per-process
 # implementation still nasty and reports per-process
 # NO_DEBUG turns off some of the debug messages (DBG(...)).
 # NO_DEBUG turns off some of the debug messages (DBG(...)).
 # NO_LOG completely turns of all the logging (and DBG(...))
 # NO_LOG completely turns of all the logging (and DBG(...))
 # DEBUG compiles in some extra debugging code
 # DEBUG compiles in some extra debugging code
-# OLD_PARSER uses the old and stable parser (from ser 8.3.2)
 # DNS_IP_HACK faster ip address resolver for ip strings (e.g "127.0.0.1")
 # DNS_IP_HACK faster ip address resolver for ip strings (e.g "127.0.0.1")
 # SHM_MEM    compiles in shared mem. support, needed by some modules and
 # SHM_MEM    compiles in shared mem. support, needed by some modules and
 #            by USE_SHM_MEM
 #            by USE_SHM_MEM
@@ -48,8 +43,8 @@ DEFS=-DTHREAD -DNOCR -DMACROEATER -DDNS_IP_HACK  -DSHM_MEM \
 #-DNO_LOG
 #-DNO_LOG
 
 
 PROFILE=  # -pg #set this if you want profiling
 PROFILE=  # -pg #set this if you want profiling
-#mode = debug
-mode = release
+mode = debug
+#mode = release
 
 
 # platform dependent settings
 # platform dependent settings
 
 
@@ -60,10 +55,10 @@ CC=gcc
 LD=gcc
 LD=gcc
 
 
 ifeq ($(mode), release)
 ifeq ($(mode), release)
-	CFLAGS=-O2 -Wcast-align $(PROFILE) -Winline#-Wmissing-prototypes 
+	CFLAGS=-O2 -fPIC -DPIC -Wcast-align $(PROFILE) -Winline#-Wmissing-prototypes 
 	LDFLAGS=-Wl,-O2 -Wl,-E $(PROFILE)
 	LDFLAGS=-Wl,-O2 -Wl,-E $(PROFILE)
 else
 else
-	CFLAGS=-g -Wcast-align -Winline
+	CFLAGS=-g -fPIC -DPIC -Wcast-align -Winline
 	LDFLAGS=-g -Wl,-E
 	LDFLAGS=-g -Wl,-E
 endif
 endif
 
 

+ 1 - 1
debug.gdb

@@ -1,5 +1,5 @@
 file ./ser
 file ./ser
-set args -f t_debug.cfg
+set args -f td.cfg
 break main
 break main
 #break dump_all_statistic
 #break dump_all_statistic
 #break lock_initialize
 #break lock_initialize

+ 2 - 16
main.c

@@ -43,19 +43,8 @@
 
 
 static char id[]="@(#) $Id$";
 static char id[]="@(#) $Id$";
 static char version[]="ser 0.8.3.9";
 static char version[]="ser 0.8.3.9";
-static char flags[]="NOCR:"
-#ifdef NOCR
-"On"
-#else
-"Off"
-#endif
-", MACROEATER:"
-#ifdef MACROEATER
-"On"
-#else
-"Off"
-#endif
-", STATS:"
+static char flags[]=
+"STATS:"
 #ifdef STATS
 #ifdef STATS
 "On"
 "On"
 #else
 #else
@@ -70,9 +59,6 @@ static char flags[]="NOCR:"
 #ifdef DEBUG
 #ifdef DEBUG
 ", DEBUG"
 ", DEBUG"
 #endif
 #endif
-#ifdef OLD_PARSER
-", OLD_PARSER"
-#endif
 #ifdef DNS_IP_HACK
 #ifdef DNS_IP_HACK
 ", DNS_IP_HACK"
 ", DNS_IP_HACK"
 #endif
 #endif

+ 0 - 151
msg_parser.c

@@ -517,157 +517,6 @@ error:
 }
 }
 
 
 
 
-#ifdef OLD_PARSER
-/* parses a via body, returns next via (for compact vias) & fills vb,
- * the buffer should be null terminated! */
-char* parse_via_body(char* buffer,unsigned int len, struct via_body * vb)
-{
-	/* format: sent-proto sent-by  *(";" params) [comment] 
-
-	           sent-proto = name"/"version"/"transport
-		   sent-by    = host [":" port]
-		   
-	*/
-
-	char* tmp;
-	char *name,*version, *transport, *comment, *params, *hostport;
-	int name_len, version_len, transport_len, comment_len, params_len;
-	char * next_via;
-	str host;
-	short int port;
-	int offset;
-	
-
-	name=version=transport=comment=params=hostport=next_via=host.s=0;
-	name_len=version_len=transport_len=comment_len=params_len=host.len=0;
-	name=eat_space_end(buffer, buffer+len);
-	if (name-buffer==len) goto error;
-	offset=name-buffer;
-	tmp=name;
-
-	version=eat_token2_end(tmp,tmp+len-offset,'/');
-	if (version+1-buffer>=len) goto error;
-	*version=0;
-	name_len=version-name;
-	version++;
-	offset+=version-tmp;
-	
-	transport=eat_token2_end(tmp,tmp+len-offset,'/');
-	if (transport+1-buffer>=len) goto error;
-	*transport=0;
-	version_len=transport-version;
-	transport++;
-	offset+=transport-tmp;
-	
-	tmp=eat_token_end(transport,transport+len-offset);
-	if (tmp+1-buffer>=len) goto error;
-	*tmp=0;
-	transport_len=tmp-transport;
-	tmp++;
-	offset+=tmp-transport;
-	
-	hostport=eat_space_end(tmp,tmp+len-offset);
-	if (hostport+1-buffer>=len) goto error;
-	offset+=hostport-tmp;
-
-	/* find end of hostport */
- 	for(tmp=hostport; (tmp-buffer)<len &&
-			(*tmp!=' ')&&(*tmp!=';')&&(*tmp!=','); tmp++);
-	if (tmp-buffer<len){
-		switch (*tmp){
-			case ' ':
-				*tmp=0;
-				tmp++;
-				/*the rest is comment? */
-				if (tmp-buffer<len){
-					comment=tmp;
-					/* eat the comment */
-					for(;((tmp-buffer)<len)&&
-						(*tmp!=',');tmp++);
-					/* mark end of compact via (also end of comment)*/
-					comment_len=tmp-comment;
-					if (tmp-buffer<len){
-						*tmp=0;
-					}else break;
-					/* eat space & ',' */
-					for(tmp=tmp+1;((tmp-buffer)<len)&&
-						(*tmp==' '|| *tmp==',');tmp++);
-					
-				}
-				break;
-
-			case ';':
-				*tmp=0;
-				tmp++;
-				if (tmp-buffer>=len) goto error;
-				params=tmp;
-				/* eat till end, first space  or ',' */
-				for(;((tmp-buffer)<len)&&
-					(*tmp!=' '&& *tmp!=',');tmp++);
-				params_len=tmp-params;
-				if (tmp-buffer==len)  break;
-				if (*tmp==' '){
-					/* eat comment */
-					*tmp=0;
-					tmp++;
-					comment=tmp;
-					for(;((tmp-buffer)<len)&&
-						(*tmp!=',');tmp++);
-					comment_len=tmp-comment;
-					if (tmp-buffer==len)  break;
-				}
-				/* mark end of via*/
-				*tmp=0;
-				
-				/* eat space & ',' */
-				for(tmp=tmp+1;((tmp-buffer)<len)&&
-					(*tmp==' '|| *tmp==',');tmp++);
-				break;
-
-			case ',':
-				*tmp=0;
-				tmp++;
-				if (tmp-buffer<len){
-					/* eat space and ',' */
-					for(;((tmp-buffer)<len)&&
-						(*tmp==' '|| *tmp==',');
-					   tmp++);
-				}
-		}
-	}
-	/* if we are not at the end of the body => we found another compact via */
-	if (tmp-buffer<len) next_via=tmp;
-	
-	/* parse hostport */
-	parse_hostport(hostport, &host, &port);
-	vb->name.s=name;
-	vb->name.len=name_len;
-	vb->version.s=version;
-	vb->version.len=version_len;
-	vb->transport.s=transport;
-	vb->transport.len=transport_len;
-	vb->host.s=host.s;
-	vb->host.len=host.len;
-	vb->port=port;
-	vb->params.s=params;
-	vb->params.len=params_len;
-	vb->comment.s=comment;
-	vb->comment.len=comment_len;
-	vb->next=next_via;
-	vb->error=VIA_PARSE_OK;
-
-	
-	/* tmp points to end of body or to next via (if compact)*/
-	
-	return tmp;
-
-error:
-	vb->error=VIA_PARSE_ERROR;
-	return tmp;
-}
-#endif
-
-
 /* parse the headers and adds them to msg->headers and msg->to, from etc.
 /* parse the headers and adds them to msg->headers and msg->to, from etc.
  * It stops when all the headers requested in flags were parsed, on error
  * It stops when all the headers requested in flags were parsed, on error
  * (bad header) or end of headers */
  * (bad header) or end of headers */

+ 0 - 9
msg_parser.h

@@ -195,15 +195,8 @@ struct sip_uri{
 
 
 char* parse_fline(char* buffer, char* end, struct msg_start* fl);
 char* parse_fline(char* buffer, char* end, struct msg_start* fl);
 char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl);
 char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl);
-#ifdef OLD_PARSER 
-char* get_hdr_field(char *buffer, unsigned int len, struct hdr_field*  hdr_f);
-int field_name(char *s, int len);
-#endif
 char* parse_hostport(char* buf, str* host, short int* port);
 char* parse_hostport(char* buf, str* host, short int* port);
 
 
-#ifdef OLD_PARSER 
-char* parse_via_body(char* buffer,unsigned int len, struct via_body * vb);
-#endif
 int parse_msg(char* buf, unsigned int len, struct sip_msg* msg);
 int parse_msg(char* buf, unsigned int len, struct sip_msg* msg);
 int parse_uri(char *buf, int len, struct sip_uri* uri);
 int parse_uri(char *buf, int len, struct sip_uri* uri);
 int parse_headers(struct sip_msg* msg, int flags);
 int parse_headers(struct sip_msg* msg, int flags);
@@ -211,11 +204,9 @@ int parse_headers(struct sip_msg* msg, int flags);
 void free_uri(struct sip_uri* u);
 void free_uri(struct sip_uri* u);
 
 
 
 
-#ifndef OLD_PARSER
 char* parse_hname(char* buf, char* end, struct hdr_field* hdr);
 char* parse_hname(char* buf, char* end, struct hdr_field* hdr);
 char* parse_via(char* buffer, char* end, struct via_body *vb);
 char* parse_via(char* buffer, char* end, struct via_body *vb);
 char* parse_cseq(char* buffer, char* end, struct cseq_body *cb);
 char* parse_cseq(char* buffer, char* end, struct cseq_body *cb);
-#endif
 
 
 void free_via_param_list(struct via_param *vp);
 void free_via_param_list(struct via_param *vp);
 void free_via_list(struct via_body *vb);
 void free_via_list(struct via_body *vb);

+ 0 - 2
parse_via.c

@@ -16,7 +16,6 @@
  */
  */
 
 
 
 
-#ifndef OLD_PARSER
 
 
 #include <stdlib.h>
 #include <stdlib.h>
 #include "dprint.h"
 #include "dprint.h"
@@ -1736,4 +1735,3 @@ error:
 }
 }
 
 
 
 
-#endif

+ 0 - 57
parser_f.c

@@ -17,69 +17,12 @@ char* eat_line(char* buffer, unsigned int len)
 	/* jku .. replace for search with a library function; not conformant
 	/* jku .. replace for search with a library function; not conformant
  		  as I do not care about CR
  		  as I do not care about CR
 	*/
 	*/
-#ifdef NOCR
 	nl=(char *)q_memchr( buffer, '\n', len );
 	nl=(char *)q_memchr( buffer, '\n', len );
 	if ( nl ) { 
 	if ( nl ) { 
 		c=* nl;
 		c=* nl;
 		if ( nl + 1 < buffer+len)  nl++;
 		if ( nl + 1 < buffer+len)  nl++;
 		if (( nl+1<buffer+len) && * nl=='\r')  nl++;
 		if (( nl+1<buffer+len) && * nl=='\r')  nl++;
 	} else  nl=buffer+len;
 	} else  nl=buffer+len;
-#else
-	for(nl=buffer;(nl<buffer+len)&& (*nl!='\r')&&(*nl!='\n') ;nl++);
-	c=*nl;
-	if (nl+1<buffer+len)  nl++;
-	if ((nl+1<buffer+len) &&
-			((c=='\r' && *nl=='\n')|| (c=='\n' && *nl=='\r'))) 
-		nl++;
-#endif
-	
-	/* end of jku */
 	return nl;
 	return nl;
 }
 }
 
 
-
-
-/* returns pointer to first non  white char or after the end  of the buffer */
-
-/* MACROEATER no more optional */
-
-/*
-#ifndef MACROEATER
-
-char* eat_space(char* buffer, unsigned int len)
-{
-	char* p;
-
-	for(p=buffer;(p<buffer+len)&& (*p==' ' || *p=='\t') ;p++);
-	return p;
-}
-
-
-// returns pointer after the token (first whitespace char or CR/LF) 
-char* eat_token(char* buffer, unsigned int len)
-{
-	char *p;
-
-	for (p=buffer;(p<buffer+len)&&
-			(*p!=' ')&&(*p!='\t')&&(*p!='\n')&&(*p!='\r');
-		p++);
-	return p;
-}
-
-
-
-// returns pointer after the token (first delim char or CR/LF)
-char* eat_token2(char* buffer, unsigned int len, char delim)
-{
-	char *p;
-
-	for (p=buffer;(p<buffer+len)&&
-			(*p!=delim)&&(*p!='\n')&&(*p!='\r');
-		p++);
-	return p;
-}
-#endif
-*/
-
-/* EoMACROEATER */
-

+ 0 - 19
parser_f.h

@@ -7,13 +7,6 @@
 
 
 char* eat_line(char* buffer, unsigned int len);
 char* eat_line(char* buffer, unsigned int len);
 
 
-/* macro now
-int is_empty(char* buffer, unsigned int len);
-*/
-
-/* MACROEATER no more optional */
-/* #ifdef MACROEATER */
-
 /* turn the most frequently called functions into macros */
 /* turn the most frequently called functions into macros */
 
 
 
 
@@ -50,16 +43,4 @@ int is_empty(char* buffer, unsigned int len);
   } )
   } )
 
 
 
 
-/*
-#else
-
-
-char* eat_space(char* buffer, unsigned int len);
-char* eat_token(char* buffer, unsigned int len);
-char* eat_token2(char* buffer, unsigned int len, char delim);
-
-#endif
-*/
-/* EoMACROEATER */
-
 #endif
 #endif