- cosmetic changes (lines too long a.s.o)
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 20 Sep 2002 09:29:07 +0000 (09:29 +0000)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 20 Sep 2002 09:29:07 +0000 (09:29 +0000)
14 files changed:
db/db_val.h
globals.h
main.c
mem/shm_mem.c
mem/vq_malloc.c
mem/vq_malloc.h
msg_translator.c
route_struct.c
sr_module.c
sr_module.h
stats.c
stats.h
udp_server.c
ut.h

index d48cdbb..45bb1bf 100644 (file)
@@ -50,8 +50,9 @@ typedef enum {
  * Column value structure
  */
 typedef struct {
-       db_type_t type;                  /* Type of the value */
-       int nul;                         /* Means that the column in database has no value */
+       db_type_t type;                /* Type of the value */
+       int nul;                       /* Means that the column in database
+                                                                         has no value */
        union {
                int          int_val;    /* integer value */
                double       double_val; /* double value */
@@ -59,7 +60,7 @@ typedef struct {
                const char*  string_val; /* NULL terminated string */
                str          str_val;    /* str string value */
                str          blob_val;   /* Blob data */
-       } val;                           /* union of all possible types */
+       } val;                       /* union of all possible types */
 } db_val_t;
 
 
index b317036..333227e 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -58,9 +58,11 @@ extern int names_len[];
 extern struct ip_addr addresses[];
 extern int addresses_no;
 */
-extern struct socket_info* bind_address; /* pointer to the crt. proc. listening address */
+extern struct socket_info* bind_address; /* pointer to the crt. proc.
+                                                                                       listening address */
 extern int bind_idx; /* same as above but index in the bound[] array */
-extern struct socket_info* sendipv4; /* ipv4 socket to use when msg. comes from ipv6*/
+extern struct socket_info* sendipv4; /* ipv4 socket to use when msg.
+                                                                               comes from ipv6*/
 extern struct socket_info* sendipv6; /* same as above for ipv6 */
 
 extern unsigned int maxbuffer;
diff --git a/main.c b/main.c
index 3135f49..2872253 100644 (file)
--- a/main.c
+++ b/main.c
@@ -259,9 +259,10 @@ int names_len[MAX_LISTEN];            /* lengths of the names*/
 struct ip_addr addresses[MAX_LISTEN]; /* our ips */
 int addresses_no=0;                   /* number of names/ips */
 #endif
-struct socket_info sock_info[MAX_LISTEN]; /* all addresses we listen/send from*/
+struct socket_info sock_info[MAX_LISTEN];/*all addresses we listen/send from*/
 int sock_no=0; /* number of addresses/open sockets*/
-struct socket_info* bind_address; /* pointer to the crt. proc. listening address */
+struct socket_info* bind_address; /* pointer to the crt. proc.
+                                                                        listening address*/
 int bind_idx; /* same as above but index in the bound[] array */
 struct socket_info* sendipv4; /* ipv4 socket to use when msg. comes from ipv6*/
 struct socket_info* sendipv6; /* same as above for ipv6 */
@@ -515,7 +516,8 @@ int main_loop()
                bind_address=&sock_info[0];
                bind_idx=0;
                if (sock_no>1){
-                       LOG(L_WARN, "WARNING: using only the first listen address (no fork)\n");
+                       LOG(L_WARN, "WARNING: using only the first listen address"
+                                               " (no fork)\n");
                }
 
                /* process_no now initialized to zero -- increase from now on
@@ -601,7 +603,6 @@ int main_loop()
                                                LOG(L_ERR, "init_child failed\n");
                                                goto error;
                                        }
-                                       /* process_bit = 1 << (i+r*children_no); */ /*or process_no-1*/
 #ifdef STATS
                                        setstats( i+r*children_no );
 #endif
@@ -654,8 +655,9 @@ int main_loop()
        strncpy(pt[0].desc, "attendant", MAX_PT_DESC );
        /*DEBUG- remove it*/
 #ifdef DEBUG
-       printf("\n% 3d processes, % 3d children * % 3d listening addresses + main + fifo %s\n",
-                       process_no+1, children_no, sock_no, (timer_list)?"+ timer":"");
+       printf("\n% 3d processes, % 3d children * % 3d listening addresses + main"
+                       " + fifo %s\n", process_no+1, children_no, sock_no,
+                       (timer_list)?"+ timer":"");
        for (r=0; r<=process_no; r++){
                printf("% 3d   % 5d\n", r, pt[r].pid);
        }
@@ -1274,8 +1276,8 @@ int main(int argc, char** argv)
        }
        if (dont_fork){
                fprintf(stderr, "WARNING: no fork mode %s\n", 
-                               (sock_no>1)?" and more than one listen address found (will use only the"
-                               " the first one)":"");
+                               (sock_no>1)?" and more than one listen address found (will"
+                                                       " use only the the first one)":"");
        }
        
        /* init_daemon? */
