Sun cc ser core support:
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 1 Mar 2002 23:21:25 +0000 (23:21 +0000)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 1 Mar 2002 23:21:25 +0000 (23:21 +0000)
- major makefile changes
- lots of warning fixed
- replaced incompatible expr-statement defines (  ({ }) ).
- special LOG, DBG, DPrint version for suncc

18 files changed:
Makefile.defs
action.c
cfg.y
dprint.h
forward.c
main.c
mem/shm_mem.c
mem/shm_mem.h
msg_parser.c
parse_fline.c
parse_to.c
parse_via.c
parser_f.h
proxy.c
sr_module.c
strs.h
udp_server.c
ut.h

index 3c2a846..0b29f08 100644 (file)
@@ -8,7 +8,7 @@
 VERSION = 0
 PATCHLEVEL = 8
 SUBLEVEL = 7
-EXTRAVERSION = -2
+EXTRAVERSION = -3-suncc
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s)
@@ -76,9 +76,12 @@ ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
 
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
         -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
-        -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
+        -DDNS_IP_HACK  -DPKG_MALLOC \
         -DF_MALLOC  -DUSE_SYNONIM\
-        -DWAIT -DNEW_HNAME -DNOISY_REPLIES -DBOGDAN_TRIFLE \
+        -DSHM_MEM  -DSHM_MMAP \
+        -DNO_DEBUG \
+        -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
+        -DWAIT -DNEW_HNAME # -DNOISY_REPLIES -DBOGDAN_TRIFLE \
         #-DNO_DEBUG \
         #-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \
         #-DNOSMP \
@@ -95,7 +98,9 @@ ifeq ($(ARCH), i386)
 endif
 
 ifeq ($(ARCH), sparc64)
-       DEFS+= -DFAST_LOCK
+ifeq   ($(CC_NAME), gcc)
+               DEFS+= -DFAST_LOCK
+endif
 endif
 
 
@@ -109,34 +114,51 @@ mode = release
 #common
 CC=gcc
 LD= $(CC)
-CC_VER= $(CC) $(shell $(CC) --version)
-CC_LONGVER=$(shell $(CC) -v 2>&1)
-MKDEP=gcc -MM $(DEFS)
+CC_LONGVER=$(shell if  $(CC) -v 2>/dev/null; then \
+                                               $(CC) -v 2>&1 ;\
+                                       else \
+                                               $(CC) -V 2>&1 ; \
+                                       fi )
 MKTAGS=ctags -R .
 
 #find-out the compiler's name
 
 ifneq (,$(findstring gcc, $(CC_LONGVER)))
        CC_NAME=gcc
+       CC_VER=$(CC) $(shell $(CC) --version)
+       MKDEP=$(CC) -MM $(DEFS)
        #transform gcc version into 2.9x or 3.0
        CC_SHORTVER=$(shell $(CC) --version | \
                                 sed -e 's/[^0-9]*-\(.*\)/\1/'| \
                                 sed -e 's/2\.9.*/2.9x/' -e 's/3\..\..*/3.0/')