index f20f0a8..6d2d021 100644 (file)
@@ -109,7 +109,8 @@ inline static void* sh_realloc(void* p, unsigned int size)
 */
 
 #ifdef DBG_QM_MALLOC
-void* _shm_resize( void* p, unsigned int s, char* file, char* func, unsigned int line)
+void* _shm_resize( void* p, unsigned int s, char* file, char* func,
+                                       unsigned int line)
 #else
 void* _shm_resize( void* p , unsigned int s)
 #endif
@@ -139,7 +140,8 @@ void* _shm_resize( void* p , unsigned int s)
 
 #ifdef _OBSOLETED
 #ifdef DBG_QM_MALLOC
-void* _shm_resize( void* p, unsigned int s, char* file, char* func, unsigned int line)
+void* _shm_resize( void* p, unsigned int s, char* file, char* func,
+                                       unsigned int line)
 #else
 void* _shm_resize( void* p , unsigned int s)
 #endif
@@ -217,8 +219,7 @@ int shm_mem_init()
                                strerror(errno));
                return -1;
        }
-       shm_mempool=mmap(0, /* SHM_MEM_SIZE */ shm_mem_size, PROT_READ|PROT_WRITE, MAP_SHARED,
-                                               fd ,0);
+       shm_mempool=mmap(0, shm_mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd ,0);
        /* close /dev/zero */
        close(fd);
 #else
index d96d022..3e21887 100644 (file)
  * Horde has been heavily optimized for multi-processor machines
  *
  * References:
- *   - list of malloc implementations: http://www.cs.colorado.edu/~zorn/Malloc.html
+ *   - list of malloc implementations: 
+ *       http://www.cs.colorado.edu/~zorn/Malloc.html
  *   - a white-paper: http://g.oswego.edu/dl/html/malloc.html
  *   - Paul R. Wilson, Mark S. Johnstone, Michael Neely, and David Boles: 
-       ``Dynamic Storage Allocation: A Survey and Critical Review'' in International 
      Workshop on Memory Management, September 1995, 
-       ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps
+ *      ``Dynamic Storage Allocation: A Survey and Critical Review'' in
*      International Workshop on Memory Management, September 1995, 
*      ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps
  *   - ptmalloc: http://www.malloc.de/en/
- *   - GNU C-lib malloc: http://www.gnu.org/manual/glibc-2.0.6/html_chapter/libc_3.html
+ *   - GNU C-lib malloc:
+ *      http://www.gnu.org/manual/glibc-2.0.6/html_chapter/libc_3.html
  *   - delorie malocs: http://www.delorie.com/djgpp/malloc/
  *
  */
@@ -92,7 +94,8 @@
 #endif
 
 #ifdef DBG_QM_MALLOC
-#      define MORE_CORE(_q,_b,_s) (more_core( (_q), (_b), (_s), file, func, line ))
+#      define MORE_CORE(_q,_b,_s)\
+                               (more_core( (_q), (_b), (_s), file, func, line ))
 #else
 #      define MORE_CORE(_q,_b,_s) (more_core( (_q), (_b), (_s) ))
 #endif
 
 
 /* dimensioning buckets: define the step function constants for size2bucket */
-int s2b_step[] = {8, 16, 32, 64, 128, 256, 512, 1024, 1536, 2048, 2560, MAX_FIXED_BLOCK, EO_STEP };
+int s2b_step[] = {8, 16, 32, 64, 128, 256, 512, 1024, 1536, 2048, 2560,
+                                       MAX_FIXED_BLOCK, EO_STEP };
 
 void my_assert( int assertation, int line, char *file, char *function )
 {
@@ -202,8 +206,8 @@ struct vqm_block* vqm_malloc_init(char* address, unsigned int size)
        for (s=0, b=0; s<MAX_FIXED_BLOCK ; s++) {
                while (s>s2b_step[b]) b++;
                if (b>MAX_BUCKET) {
-                       LOG(L_CRIT, "CRIT: vqm_malloc_init: attempt to install too many buckets,"
-                               "s2b_step > MAX_BUCKET\n");
+                       LOG(L_CRIT, "CRIT: vqm_malloc_init: attempt to install too"
+                                       " many buckets, s2b_step > MAX_BUCKET\n");
                        return 0;
                }
                qm->s2b[s] = b;
@@ -257,7 +261,8 @@ struct vqm_frag *more_core( struct vqm_block* qm,
        return new_chunk;
 }
 
-static inline void vqm_detach_free( struct vqm_block* qm, struct vqm_frag* frag)
+static inline void vqm_detach_free( struct vqm_block* qm,
+                                                                       struct vqm_frag* frag)
 {
 
        struct vqm_frag *prev, *next;
@@ -331,11 +336,12 @@ void* vqm_malloc(struct vqm_block* qm, unsigned int size)
        new_chunk->line=line;
        new_chunk->demanded_size=demanded_size;
        qm->usage[ bucket ]++;
-       DBG("vqm_malloc( %p, %d ) returns address %p in bucket %d, real-size %d \n",
+       DBG("vqm_malloc( %p, %d ) returns address %p in bucket %d, real-size %d\n",
                qm, demanded_size, (char*)new_chunk+sizeof(struct vqm_frag), 
                bucket, size );
 
-       new_chunk->end_check=(char*)new_chunk+sizeof(struct vqm_frag)+demanded_size;
+       new_chunk->end_check=(char*)new_chunk+
+                                                       sizeof(struct vqm_frag)+demanded_size;
        memcpy(  new_chunk->end_check, END_CHECK_PATTERN, END_CHECK_PATTERN_LEN );
        new_chunk->check=ST_CHECK_PATTERN;
 #endif
index ededd4f..439f0a9 100644 (file)
@@ -62,7 +62,8 @@
 #      define ST_CHECK_PATTERN         0xf0f0f0f0
 #      define END_CHECK_PATTERN        "sExP"
 #      define END_CHECK_PATTERN_LEN    4
-#      define VQM_OVERHEAD (sizeof(struct vqm_frag)+ sizeof(struct vqm_frag_end)+END_CHECK_PATTERN_LEN)
+#      define VQM_OVERHEAD (sizeof(struct vqm_frag)+ \
+                                                       sizeof(struct vqm_frag_end)+END_CHECK_PATTERN_LEN)
 #      define VQM_DEBUG_FRAG(qm, f) vqm_debug_frag( (qm), (f))
 #else
 #      define VQM_DEBUG_FRAG(qm, f)
index b53a155..fe0e6a3 100644 (file)
@@ -549,7 +549,8 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
        new_len=len+lumps_len(msg->repl_add_rm);
 
        DBG(" old size: %d, new size: %d\n", len, new_len);
-       new_buf=(char*)pkg_malloc(new_len+1); /* +1 is for debugging (\0 to print it )*/
+       new_buf=(char*)pkg_malloc(new_len+1); /* +1 is for debugging 
+                                                                                        (\0 to print it )*/
        if (new_buf==0){
                LOG(L_ERR, "ERROR: build_res_buf_from_sip_res: out of mem\n");
                goto error;
index 45939f7..af1aa08 100644 (file)
@@ -76,7 +76,8 @@ error:
 
 
 
-struct action* mk_action(int type, int p1_type, int p2_type, void* p1, void* p2)
+struct action* mk_action(int type, int p1_type, int p2_type,
+                                                                                       void* p1, void* p2)
 {
        struct action* a;
        a=(struct action*)malloc(sizeof(struct action));
index e425063..2743572 100644 (file)
@@ -228,7 +228,8 @@ void* find_param_export(char* mod, char* name, modparam_t type)
                        }
                }
        }
-       DBG("find_param_export: parameter <%s> or module <%s> not found\n", name, mod);
+       DBG("find_param_export: parameter <%s> or module <%s> not found\n",
+                       name, mod);
        return 0;
 }
 
@@ -272,7 +273,8 @@ int init_modules(void)
        for(t = modules; t; t = t->next) {
                if ((t->exports) && (t->exports->init_f))
                        if (t->exports->init_f() != 0) {
-                               LOG(L_ERR, "init_modules(): Error while initializing module %s\n", t->exports->name);
+                               LOG(L_ERR, "init_modules(): Error while initializing"
+                                                       " module %s\n", t->exports->name);
                                return -1;
                        }
        }
index 849eda1..f65abf7 100644 (file)
@@ -52,34 +52,30 @@ typedef enum {
 struct module_exports{
        char* name;                     /* null terminated module name */
        char** cmd_names;               /* cmd names registered by this modules */
-       cmd_function* cmd_pointers;     /* pointers to the corresponding functions */
-       int* param_no;                  /* number of parameters used by the function */
+       cmd_function* cmd_pointers;     /* pointers to the corresponding
+                                                                          functions */
+       int* param_no;                  /* number of parameters used
+                                                                          by the function */
        fixup_function* fixup_pointers; /* pointers to functions called to "fix"
-                                        * the params, e.g: precompile a re 
-                                        */
-       int cmd_no;       /* number of registered commands
-                          * (size of cmd_{names,pointers}
-                          */
+                                                                               the params, e.g: precompile a re */
+       int cmd_no;                     /* number of registered commands
+                                                                               (size of cmd_{names,pointers} */
 
        char** param_names;    /* parameter names registered by this modules */
        modparam_t* param_types; /* Type of parameters */
        void** param_pointers; /* Pointers to the corresponding memory locations */
-       int par_no;            /* Number of registered parameters */
+       int par_no;            /* number of registered parameters */
 
 
        init_function init_f;         /* Initilization function */
        response_function response_f; /* function used for responses,
-                                      * returns yes or no;
-                                      * can be null 
-                                      */
+                                                                       returns yes or no; can be null */
        destroy_function destroy_f;  /* function called when the module should
-                                     * be "destroyed", e.g: on ser exit;
-                                     * can be null 
-                                     */
+                                                                       be "destroyed", e.g: on ser exit;
+                                                                       can be null */
        onbreak_function onbreak_f;
-       child_init_function init_child_f;  /* Function will be called by all 
-                                           * processes after the fork 
-                                           */
+       child_init_function init_child_f;  /* function called by all processes
+                                                                                 after the fork */
 };
 
 struct sr_module{
diff --git a/stats.c b/stats.c
index ba48656..6fc0b2c 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -93,7 +93,8 @@ int init_stats(int nr_of_processes)
        stats_segments = nr_of_processes;
 
        if(stats_register() == -1)
-               LOG(L_WARN, "init_stats(): Couldn't register stats with snmp module\n");
+               LOG(L_WARN, "init_stats(): Couldn't register stats"
+                                       " with snmp module\n");
 
 
        return 0;
diff --git a/stats.h b/stats.h
index b80553b..10e45d7 100644 (file)
--- a/stats.h
+++ b/stats.h
 
 
 #define _update_request( method, dir )                 \
-       { if (stat_file!=NULL) switch( method ) {       \
+       do{ if (stat_file!=NULL) switch( method ) {     \
                case METHOD_INVITE: stats->dir##_requests_inv++; break; \
                case METHOD_ACK: stats->dir##_requests_ack++; break;            \
                case METHOD_CANCEL: stats->dir##_requests_cnc++; break; \
                case METHOD_BYE: stats->dir##_requests_bye++; break;            \
                case METHOD_OTHER: stats->dir##_requests_other++; break;        \
-               default: LOG(L_ERR, "ERROR: unknown method in rq stats (%s)\n", #dir);  \
+               default: LOG(L_ERR, "ERROR: unknown method in rq stats (%s)\n", \
+                                                       #dir);  \
                }       \
-        }
+       }while(0)
 
 
 /*
 #define update_received_request( method ) _update_request( method, received )
 #define update_sent_request( method ) _update_request( method, sent )
 
-#define update_received_response( statusclass ) _update_response( statusclass, received )
-#define update_sent_response( statusclass ) _update_response( statusclass, sent )
+#define update_received_response( statusclass ) \
+                                                                       _update_response( statusclass, received )
+#define update_sent_response( statusclass ) \
+                                                                       _update_response( statusclass, sent )
 #define update_received_drops  {  stats->received_drops++; }
 #define update_fail_on_send    {  stats->failed_on_send++; }
 */
 
-#define         _statusline(class, dir )       case class: stats->dir##_responses_##class++; break;
+#define         _statusline(class, dir )\
+                                               case class: stats->dir##_responses_##class++; break;
 
 /* FIXME: Don't have case for _other (see received_responses_other) */
 #define _update_response( statusclass, dir )           \
-        { if (stat_file!=NULL)                          \
+        do{ if (stat_file!=NULL)                          \
                 switch( statusclass ) {                 \
                         _statusline(1, dir)                   \
                         _statusline(2, dir)                   \
                         _statusline(4, dir)                   \
                         _statusline(5, dir)                   \
                         _statusline(6, dir)                   \
-                        default: LOG(L_INFO, "ERROR: unusual status code received in stats (%s)\n", #dir);    \
+                        default: LOG(L_INFO, "ERROR: unusual status code"\
+                                                                                " received in stats (%s)\n", #dir); \
                 }       \
-        }
+        }while(0)
 
 #ifdef STATS
 #      define STATS_RX_REQUEST(method) _update_request(method, received)
index 5fd5d9b..7374402 100644 (file)
@@ -322,8 +322,8 @@ int udp_rcv_loop()
 #endif
 #ifdef DBG_MSG_QA
                if (!dbg_msg_qa(buf, len)) {
-                       LOG(L_WARN, "WARNING: an incoming message didn't pass test, drop it: %.*s\n",
-                               len, buf );
+                       LOG(L_WARN, "WARNING: an incoming message didn't pass test,"
+                                               "  drop it: %.*s\n", len, buf );
                        continue;
                }
 #endif
@@ -348,7 +348,8 @@ error:
 
 
 /* which socket to use? main socket or new one? */
-int udp_send(struct socket_info *source, char *buf, unsigned len, union sockaddr_union*  to)
+int udp_send(struct socket_info *source, char *buf, unsigned len,
+                                                                               union sockaddr_union*  to)
 {
 
        int n;
diff --git a/ut.h b/ut.h
index 0cb6241..1cf79ab 100644 (file)
--- a/ut.h
+++ b/ut.h
@@ -46,7 +46,8 @@ struct sip_msg;
 #define trim_len( _len, _begin, _mystr ) \
        do{     static char _c; \
                (_len)=(_mystr).len; \
-               while ((_len) && ((_c=(_mystr).s[(_len)-1])==0 || _c=='\r' || _c=='\n' || _c==' ' || _c=='\t' )) \
+               while ((_len) && ((_c=(_mystr).s[(_len)-1])==0 || _c=='\r' || \
+                                       _c=='\n' || _c==' ' || _c=='\t' )) \
                        (_len)--; \
                (_begin)=(_mystr).s; \
                while ((_len) && ((_c=*(_begin))==' ' || _c=='\t')) { \