-else
+endif
+
+ifneq (, $(findstring Sun, $(CC_LONGVER)))
+       CC_NAME=suncc
+       CC_SHORTVER=$(shell echo $(CC_LONGVER)|head -1| \
+                                       sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
+       CC_VER=$(CC) $(CC_SHORTVER)
+       MKDEP=$(CC) -xM1 $(DEFS)
+endif
+
+ifeq (,$(CC_NAME))
+#not found
        CC_NAME=$(CC)
        CC_SHORTVER=unknown
+       CC_VER=unknown
+       MKDEP=gcc -MM $(DEFS)
 endif
 
 
 # setting CFLAGS
 ifeq ($(mode), release)
-       #common stuff
-       CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
-                       #-Wmissing-prototypes \
        #if i386
 ifeq   ($(ARCH), i386)
                # if gcc 
 ifeq           ($(CC_NAME), gcc)
+                               #common stuff
+                               CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
+                                       #-Wmissing-prototypes \
                        #if gcc 3.0
 ifeq                   ($(CC_SHORTVER), 3.0)
                                        CFLAGS+=-minline-all-stringops -malign-double \
@@ -169,6 +191,9 @@ endif       #ARCH, i386
 ifeq   ($(ARCH), sparc64)
                        #if gcc
 ifeq           ($(CC_NAME), gcc)
+                               #common stuff
+                               CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
+                                       #-Wmissing-prototypes \
                                #if gcc 3.0
 ifeq                   ($(CC_SHORTVER), 3.0)
                                        #use 32bit for now
@@ -193,27 +218,52 @@ endif                     #CC_SHORTVER, 2.9x
 endif                  #CC_SHORTVER, 3.0
 
 else           #CC_NAME, gcc
+ifeq           ($(CC_NAME), suncc)
+                       CFLAGS+=-xO5 -fast -native -xarch=v8plusa -xCC \
+                                       -xc99 # C99 support
+                       # -Dinline="" # add this if cc < 5.3 (define inline as null)
+else
                                #other compilers
 $(error                        Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
+endif          #CC_NAME, suncc
 endif          #CC_NAME, gcc
 endif  #ARCH, sparc64
 
 
 
 # setting LDFLAGS
+ifeq   ($(CC_NAME), gcc)
+       #gcc and maybe others
        LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
+endif
+ifeq   ($(CC_NAME), suncc)
+       LDFLAGS+=-xO5 $(PROFILE)
+endif
        # we need -fPIC -DPIC only for shared objects, we don't need them for
        # the executable file, because it's always loaded at a fixed address
        # -andrei
 else   #mode,release
-       CFLAGS=-g -Wcast-align -Winline $(PROFILE)
-       LDFLAGS+=-g -Wl,-E $(PROFILE)
+ifeq   ($(CC_NAME), gcc)
+               CFLAGS=-g -Wcast-align -Winline $(PROFILE)
+               LDFLAGS+=-g -Wl,-E $(PROFILE)
+endif
+ifeq   ($(CC_NAME), suncc)
+               CFLAGS= -g $(PROFILE)
+               LDFLAGS+=-g $(PROFILE)
+endif
+
 endif #mode=release
 
 
 #*FLAGS used for compiling the modules
+ifeq   ($(CC_NAME), gcc)
 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
 MOD_LDFLAGS=-shared $(LDFLAGS)
+endif
+ifeq   ($(CC_NAME), suncc)
+MOD_CFLAGS=-Kpic  $(CFLAGS)
+MOD_LDFLAGS=-G $(LDFLAGS)
+endif
 
 LEX=flex
 YACC=bison
@@ -239,8 +289,12 @@ ifeq  ($(OS), SunOS)
        endif
 
        YACC=yacc
-       LIBS+=-L/usr/local/lib -lxnet -lrt # or -lnsl -lsocket or -lglibc ?
-       # -lrt needed for sched_yield; some systems may require -lposix4
+
+ifeq ($(CC_NAME), suncc)
+       LIBS=-lfast
+endif
+       LIBS+=-ldl -L/usr/local/lib -lfl -lxnet -lrt
+       # -lrt needed for sched_yield
 endif
 
 ifeq ($(OS), FreeBSD)
index 4b04bde..a2aeeda 100644 (file)
--- a/action.c
+++ b/action.c
@@ -71,8 +71,8 @@ int do_action(struct action* a, struct sip_msg* msg)
                                        case URIPORT_ST:
                                                                        if (uri.port.s){
                                                                         /*port=strtol(uri.port.s,&end,10);*/
-                                                                               port=str2s(uri.port.s, uri.port.len,
-                                                                                                       &err);
+                                                                               port=str2s((unsigned char*)uri.port.s, 
+                                                                                                       uri.port.len, &err);
                                                                                /*if ((end)&&(*end)){*/
                                                                                if (err){
                                                                                        LOG(L_ERR, "ERROR: do_action: "
@@ -140,7 +140,11 @@ int do_action(struct action* a, struct sip_msg* msg)
                                        p->addr_idx=0;
                                p->ok=1;
                        }
+                       memcpy(&(to->sin_addr.s_addr), p->host.h_addr_list[p->addr_idx],
+                                       sizeof(to->sin_addr.s_addr));
+                       /*
                        to->sin_addr.s_addr=*((long*)p->host.h_addr_list[p->addr_idx]);
+                       */
                        p->tx++;
                        p->tx_bytes+=msg->len;
                        ret=udp_send(msg->orig, msg->len, (struct sockaddr*)to,
diff --git a/cfg.y b/cfg.y
index 653fbd9..0eb3a73 100644 (file)
--- a/cfg.y
+++ b/cfg.y
@@ -592,7 +592,7 @@ cmd:                FORWARD LPAREN host RPAREN      { $$=mk_action( FORWARD_T,
                | SET_URI error { $$=0; yyerror("missing '(' or ')' ?"); }
                | SET_URI LPAREN error RPAREN { $$=0; yyerror("bad argument, "
                                                                                "string expected"); }
-               | ID LPAREN RPAREN                      { f_tmp=find_export($1, 0);
+               | ID LPAREN RPAREN                      { f_tmp=(void*)find_export($1, 0);
                                                                           if (f_tmp==0){
                                                                                yyerror("unknown command, missing"
                                                                                " loadmodule?\n");
@@ -606,7 +606,7 @@ cmd:                FORWARD LPAREN host RPAREN      { $$=mk_action( FORWARD_T,
                                                                                                        );
                                                                           }
                                                                        }
-               | ID LPAREN STRING RPAREN { f_tmp=find_export($1, 1);
+               | ID LPAREN STRING RPAREN { f_tmp=(void*)find_export($1, 1);
                                                                        if (f_tmp==0){
                                                                                yyerror("unknown command, missing"
                                                                                " loadmodule?\n");
@@ -621,7 +621,7 @@ cmd:                FORWARD LPAREN host RPAREN      { $$=mk_action( FORWARD_T,
                                                                        }
                                                                  }
                | ID LPAREN STRING  COMMA STRING RPAREN 
-                                                                 { f_tmp=find_export($1, 2);
+                                                                 { f_tmp=(void*)find_export($1, 2);
                                                                        if (f_tmp==0){
                                                                                yyerror("unknown command, missing"
                                                                                " loadmodule?\n");
index 763587a..8d36e2e 100644 (file)
--- a/dprint.h
+++ b/dprint.h
 void dprint (char* format, ...);
 
 #ifdef NO_DEBUG
-       #define DPrint(fmt, args...)
+       #ifdef __SUNPRO_C
+               #define DPrint(...)
+       #else
+               #define DPrint(fmt, args...)
+       #endif
 #else
-       #define DPrint(fmt,args...) \
-               do{ \
-                       if (debug>=DPRINT_LEV){ \
-                               if (log_stderr){ \
-                                       dprint (fmt, ## args); \
-                               }else{ \
-                                       syslog(DPRINT_LEV|L_FAC, fmt, ## args); \
-                               }\
-                       } \
-               }while(0)
+       #ifdef __SUNPRO_C
+               #define DPrint( ...) \
+                       do{ \
+                               if (debug>=DPRINT_LEV){ \
+                                       if (log_stderr){ \
+                                               dprint (__VA_ARGS__); \
+                                       }else{ \
+                                               syslog(DPRINT_LEV|L_FAC,  __VA_ARGS__); \
+                                       }\
+                               } \
+                       }while(0)
+       #else
+                       #define DPrint(fmt,args...) \
+                       do{ \
+                               if (debug>=DPRINT_LEV){ \
+                                       if (log_stderr){ \
+                                               dprint (fmt, ## args); \
+                                       }else{ \
+                                               syslog(DPRINT_LEV|L_FAC, fmt, ## args); \
+                                       }\
+                               } \
+                       }while(0)
+       #endif
 
 #endif
 
@@ -50,10 +67,46 @@ void dprint (char* format, ...);
 #endif
 
 #ifdef NO_LOG
-       #define LOG(lev, fmt, args...)
+       #ifdef __SUNPRO_C
+               #define LOG(lev, ...)
+       #else
+               #define LOG(lev, fmt, args...)
+       #endif
 #else
-
-       #define LOG(lev, fmt, args...) \
+       #ifdef __SUNPRO_C
+               #define LOG(lev, ...) \
+                       do { \
+                               if (debug>=(lev)){ \
+                                       if (log_stderr) dprint (__VA_ARGS__); \
+                                       else { \
+                                               switch(lev){ \
+                                                       case L_CRIT: \
+                                                               syslog(LOG_CRIT | L_FAC, __VA_ARGS__); \
+                                                               break; \
+                                                       case L_ALERT: \
+                                                               syslog(LOG_ALERT | L_FAC, __VA_ARGS__); \
+                                                               break; \
+                                                       case L_ERR: \
+                                                               syslog(LOG_ERR | L_FAC, __VA_ARGS__); \
+                                                               break; \
+                                                       case L_WARN: \
+                                                               syslog(LOG_WARNING | L_FAC, __VA_ARGS__);\
+                                                               break; \
+                                                       case L_NOTICE: \
+                                                               syslog(LOG_NOTICE | L_FAC, __VA_ARGS__); \
+                                                               break; \
+                                                       case L_INFO: \
+                                                               syslog(LOG_INFO | L_FAC, __VA_ARGS__); \
+                                                               break; \
+                                                       case L_DBG: \
+                                                               syslog(LOG_DEBUG | L_FAC, __VA_ARGS__); \
+                                                               break; \
+                                               } \
+                                       } \
+                               } \
+                       }while(0)
+       #else
+               #define LOG(lev, fmt, args...) \
                        do { \
                                if (debug>=(lev)){ \
                                        if (log_stderr) dprint (fmt, ## args); \
@@ -84,13 +137,22 @@ void dprint (char* format, ...);
                                        } \
                                } \
                        }while(0)
+       #endif /*SUN_PRO_C*/
 #endif
 
 
 #ifdef NO_DEBUG
-       #define DBG(fmt, args...)
+       #ifdef __SUNPRO_C
+               #define DBG(...)
+       #else
+               #define DBG(fmt, args...)
+       #endif
 #else
-       #define DBG(fmt, args...) LOG(L_DBG, fmt, ## args)
+       #ifdef __SUNPRO_C
+               #define DBG(...) LOG(L_DBG, __VA_ARGS__)
+       #else
+               #define DBG(fmt, args...) LOG(L_DBG, fmt, ## args)
+       #endif
 #endif
 
 #endif /* ifndef dprint_h */
index 4b6df57..d7120df 100644 (file)
--- a/forward.c
+++ b/forward.c
@@ -63,8 +63,12 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
                        p->addr_idx++;
                p->ok=1;
        }
-       /* ? not 64bit clean?*/
+       
+       memcpy(&(to->sin_addr.s_addr), p->host.h_addr_list[p->addr_idx],
+                       sizeof(to->sin_addr.s_addr));
+       /* 
        to->sin_addr.s_addr=*((long*)p->host.h_addr_list[p->addr_idx]);
+       */
 
        p->tx++;
        p->tx_bytes+=len;
@@ -98,7 +102,7 @@ int update_sock_struct_from_via( struct sockaddr_in* to,  struct via_body* via )
        to->sin_port = (via->port)?htons(via->port): htons(SIP_PORT);
 
 #ifdef DNS_IP_HACK
-       to->sin_addr.s_addr=str2ip(via->host.s, via->host.len, &err);
+       to->sin_addr.s_addr=str2ip((unsigned char*)via->host.s,via->host.len,&err);
        if (err)
 #endif
        {
@@ -109,7 +113,11 @@ int update_sock_struct_from_via( struct sockaddr_in* to,  struct via_body* via )
                                        via->host.s);
                        return -1;
                }
+               memcpy(&(to->sin_addr.s_addr), he->h_addr_list[0], 
+                               sizeof(to->sin_addr.s_addr));
+               /*
                to->sin_addr.s_addr=*((long*)he->h_addr_list[0]);
+               */
        }
        return 1;
 }
diff --git a/main.c b/main.c
index 36d0504..e2d1dac 100644 (file)
--- a/main.c
+++ b/main.c
@@ -388,7 +388,7 @@ int main_loop()
                for(;;) sleep(LONG_SLEEP);
        }
        
-       return 0;
+       /*return 0; */
  error:
        return -1;
 
@@ -748,7 +748,8 @@ int main(int argc, char** argv)
                        DPrint("ERROR: could not resolve %s\n", names[r]);
                        goto error;
                }
-               addresses[r]=*((long*)he->h_addr_list[0]);
+               memcpy(&addresses[r], he->h_addr_list[0], sizeof(int));
+               /*addresses[r]=*((long*)he->h_addr_list[0]);*/
                printf("%s [%s] : %d\n",names[r],
                                inet_ntoa(*(struct in_addr*)&addresses[r]),
                                (unsigned short)port_no);
index 17d1eaa..c26d514 100644 (file)
@@ -57,13 +57,16 @@ static void* shm_mempool=(void*)-1;
        struct qm_block* shm_block;
 #endif
 
-#define sh_realloc(_p, _size) ({ \
-               char *_c; \
-               shm_lock(); \
-               shm_free_unsafe( (_p) ); \
-               _c=shm_malloc_unsafe( (_size) ); \
-               shm_unlock(); \
-               _c; })
+
+inline static void* sh_realloc(void* p, unsigned int size)
+{
+       void *r;
+       shm_lock(); 
+       shm_free_unsafe(p);
+       r=shm_malloc_unsafe(size);
+       shm_unlock();
+       return r;
+}
 
 /* look at a buffer if there is perhaps enough space for the new size
    (It is benefitial to do so because vq_malloc is pretty stateful
@@ -83,7 +86,11 @@ void* _shm_resize( void* p , unsigned int s)
 #ifdef VQ_MALLOC
        struct vqm_frag *f;
 #else
-#      warning shm_resize performs suboptimally without VQ_MALLOC!
+       #ifdef __SUNPRO_C
+               /*no warning support on Sun cc */
+       #else
+               #warning shm_resize performs suboptimally without VQ_MALLOC!
+       #endif
 #endif
 
        if (p==0) {
@@ -214,6 +221,9 @@ void shm_mem_destroy()
 #ifndef SHM_MMAP
        struct shmid_ds shm_info;
 #endif
+#ifndef FAST_LOCK
+       union semun zero_un;
+#endif
        
        DBG("shm_mem_destroy\n");
        if (shm_mempool && (shm_mempool!=(void*)-1)) {
@@ -232,7 +242,8 @@ void shm_mem_destroy()
 #endif
 #ifndef FAST_LOCK
        if (shm_semid!=-1) {
-               semctl(shm_semid, 0, IPC_RMID, (union semun)0);
+               zero_un.val=0;
+               semctl(shm_semid, 0, IPC_RMID, zero_un);
                shm_semid=-1;
        }
 #endif
index 372cfd5..51a1866 100644 (file)
@@ -126,18 +126,24 @@ again:
 
 #define shm_malloc_unsafe(_size ) \
        MY_MALLOC(shm_block, (_size), __FILE__, __FUNCTION__, __LINE__ )
-#define shm_malloc(_size) \
-({\
-       void *p;\
-       \
+
+
+
+inline static void* shm_malloc(unsigned int size)
+{
+       void *p;
+       
        shm_lock();\
-       p=shm_malloc_unsafe( (_size) );\
-       shm_unlock();\
-       p; \
-})
+       p=shm_malloc_unsafe(size);
+       shm_unlock();
+       return p; 
+}
+
+
 
 #define shm_free_unsafe( _p  ) \
        MY_FREE( shm_block, (_p), __FILE__, __FUNCTION__, __LINE__ )
+
 #define shm_free(_p) \
 do { \
                shm_lock(); \
@@ -148,21 +154,27 @@ do { \
 #define shm_resize(_p, _s ) \
        _shm_resize( (_p), (_s),   __FILE__, __FUNCTION__, __LINE__)
 
+
+
 #else
 
+
 #define shm_malloc_unsafe(_size) MY_MALLOC(shm_block, (_size))
-#define shm_malloc(size) \
-({\
-       void *p;\
-       \
-               shm_lock();\
-               p=shm_malloc_unsafe(size); \
-               shm_unlock();\
-        p; \
-})
+
+inline static void* shm_malloc(unsigned int size)
+{
+       void *p;
+       
+       shm_lock();
+       p=shm_malloc_unsafe(size);
+       shm_unlock();
+        return p; 
+}
+
 
 
 #define shm_free_unsafe( _p ) MY_FREE(shm_block, (_p))
+
 #define shm_free(_p) \
 do { \
                shm_lock(); \
@@ -170,8 +182,11 @@ do { \
                shm_unlock(); \
 }while(0)
 
+
+
 #define shm_resize(_p, _s) _shm_resize( (_p), (_s))
 
+
 #endif
 
 
index 32b40da..29c0498 100644 (file)
@@ -324,7 +324,7 @@ char* parse_hostport(char* buf, str* host, short int* port)
                *port=0;
        }else{
                *tmp=0;
-               *port=str2s(tmp+1, strlen(tmp+1), &err);
+               *port=str2s((unsigned char*)(tmp+1), strlen(tmp+1), &err);
                if (err ){
                        LOG(L_INFO, 
                                        "ERROR: hostport: trailing chars in port number: %s\n",
index f6f7114..f3fc0be 100644 (file)
@@ -504,8 +504,6 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
                                                fl->u.request.uri.s=tmp;
                                                state=P_URI;
                                                break;
-                                               state=VER3;
-                                               break;
                                        case L_VER:
                                        case VER1:
                                        case VER2:
@@ -553,8 +551,6 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
                                                fl->u.request.uri.s=tmp;
                                                state=P_URI;
                                                break;
-                                               state=VER3;
-                                               break;
                                        case L_VER:
                                        case VER1:
                                        case VER2:
@@ -602,8 +598,6 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
                                                fl->u.request.uri.s=tmp;
                                                state=P_URI;
                                                break;
-                                               state=VER3;
-                                               break;
                                        case L_VER:
                                        case VER1:
                                        case VER2:
@@ -657,8 +651,6 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
                                                fl->u.request.uri.s=tmp;
                                                state=P_URI;
                                                break;
-                                               state=VER3;
-                                               break;
                                        case L_VER:
                                        case VER1:
                                        case VER2:
@@ -709,8 +701,6 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
                                                fl->u.request.uri.s=tmp;
                                                state=P_URI;
                                                break;
-                                               state=VER3;
-                                               break;
                                        case L_VER:
                                        case VER1:
                                        case VER2:
@@ -761,8 +751,6 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
                                                fl->u.request.uri.s=tmp;
                                                state=P_URI;
                                                break;
-                                               state=VER3;
-                                               break;
                                        case L_VER:
                                        case VER1:
                                        case VER2:
@@ -810,8 +798,6 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
                                                fl->u.request.uri.s=tmp;
                                                state=P_URI;
                                                break;
-                                               state=VER3;
-                                               break;
                                        case L_VER:
                                        case VER1:
                                        case VER2:
@@ -859,8 +845,6 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
                                                fl->u.request.uri.s=tmp;
                                                state=P_URI;
                                                break;
-                                               state=VER3;
-                                               break;
                                        case L_VER:
                                        case VER1:
                                        case VER2:
@@ -905,8 +889,6 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
                                                fl->u.request.uri.s=tmp;
                                                state=P_URI;
                                                break;
-                                               state=VER3;
-                                               break;
                                        case L_VER:
                                        case VER1:
                                        case VER2:
@@ -954,8 +936,6 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
                                                fl->u.request.uri.s=tmp;
                                                state=P_URI;
                                                break;
-                                               state=VER3;
-                                               break;
                                        case L_VER:
                                        case VER1:
                                        case VER2:
@@ -1058,8 +1038,6 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
                                                fl->u.request.uri.s=tmp;
                                                state=P_URI;
                                                break;
-                                               state=VER3;
-                                               break;
                                        case L_VER:
                                        case VER1:
                                        case VER2:
@@ -1102,8 +1080,6 @@ char* parse_fline(char* buffer, char* end, struct msg_start* fl)
                                                fl->u.request.uri.s=tmp;
                                                state=P_URI;
                                                break;
-                                               state=VER3;
-                                               break;
                                        case L_VER:
                                        case VER1:
                                        case VER2:
index 727ba20..ec10584 100644 (file)
@@ -33,7 +33,7 @@ enum{ S_PARA_NAME=20, PARA_NAME, S_EQUAL, S_PARA_VALUE, TAG1, TAG2, TAG3
 
 
 char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
-                                                               unsigned int *returned_status)
+                                                               int *returned_status)
 {
        struct to_param *param=0;
        int status =PARA_START;
index 48cf6dd..3af9b76 100644 (file)
@@ -1699,7 +1699,7 @@ endofpacket:
        vb->error=VIA_PARSE_OK;
        vb->bsize=tmp-buffer;
        if (vb->port_str.s){
-               vb->port=str2s(vb->port_str.s, vb->port_str.len, &err);
+               vb->port=str2s((unsigned char*)vb->port_str.s, vb->port_str.len, &err);
                if (err){
                                        LOG(L_ERR, "ERROR: parse_via: invalid port number <%s>\n",
                                                vb->port_str.s);
@@ -1712,7 +1712,7 @@ nextvia:
        vb->error=VIA_PARSE_OK;
        vb->bsize=tmp-buffer;
        if (vb->port_str.s){
-               vb->port=str2s(vb->port_str.s, vb->port_str.len, &err);
+               vb->port=str2s((unsigned char*)vb->port_str.s, vb->port_str.len, &err);
                if (err){
                                        LOG(L_ERR, "ERROR: parse_via: invalid port number <%s>\n",
                                                vb->port_str.s);
index afda7af..ed3dd71 100644 (file)
@@ -7,40 +7,38 @@
 
 char* eat_line(char* buffer, unsigned int len);
 
-/* turn the most frequently called functions into macros */
-
-
-#define eat_space_end(buffer,pend)                                       \
-  ( {   char *_p;                                                      \
-       char *_pe=(pend);                                               \
-        for(_p=(buffer);(_p<_pe)&& (*_p==' ' || *_p=='\t') ;_p++);             \
-        _p;                                                              \
-  } )
-
-#define eat_token_end(buffer,pend)                                     \
-  ( { char *_p       ;                                                 \
-      char *_pe=(pend);                                                \
-      for (_p=(buffer);(_p<_pe)&&                                      \
-                        (*_p!=' ')&&(*_p!='\t')&&(*_p!='\n')&&(*_p!='\r');     \
-                _p++);                                                 \
-      _p;                                                              \
-  } )
-
-#define eat_token2_end(buffer,pend,delim)                                      \
-  ( { char *_p       ;                                                 \
-      char *_pe=(pend);                                                \
-      for (_p=(buffer);(_p<_pe)&&                                      \
-                        (*_p!=(delim))&&(*_p!='\n')&&(*_p!='\r');              \
-                _p++);                                                 \
-      _p;                                                              \
-  } )
-
-#define is_empty_end(buffer, pend )                                    \
-  ( { char *_p;                                                                \
-      char *_pe=(pend);                                                \
-      _p=eat_space_end( buffer, _pe );                                 \
-      ((_p<(pend )) && (*_p=='\r' || *_p=='\n')) ? 1 : 0;                      \
-  } )
+/* turn the most frequently called functions into inline functions */
+
+
+inline static char* eat_space_end(char* p, char* pend)
+{
+       for(;(p<pend)&&(*p==' ' || *p=='\t') ;p++);
+       return p;
+}
+
+
+
+inline static char* eat_token_end(char* p, char* pend)
+{
+       for (;(p<pend)&&(*p!=' ')&&(*p!='\t')&&(*p!='\n')&&(*p!='\r'); p++);
+       return p;
+}
+
+
+
+inline static char* eat_token2_end(char* p, char* pend, char delim)
+{
+       for (;(p<pend)&&(*p!=(delim))&&(*p!='\n')&&(*p!='\r'); p++);
+       return p;
+}
+
+
+
+inline static int is_empty_end(char* p, char* pend )
+{
+       p=eat_space_end(p, pend );
+       return ((p<(pend )) && (*p=='\r' || *p=='\n'));
+}
 
 
 #endif
diff --git a/proxy.c b/proxy.c
index 32e1647..64e028e 100644 (file)
--- a/proxy.c
+++ b/proxy.c
@@ -176,7 +176,7 @@ struct proxy_l* mk_proxy(char* name, unsigned short port)
        p->port=port;
 #ifdef DNS_IP_HACK
        len=strlen(name);
-       ip=str2ip(name, len, &err);
+       ip=str2ip((unsigned char*)name, len, &err);
        if (err==0){
                p->host.h_name=malloc(len+1);
                if (p->host.h_name==0) goto error;
index 11e07b3..698a0dd 100644 (file)
@@ -128,7 +128,7 @@ int load_module(char* path)
                }
        }
        /* launch register */
-       mod_register = dlsym(handle, "mod_register");
+       mod_register = (module_register)dlsym(handle, "mod_register");
        if ( (error =dlerror())!=0 ){
                LOG(L_ERR, "ERROR: load_module: %s\n", error);
                goto error1;
@@ -176,7 +176,7 @@ struct sr_module* find_module(void* f, int *i)
        int r;
        for (t=modules;t;t=t->next){
                for(r=0;r<t->exports->cmd_no;r++) 
-                       if (f==t->exports->cmd_pointers[r]) {
+                       if (f==(void*)t->exports->cmd_pointers[r]) {
                                if (i) *i=r;
                                return t;
                        }
diff --git a/strs.h b/strs.h
index 84b8ee1..5e5d790 100644 (file)
--- a/strs.h
+++ b/strs.h
-#ifndef STRS_H\r
-#define STRS_H\r
-\r
-#define via1 0x3a616976   /* "via:" */\r
-#define viA1 0x3a416976   /* "viA:" */\r
-#define vIa1 0x3a614976   /* "vIa:" */\r
-#define vIA1 0x3a414976   /* "vIA:" */\r
-#define Via1 0x3a616956   /* "Via:" */\r
-#define ViA1 0x3a416956   /* "ViA:" */\r
-#define VIa1 0x3a614956   /* "VIa:" */\r
-#define VIA1 0x3a414956   /* "VIA:" */\r
-\r
-#define via2 0x20616976   /* "via " */\r
-#define viA2 0x20416976   /* "viA " */\r
-#define vIa2 0x20614976   /* "vIa " */\r
-#define vIA2 0x20414976   /* "vIA " */\r
-#define Via2 0x20616956   /* "Via " */\r
-#define ViA2 0x20416956   /* "ViA " */\r
-#define VIa2 0x20614956   /* "VIa " */\r
-#define VIA2 0x20414956   /* "VIA " */\r
-\r
-#define from 0x6d6f7266   /* "from" */\r
-#define froM 0x4d6f7266   /* "froM" */\r
-#define frOm 0x6d4f7266   /* "frOm" */\r
-#define frOM 0x4d4f7266   /* "frOM" */\r
-#define fRom 0x6d6f5266   /* "fRom" */\r
-#define fRoM 0x4d6f5266   /* "fRoM" */\r
-#define fROm 0x6d4f5266   /* "fROm" */\r
-#define fROM 0x4d4f5266   /* "fROM" */\r
-#define From 0x6d6f7246   /* "From" */\r
-#define FroM 0x4d6f7246   /* "FroM" */\r
-#define FrOm 0x6d4f7246   /* "FrOm" */\r
-#define FrOM 0x4d4f7246   /* "FrOM" */\r
-#define FRom 0x6d6f5246   /* "FRom" */\r
-#define FRoM 0x4d6f5246   /* "FRoM" */\r
-#define FROm 0x6d4f5246   /* "FROm" */\r
-#define FROM 0x4d4f5246   /* "FROM" */\r
-\r
-#define to12 0x203a6f74   /* "to: " */\r
-#define tO12 0x203a4f74   /* "tO: " */\r
-#define To12 0x203a6f54   /* "To: " */\r
-#define TO12 0x203a4f54   /* "TO: " */\r
-\r
-#define to21 0x3a206f74   /* "to :" */\r
-#define tO21 0x3a204f74   /* "tO :" */\r
-#define To21 0x3a206f54   /* "To :" */\r
-#define TO21 0x3a204f54   /* "TO :" */\r
-\r
-#define cseq 0x71657363   /* "cseq" */\r
-#define cseQ 0x51657363   /* "cseQ" */\r
-#define csEq 0x71457363   /* "csEq" */\r
-#define csEQ 0x51457363   /* "csEQ" */\r
-#define cSeq 0x71655363   /* "cSeq" */\r
-#define cSeQ 0x51655363   /* "cSeQ" */\r
-#define cSEq 0x71455363   /* "cSEq" */\r
-#define cSEQ 0x51455363   /* "cSEQ" */\r
-#define Cseq 0x71657343   /* "Cseq" */\r
-#define CseQ 0x51657343   /* "CseQ" */\r
-#define CsEq 0x71457343   /* "CsEq" */\r
-#define CsEQ 0x51457343   /* "CsEQ" */\r
-#define CSeq 0x71655343   /* "CSeq" */\r
-#define CSeQ 0x51655343   /* "CSeQ" */\r
-#define CSEq 0x71455343   /* "CSEq" */\r
-#define CSEQ 0x51455343   /* "CSEQ" */\r
-\r
-#define call 0x6c6c6163   /* "call" */\r
-#define calL 0x4c6c6163   /* "calL" */\r
-#define caLl 0x6c4c6163   /* "caLl" */\r
-#define caLL 0x4c4c6163   /* "caLL" */\r
-#define cAll 0x6c6c4163   /* "cAll" */\r
-#define cAlL 0x4c6c4163   /* "cAlL" */\r
-#define cALl 0x6c4c4163   /* "cALl" */\r
-#define cALL 0x4c4c4163   /* "cALL" */\r
-#define Call 0x6c6c6143   /* "Call" */\r
-#define CalL 0x4c6c6143   /* "CalL" */\r
-#define CaLl 0x6c4c6143   /* "CaLl" */\r
-#define CaLL 0x4c4c6143   /* "CaLL" */\r
-#define CAll 0x6c6c4143   /* "CAll" */\r
-#define CAlL 0x4c6c4143   /* "CAlL" */\r
-#define CALl 0x6c4c4143   /* "CALl" */\r
-#define CALL 0x4c4c4143   /* "CALL" */\r
-\r
-#define _id1 0x3a64692d   /* "-id:" */\r
-#define _iD1 0x3a44692d   /* "-iD:" */\r
-#define _Id1 0x3a64492d   /* "-Id:" */\r
-#define _ID1 0x3a44492d   /* "-ID:" */\r
-\r
-#define _id2 0x2064692d   /* "-id " */\r
-#define _iD2 0x2044692d   /* "-iD " */\r
-#define _Id2 0x2064492d   /* "-Id " */\r
-#define _ID2 0x2044492d   /* "-ID " */\r
-\r
-#define cont 0x746e6f63   /* "cont" */\r
-#define conT 0x546e6f63   /* "conT" */\r
-#define coNt 0x744e6f63   /* "coNt" */\r
-#define coNT 0x544e6f63   /* "coNT" */\r
-#define cOnt 0x746e4f63   /* "cOnt" */\r
-#define cOnT 0x546e4f63   /* "cOnT" */\r
-#define cONt 0x744e4f63   /* "cONt" */\r
-#define cONT 0x544e4f63   /* "cONT" */\r
-#define Cont 0x746e6f43   /* "Cont" */\r
-#define ConT 0x546e6f43   /* "ConT" */\r
-#define CoNt 0x744e6f43   /* "CoNt" */\r
-#define CoNT 0x544e6f43   /* "CoNT" */\r
-#define COnt 0x746e4f43   /* "COnt" */\r
-#define COnT 0x546e4f43   /* "COnT" */\r
-#define CONt 0x744e4f43   /* "CONt" */\r
-#define CONT 0x544e4f43   /* "CONT" */\r
-\r
-#define act1 0x3a746361   /* "act:" */\r
-#define acT1 0x3a546361   /* "acT:" */\r
-#define aCt1 0x3a744361   /* "aCt:" */\r
-#define aCT1 0x3a544361   /* "aCT:" */\r
-#define Act1 0x3a746341   /* "Act:" */\r
-#define AcT1 0x3a546341   /* "AcT:" */\r
-#define ACt1 0x3a744341   /* "ACt:" */\r
-#define ACT1 0x3a544341   /* "ACT:" */\r
-\r
-#define act2 0x20746361   /* "act " */\r
-#define acT2 0x20546361   /* "acT " */\r
-#define aCt2 0x20744361   /* "aCt " */\r
-#define aCT2 0x20544361   /* "aCT " */\r
-#define Act2 0x20746341   /* "Act " */\r
-#define AcT2 0x20546341   /* "AcT " */\r
-#define ACt2 0x20744341   /* "ACt " */\r
-#define ACT2 0x20544341   /* "ACT " */\r
-\r
-#define max_ 0x2d78616d   /* "max-" */\r
-#define maX_ 0x2d58616d   /* "maX-" */\r
-#define mAx_ 0x2d78416d   /* "mAx-" */\r
-#define mAX_ 0x2d58416d   /* "mAX-" */\r
-#define Max_ 0x2d78614d   /* "Max-" */\r
-#define MaX_ 0x2d58614d   /* "MaX-" */\r
-#define MAx_ 0x2d78414d   /* "MAx-" */\r
-#define MAX_ 0x2d58414d   /* "MAX-" */\r
-\r
-#define forw 0x77726f66   /* "forw" */\r
-#define forW 0x57726f66   /* "forW" */\r
-#define foRw 0x77526f66   /* "foRw" */\r
-#define foRW 0x57526f66   /* "foRW" */\r
-#define fOrw 0x77724f66   /* "fOrw" */\r
-#define fOrW 0x57724f66   /* "fOrW" */\r
-#define fORw 0x77524f66   /* "fORw" */\r
-#define fORW 0x57524f66   /* "fORW" */\r
-#define Forw 0x77726f46   /* "Forw" */\r
-#define ForW 0x57726f46   /* "ForW" */\r
-#define FoRw 0x77526f46   /* "FoRw" */\r
-#define FoRW 0x57526f46   /* "FoRW" */\r
-#define FOrw 0x77724f46   /* "FOrw" */\r
-#define FOrW 0x57724f46   /* "FOrW" */\r
-#define FORw 0x77524f46   /* "FORw" */\r
-#define FORW 0x57524f46   /* "FORW" */\r
-\r
-#define ards 0x73647261   /* "ards" */\r
-#define ardS 0x53647261   /* "ardS" */\r
-#define arDs 0x73447261   /* "arDs" */\r
-#define arDS 0x53447261   /* "arsd" */\r
-#define aRds 0x73645261   /* "aRds" */\r
-#define aRdS 0x53645261   /* "aRdS" */\r
-#define aRDs 0x73445261   /* "aRDs" */\r
-#define aRDS 0x53445261   /* "aRDS" */\r
-#define Ards 0x73647241   /* "Ards" */\r
-#define ArdS 0x53647241   /* "ArdS" */\r
-#define ArDs 0x73447241   /* "ArDs" */\r
-#define ArDS 0x53447241   /* "ArDS" */\r
-#define ARds 0x73645241   /* "ARds" */\r
-#define ARdS 0x53645241   /* "ARdS" */\r
-#define ARDs 0x73445241   /* "ARDs" */\r
-#define ARDS 0x53445241   /* "ARDS" */\r
-\r
-#define rout 0x74756f72   /* "rout" */\r
-#define rouT 0x54756f72   /* "rouT" */\r
-#define roUt 0x74556f72   /* "roUt" */\r
-#define roUT 0x54556f72   /* "roUT" */\r
-#define rOut 0x74754f72   /* "rOut" */\r
-#define rOuT 0x54754f72   /* "rOuT" */\r
-#define rOUt 0x74554f72   /* "rOUt" */\r
-#define rOUT 0x54554f72   /* "rOUT" */\r
-#define Rout 0x74756f52   /* "Rout" */\r
-#define RouT 0x54756f52   /* "RouT" */\r
-#define RoUt 0x74556f52   /* "RoUt" */\r
-#define RoUT 0x54556f52   /* "RoUT" */\r
-#define ROut 0x74754f52   /* "ROut" */\r
-#define ROuT 0x54754f52   /* "ROuT" */\r
-#define ROUt 0x74554f52   /* "ROUt" */\r
-#define ROUT 0x54554f52   /* "ROUT" */\r
-\r
-#define reco 0x6f636572   /* "reco" */\r
-#define recO 0x4f636572   /* "recO" */\r
-#define reCo 0x6f436572   /* "reCo" */\r
-#define reCO 0x4f436572   /* "reCO" */\r
-#define rEco 0x6f634572   /* "rEco" */\r
-#define rEcO 0x4f634572   /* "rEcO" */\r
-#define rECo 0x6f434572   /* "rECo" */\r
-#define rECO 0x4f434572   /* "rECO" */\r
-#define Reco 0x6f636552   /* "Reco" */\r
-#define RecO 0x4f636552   /* "RecO" */\r
-#define ReCo 0x6f436552   /* "ReCo" */\r
-#define ReCO 0x4f436552   /* "ReCO" */\r
-#define REco 0x6f634552   /* "REco" */\r
-#define REcO 0x4f634552   /* "REcO" */\r
-#define RECo 0x6f434552   /* "RECo" */\r
-#define RECO 0x4f434552   /* "RECO" */\r
-\r
-#define rd_r 0x722d6472   /* "rd-r" */\r
-#define rd_R 0x522d6472   /* "rd-R" */\r
-#define rD_r 0x722d4472   /* "rD-r" */\r
-#define rD_R 0x522d4472   /* "rD-R" */\r
-#define Rd_r 0x722d6452   /* "Rd-r" */\r
-#define Rd_R 0x522d6452   /* "Rd-R" */\r
-#define RD_r 0x722d4452   /* "RD-r" */\r
-#define RD_R 0x522d4452   /* "RD-R" */\r
-\r
-#define oute 0x6574756f   /* "oute" */\r
-#define outE 0x4574756f   /* "outE" */\r
-#define ouTe 0x6554756f   /* "ouTe" */\r
-#define ouTE 0x4554756f   /* "ouTE" */\r
-#define oUte 0x6574556f   /* "oUte" */\r
-#define oUtE 0x4574556f   /* "oUtE" */\r
-#define oUTe 0x6554556f   /* "oUTe" */\r
-#define oUTE 0x4554556f   /* "oUTE" */\r
-#define Oute 0x6574754f   /* "Oute" */\r
-#define OutE 0x4574754f   /* "OutE" */\r
-#define OuTe 0x6554754f   /* "OuTe" */\r
-#define OuTE 0x4554754f   /* "OuTE" */\r
-#define OUte 0x6574554f   /* "OUte" */\r
-#define OUtE 0x4574554f   /* "OUtE" */\r
-#define OUTe 0x6554554f   /* "OUTe" */\r
-#define OUTE 0x4554554f   /* "OUTE" */\r
-\r
-#endif\r
+#ifndef STRS_H
+#define STRS_H
+
+#define via1 0x3a616976   /* "via:" */
+#define viA1 0x3a416976   /* "viA:" */
+#define vIa1 0x3a614976   /* "vIa:" */
+#define vIA1 0x3a414976   /* "vIA:" */
+#define Via1 0x3a616956   /* "Via:" */
+#define ViA1 0x3a416956   /* "ViA:" */
+#define VIa1 0x3a614956   /* "VIa:" */
+#define VIA1 0x3a414956   /* "VIA:" */
+
+#define via2 0x20616976   /* "via " */
+#define viA2 0x20416976   /* "viA " */
+#define vIa2 0x20614976   /* "vIa " */
+#define vIA2 0x20414976   /* "vIA " */
+#define Via2 0x20616956   /* "Via " */
+#define ViA2 0x20416956   /* "ViA " */
+#define VIa2 0x20614956   /* "VIa " */
+#define VIA2 0x20414956   /* "VIA " */
+
+#define from 0x6d6f7266   /* "from" */
+#define froM 0x4d6f7266   /* "froM" */
+#define frOm 0x6d4f7266   /* "frOm" */
+#define frOM 0x4d4f7266   /* "frOM" */
+#define fRom 0x6d6f5266   /* "fRom" */
+#define fRoM 0x4d6f5266   /* "fRoM" */
+#define fROm 0x6d4f5266   /* "fROm" */
+#define fROM 0x4d4f5266   /* "fROM" */
+#define From 0x6d6f7246   /* "From" */
+#define FroM 0x4d6f7246   /* "FroM" */
+#define FrOm 0x6d4f7246   /* "FrOm" */
+#define FrOM 0x4d4f7246   /* "FrOM" */
+#define FRom 0x6d6f5246   /* "FRom" */
+#define FRoM 0x4d6f5246   /* "FRoM" */
+#define FROm 0x6d4f5246   /* "FROm" */
+#define FROM 0x4d4f5246   /* "FROM" */
+
+#define to12 0x203a6f74   /* "to: " */
+#define tO12 0x203a4f74   /* "tO: " */
+#define To12 0x203a6f54   /* "To: " */
+#define TO12 0x203a4f54   /* "TO: " */
+
+#define to21 0x3a206f74   /* "to :" */
+#define tO21 0x3a204f74   /* "tO :" */
+#define To21 0x3a206f54   /* "To :" */
+#define TO21 0x3a204f54   /* "TO :" */
+
+#define cseq 0x71657363   /* "cseq" */
+#define cseQ 0x51657363   /* "cseQ" */
+#define csEq 0x71457363   /* "csEq" */
+#define csEQ 0x51457363   /* "csEQ" */
+#define cSeq 0x71655363   /* "cSeq" */
+#define cSeQ 0x51655363   /* "cSeQ" */
+#define cSEq 0x71455363   /* "cSEq" */
+#define cSEQ 0x51455363   /* "cSEQ" */
+#define Cseq 0x71657343   /* "Cseq" */
+#define CseQ 0x51657343   /* "CseQ" */
+#define CsEq 0x71457343   /* "CsEq" */
+#define CsEQ 0x51457343   /* "CsEQ" */
+#define CSeq 0x71655343   /* "CSeq" */
+#define CSeQ 0x51655343   /* "CSeQ" */
+#define CSEq 0x71455343   /* "CSEq" */
+#define CSEQ 0x51455343   /* "CSEQ" */
+
+#define call 0x6c6c6163   /* "call" */
+#define calL 0x4c6c6163   /* "calL" */
+#define caLl 0x6c4c6163   /* "caLl" */
+#define caLL 0x4c4c6163   /* "caLL" */
+#define cAll 0x6c6c4163   /* "cAll" */
+#define cAlL 0x4c6c4163   /* "cAlL" */
+#define cALl 0x6c4c4163   /* "cALl" */
+#define cALL 0x4c4c4163   /* "cALL" */
+#define Call 0x6c6c6143   /* "Call" */
+#define CalL 0x4c6c6143   /* "CalL" */
+#define CaLl 0x6c4c6143   /* "CaLl" */
+#define CaLL 0x4c4c6143   /* "CaLL" */
+#define CAll 0x6c6c4143   /* "CAll" */
+#define CAlL 0x4c6c4143   /* "CAlL" */
+#define CALl 0x6c4c4143   /* "CALl" */
+#define CALL 0x4c4c4143   /* "CALL" */
+
+#define _id1 0x3a64692d   /* "-id:" */
+#define _iD1 0x3a44692d   /* "-iD:" */
+#define _Id1 0x3a64492d   /* "-Id:" */
+#define _ID1 0x3a44492d   /* "-ID:" */
+
+#define _id2 0x2064692d   /* "-id " */
+#define _iD2 0x2044692d   /* "-iD " */
+#define _Id2 0x2064492d   /* "-Id " */
+#define _ID2 0x2044492d   /* "-ID " */
+
+#define cont 0x746e6f63   /* "cont" */
+#define conT 0x546e6f63   /* "conT" */
+#define coNt 0x744e6f63   /* "coNt" */
+#define coNT 0x544e6f63   /* "coNT" */
+#define cOnt 0x746e4f63   /* "cOnt" */
+#define cOnT 0x546e4f63   /* "cOnT" */
+#define cONt 0x744e4f63   /* "cONt" */
+#define cONT 0x544e4f63   /* "cONT" */
+#define Cont 0x746e6f43   /* "Cont" */
+#define ConT 0x546e6f43   /* "ConT" */
+#define CoNt 0x744e6f43   /* "CoNt" */
+#define CoNT 0x544e6f43   /* "CoNT" */
+#define COnt 0x746e4f43   /* "COnt" */
+#define COnT 0x546e4f43   /* "COnT" */
+#define CONt 0x744e4f43   /* "CONt" */
+#define CONT 0x544e4f43   /* "CONT" */
+
+#define act1 0x3a746361   /* "act:" */
+#define acT1 0x3a546361   /* "acT:" */
+#define aCt1 0x3a744361   /* "aCt:" */
+#define aCT1 0x3a544361   /* "aCT:" */
+#define Act1 0x3a746341   /* "Act:" */
+#define AcT1 0x3a546341   /* "AcT:" */
+#define ACt1 0x3a744341   /* "ACt:" */
+#define ACT1 0x3a544341   /* "ACT:" */
+
+#define act2 0x20746361   /* "act " */
+#define acT2 0x20546361   /* "acT " */
+#define aCt2 0x20744361   /* "aCt " */
+#define aCT2 0x20544361   /* "aCT " */
+#define Act2 0x20746341   /* "Act " */
+#define AcT2 0x20546341   /* "AcT " */
+#define ACt2 0x20744341   /* "ACt " */
+#define ACT2 0x20544341   /* "ACT " */
+
+#define max_ 0x2d78616d   /* "max-" */
+#define maX_ 0x2d58616d   /* "maX-" */
+#define mAx_ 0x2d78416d   /* "mAx-" */
+#define mAX_ 0x2d58416d   /* "mAX-" */
+#define Max_ 0x2d78614d   /* "Max-" */
+#define MaX_ 0x2d58614d   /* "MaX-" */
+#define MAx_ 0x2d78414d   /* "MAx-" */
+#define MAX_ 0x2d58414d   /* "MAX-" */
+
+#define forw 0x77726f66   /* "forw" */
+#define forW 0x57726f66   /* "forW" */
+#define foRw 0x77526f66   /* "foRw" */
+#define foRW 0x57526f66   /* "foRW" */
+#define fOrw 0x77724f66   /* "fOrw" */
+#define fOrW 0x57724f66   /* "fOrW" */
+#define fORw 0x77524f66   /* "fORw" */
+#define fORW 0x57524f66   /* "fORW" */
+#define Forw 0x77726f46   /* "Forw" */
+#define ForW 0x57726f46   /* "ForW" */
+#define FoRw 0x77526f46   /* "FoRw" */
+#define FoRW 0x57526f46   /* "FoRW" */
+#define FOrw 0x77724f46   /* "FOrw" */
+#define FOrW 0x57724f46   /* "FOrW" */
+#define FORw 0x77524f46   /* "FORw" */
+#define FORW 0x57524f46   /* "FORW" */
+
+#define ards 0x73647261   /* "ards" */
+#define ardS 0x53647261   /* "ardS" */
+#define arDs 0x73447261   /* "arDs" */
+#define arDS 0x53447261   /* "arsd" */
+#define aRds 0x73645261   /* "aRds" */
+#define aRdS 0x53645261   /* "aRdS" */
+#define aRDs 0x73445261   /* "aRDs" */
+#define aRDS 0x53445261   /* "aRDS" */
+#define Ards 0x73647241   /* "Ards" */
+#define ArdS 0x53647241   /* "ArdS" */
+#define ArDs 0x73447241   /* "ArDs" */
+#define ArDS 0x53447241   /* "ArDS" */
+#define ARds 0x73645241   /* "ARds" */
+#define ARdS 0x53645241   /* "ARdS" */
+#define ARDs 0x73445241   /* "ARDs" */
+#define ARDS 0x53445241   /* "ARDS" */
+
+#define rout 0x74756f72   /* "rout" */
+#define rouT 0x54756f72   /* "rouT" */
+#define roUt 0x74556f72   /* "roUt" */
+#define roUT 0x54556f72   /* "roUT" */
+#define rOut 0x74754f72   /* "rOut" */
+#define rOuT 0x54754f72   /* "rOuT" */
+#define rOUt 0x74554f72   /* "rOUt" */
+#define rOUT 0x54554f72   /* "rOUT" */
+#define Rout 0x74756f52   /* "Rout" */
+#define RouT 0x54756f52   /* "RouT" */
+#define RoUt 0x74556f52   /* "RoUt" */
+#define RoUT 0x54556f52   /* "RoUT" */
+#define ROut 0x74754f52   /* "ROut" */
+#define ROuT 0x54754f52   /* "ROuT" */
+#define ROUt 0x74554f52   /* "ROUt" */
+#define ROUT 0x54554f52   /* "ROUT" */
+
+#define reco 0x6f636572   /* "reco" */
+#define recO 0x4f636572   /* "recO" */
+#define reCo 0x6f436572   /* "reCo" */
+#define reCO 0x4f436572   /* "reCO" */
+#define rEco 0x6f634572   /* "rEco" */
+#define rEcO 0x4f634572   /* "rEcO" */
+#define rECo 0x6f434572   /* "rECo" */
+#define rECO 0x4f434572   /* "rECO" */
+#define Reco 0x6f636552   /* "Reco" */
+#define RecO 0x4f636552   /* "RecO" */
+#define ReCo 0x6f436552   /* "ReCo" */
+#define ReCO 0x4f436552   /* "ReCO" */
+#define REco 0x6f634552   /* "REco" */
+#define REcO 0x4f634552   /* "REcO" */
+#define RECo 0x6f434552   /* "RECo" */
+#define RECO 0x4f434552   /* "RECO" */
+
+#define rd_r 0x722d6472   /* "rd-r" */
+#define rd_R 0x522d6472   /* "rd-R" */
+#define rD_r 0x722d4472   /* "rD-r" */
+#define rD_R 0x522d4472   /* "rD-R" */
+#define Rd_r 0x722d6452   /* "Rd-r" */
+#define Rd_R 0x522d6452   /* "Rd-R" */
+#define RD_r 0x722d4452   /* "RD-r" */
+#define RD_R 0x522d4452   /* "RD-R" */
+
+#define oute 0x6574756f   /* "oute" */
+#define outE 0x4574756f   /* "outE" */
+#define ouTe 0x6554756f   /* "ouTe" */
+#define ouTE 0x4554756f   /* "ouTE" */
+#define oUte 0x6574556f   /* "oUte" */
+#define oUtE 0x4574556f   /* "oUtE" */
+#define oUTe 0x6554556f   /* "oUTe" */
+#define oUTE 0x4554556f   /* "oUTE" */
+#define Oute 0x6574754f   /* "Oute" */
+#define OutE 0x4574754f   /* "OutE" */
+#define OuTe 0x6554754f   /* "OuTe" */
+#define OuTE 0x4554754f   /* "OuTE" */
+#define OUte 0x6574554f   /* "OUte" */
+#define OUtE 0x4574554f   /* "OUtE" */
+#define OUTe 0x6554554f   /* "OUTe" */
+#define OUTE 0x4554554f   /* "OUTE" */
+
+#endif
index 8664909..b104d10 100644 (file)
@@ -157,11 +157,11 @@ int udp_rcv_loop()
        static char buf [BUF_SIZE+1];
 #endif
 
-       struct sockaddr* from;
+       struct sockaddr_in* from;
        int fromlen;
 
 
-       from=(struct sockaddr*) malloc(sizeof(struct sockaddr));
+       from=(struct sockaddr_in*) malloc(sizeof(struct sockaddr_in));
        if (from==0){
                LOG(L_ERR, "ERROR: udp_rcv_loop: out of memory\n");
                goto error;
@@ -176,8 +176,9 @@ int udp_rcv_loop()
                        goto error;
                }
 #endif
-               fromlen=sizeof(struct sockaddr);
-               len=recvfrom(udp_sock, buf, BUF_SIZE, 0, from, &fromlen);
+               fromlen=sizeof(struct sockaddr_in);
+               len=recvfrom(udp_sock, buf, BUF_SIZE, 0, (struct sockaddr*)from,
+                                               &fromlen);
                if (len==-1){
                        LOG(L_ERR, "ERROR: udp_rcv_loop:recvfrom: %s\n",
                                                strerror(errno));
@@ -188,14 +189,15 @@ int udp_rcv_loop()
                buf[len+1]=0;
                
                /* receive_msg must free buf too!*/
-               receive_msg(buf, len, ((struct sockaddr_in*)from)->sin_addr.s_addr);
+               receive_msg(buf, len, from->sin_addr.s_addr);
                
        /* skip: do other stuff */
                
        }
-       
+       /*
        if (from) free(from);
        return 0;
+       */
        
 error:
        if (from) free(from);
diff --git a/ut.h b/ut.h
index ae2f6be..507f8d2 100644 (file)
--- a/ut.h
+++ b/ut.h
@@ -11,7 +11,7 @@
 
 /* returns string beginning and length without insignificant chars */
 #define trim_len( _len, _begin, _mystr ) \
-       ({      static char _c; \
+       do{     static char _c; \
                (_len)=(_mystr).len; \
                while ((_len) && ((_c=(_mystr).s[(_len)-1])==0 || _c=='\r' || _c=='\n' || _c==' ' || _c=='\t' )) \
                        (_len)--; \
                        (_len)--;\
                        (_begin)++; \
                } \
-       })
+       }while(0)
 
 #define trim_r( _mystr ) \
-       ({      static _c; \
+       do{     static _c; \
                while( ((_mystr).len) && ((_c=(_mystr).s[(_mystr).len-1]))==0 || _c=='\r' || _c=='\n') \
                        (_mystr).len--; \
-       })
+       }while(0)
 
 
 #define  translate_pointer( _new_buf , _org_buf , _p) \
@@ -36,7 +36,7 @@
 
 /* converts a str to an u. short, returns the u. short and sets *err on
  * error and if err!=null
* */
+  */
 static inline unsigned short str2s(unsigned char* str, unsigned int len,
                                                                        int *err)
 {