Browse code

- cosmetic changes (lines too long a.s.o)

Andrei Pelinescu-Onciul authored on 20/09/2002 09:29:07
Showing 14 changed files
... ...
@@ -50,8 +50,9 @@ typedef enum {
50 50
  * Column value structure
51 51
  */
52 52
 typedef struct {
53
-	db_type_t type;                  /* Type of the value */
54
-	int nul;                         /* Means that the column in database has no value */
53
+	db_type_t type;                /* Type of the value */
54
+	int nul;                       /* Means that the column in database
55
+									  has no value */
55 56
 	union {
56 57
 		int          int_val;    /* integer value */
57 58
 		double       double_val; /* double value */
... ...
@@ -59,7 +60,7 @@ typedef struct {
59 59
 		const char*  string_val; /* NULL terminated string */
60 60
 		str          str_val;    /* str string value */
61 61
 		str          blob_val;   /* Blob data */
62
-	} val;                           /* union of all possible types */
62
+	} val;                       /* union of all possible types */
63 63
 } db_val_t;
64 64
 
65 65
 
... ...
@@ -58,9 +58,11 @@ extern int names_len[];
58 58
 extern struct ip_addr addresses[];
59 59
 extern int addresses_no;
60 60
 */
61
-extern struct socket_info* bind_address; /* pointer to the crt. proc. listening address */
61
+extern struct socket_info* bind_address; /* pointer to the crt. proc.
62
+											listening address */
62 63
 extern int bind_idx; /* same as above but index in the bound[] array */
63
-extern struct socket_info* sendipv4; /* ipv4 socket to use when msg. comes from ipv6*/
64
+extern struct socket_info* sendipv4; /* ipv4 socket to use when msg.
65
+										comes from ipv6*/
64 66
 extern struct socket_info* sendipv6; /* same as above for ipv6 */
65 67
 
66 68
 extern unsigned int maxbuffer;
... ...
@@ -259,9 +259,10 @@ int names_len[MAX_LISTEN];            /* lengths of the names*/
259 259
 struct ip_addr addresses[MAX_LISTEN]; /* our ips */
260 260
 int addresses_no=0;                   /* number of names/ips */
261 261
 #endif
262
-struct socket_info sock_info[MAX_LISTEN]; /* all addresses we listen/send from*/
262
+struct socket_info sock_info[MAX_LISTEN];/*all addresses we listen/send from*/
263 263
 int sock_no=0; /* number of addresses/open sockets*/
264
-struct socket_info* bind_address; /* pointer to the crt. proc. listening address */
264
+struct socket_info* bind_address; /* pointer to the crt. proc.
265
+									 listening address*/
265 266
 int bind_idx; /* same as above but index in the bound[] array */
266 267
 struct socket_info* sendipv4; /* ipv4 socket to use when msg. comes from ipv6*/
267 268
 struct socket_info* sendipv6; /* same as above for ipv6 */
... ...
@@ -515,7 +516,8 @@ int main_loop()
515 515
 		bind_address=&sock_info[0];
516 516
 		bind_idx=0;
517 517
 		if (sock_no>1){
518
-			LOG(L_WARN, "WARNING: using only the first listen address (no fork)\n");
518
+			LOG(L_WARN, "WARNING: using only the first listen address"
519
+						" (no fork)\n");
519 520
 		}
520 521
 
521 522
 		/* process_no now initialized to zero -- increase from now on
... ...
@@ -601,7 +603,6 @@ int main_loop()
601 601
 						LOG(L_ERR, "init_child failed\n");
602 602
 						goto error;
603 603
 					}
604
-					/* process_bit = 1 << (i+r*children_no); */ /*or process_no-1*/
605 604
 #ifdef STATS
606 605
 					setstats( i+r*children_no );
607 606
 #endif
... ...
@@ -654,8 +655,9 @@ int main_loop()
654 654
 	strncpy(pt[0].desc, "attendant", MAX_PT_DESC );
655 655
 	/*DEBUG- remove it*/
656 656
 #ifdef DEBUG
657
-	printf("\n% 3d processes, % 3d children * % 3d listening addresses + main + fifo %s\n",
658
-			process_no+1, children_no, sock_no, (timer_list)?"+ timer":"");
657
+	printf("\n% 3d processes, % 3d children * % 3d listening addresses + main"
658
+			" + fifo %s\n", process_no+1, children_no, sock_no,
659
+			(timer_list)?"+ timer":"");
659 660
 	for (r=0; r<=process_no; r++){
660 661
 		printf("% 3d   % 5d\n", r, pt[r].pid);
661 662
 	}
... ...
@@ -1274,8 +1276,8 @@ int main(int argc, char** argv)
1274 1274
 	}
1275 1275
 	if (dont_fork){
1276 1276
 		fprintf(stderr, "WARNING: no fork mode %s\n", 
1277
-				(sock_no>1)?" and more than one listen address found (will use only the"
1278
-				" the first one)":"");
1277
+				(sock_no>1)?" and more than one listen address found (will"
1278
+							" use only the the first one)":"");
1279 1279
 	}
1280 1280
 	
1281 1281
 	/* init_daemon? */
... ...
@@ -109,7 +109,8 @@ inline static void* sh_realloc(void* p, unsigned int size)
109 109
 */
110 110
 
111 111
 #ifdef DBG_QM_MALLOC
112
-void* _shm_resize( void* p, unsigned int s, char* file, char* func, unsigned int line)
112
+void* _shm_resize( void* p, unsigned int s, char* file, char* func,
113
+					unsigned int line)
113 114
 #else
114 115
 void* _shm_resize( void* p , unsigned int s)
115 116
 #endif
... ...
@@ -139,7 +140,8 @@ void* _shm_resize( void* p , unsigned int s)
139 139
 
140 140
 #ifdef _OBSOLETED
141 141
 #ifdef DBG_QM_MALLOC
142
-void* _shm_resize( void* p, unsigned int s, char* file, char* func, unsigned int line)
142
+void* _shm_resize( void* p, unsigned int s, char* file, char* func,
143
+					unsigned int line)
143 144
 #else
144 145
 void* _shm_resize( void* p , unsigned int s)
145 146
 #endif
... ...
@@ -217,8 +219,7 @@ int shm_mem_init()
217 217
 				strerror(errno));
218 218
 		return -1;
219 219
 	}
220
-	shm_mempool=mmap(0, /* SHM_MEM_SIZE */ shm_mem_size, PROT_READ|PROT_WRITE, MAP_SHARED,
221
-						fd ,0);
220
+	shm_mempool=mmap(0, shm_mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd ,0);
222 221
 	/* close /dev/zero */
223 222
 	close(fd);
224 223
 #else
... ...
@@ -58,14 +58,16 @@
58 58
  * Horde has been heavily optimized for multi-processor machines
59 59
  *
60 60
  * References:
61
- *   - list of malloc implementations: http://www.cs.colorado.edu/~zorn/Malloc.html
61
+ *   - list of malloc implementations: 
62
+ *       http://www.cs.colorado.edu/~zorn/Malloc.html
62 63
  *   - a white-paper: http://g.oswego.edu/dl/html/malloc.html
63 64
  *   - Paul R. Wilson, Mark S. Johnstone, Michael Neely, and David Boles: 
64
-       ``Dynamic Storage Allocation: A Survey and Critical Review'' in International 
65
-       Workshop on Memory Management, September 1995, 
66
-       ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps
65
+ *      ``Dynamic Storage Allocation: A Survey and Critical Review'' in
66
+ *      International Workshop on Memory Management, September 1995, 
67
+ *      ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps
67 68
  *   - ptmalloc: http://www.malloc.de/en/
68
- *   - GNU C-lib malloc: http://www.gnu.org/manual/glibc-2.0.6/html_chapter/libc_3.html
69
+ *   - GNU C-lib malloc:
70
+ *      http://www.gnu.org/manual/glibc-2.0.6/html_chapter/libc_3.html
69 71
  *   - delorie malocs: http://www.delorie.com/djgpp/malloc/
70 72
  *
71 73
  */
... ...
@@ -92,7 +94,8 @@
92 92
 #endif
93 93
 
94 94
 #ifdef DBG_QM_MALLOC
95
-#	define MORE_CORE(_q,_b,_s) (more_core( (_q), (_b), (_s), file, func, line ))
95
+#	define MORE_CORE(_q,_b,_s)\
96
+				(more_core( (_q), (_b), (_s), file, func, line ))
96 97
 #else
97 98
 #	define MORE_CORE(_q,_b,_s) (more_core( (_q), (_b), (_s) ))
98 99
 #endif
... ...
@@ -100,7 +103,8 @@
100 100
 
101 101
 
102 102
 /* dimensioning buckets: define the step function constants for size2bucket */
103
-int s2b_step[] = {8, 16, 32, 64, 128, 256, 512, 1024, 1536, 2048, 2560, MAX_FIXED_BLOCK, EO_STEP };
103
+int s2b_step[] = {8, 16, 32, 64, 128, 256, 512, 1024, 1536, 2048, 2560,
104
+					MAX_FIXED_BLOCK, EO_STEP };
104 105
 
105 106
 void my_assert( int assertation, int line, char *file, char *function )
106 107
 {
... ...
@@ -202,8 +206,8 @@ struct vqm_block* vqm_malloc_init(char* address, unsigned int size)
202 202
 	for (s=0, b=0; s<MAX_FIXED_BLOCK ; s++) {
203 203
 		while (s>s2b_step[b]) b++;
204 204
 		if (b>MAX_BUCKET) {
205
-			LOG(L_CRIT, "CRIT: vqm_malloc_init: attempt to install too many buckets,"
206
-				"s2b_step > MAX_BUCKET\n");
205
+			LOG(L_CRIT, "CRIT: vqm_malloc_init: attempt to install too"
206
+					" many buckets, s2b_step > MAX_BUCKET\n");
207 207
 			return 0;
208 208
 		}
209 209
 		qm->s2b[s] = b;
... ...
@@ -257,7 +261,8 @@ struct vqm_frag *more_core(	struct vqm_block* qm,
257 257
 	return new_chunk;
258 258
 }
259 259
 
260
-static inline void vqm_detach_free( struct vqm_block* qm, struct vqm_frag* frag)
260
+static inline void vqm_detach_free( struct vqm_block* qm,
261
+									struct vqm_frag* frag)
261 262
 {
262 263
 
263 264
 	struct vqm_frag *prev, *next;
... ...
@@ -331,11 +336,12 @@ void* vqm_malloc(struct vqm_block* qm, unsigned int size)
331 331
 	new_chunk->line=line;
332 332
 	new_chunk->demanded_size=demanded_size;
333 333
 	qm->usage[ bucket ]++;
334
-	DBG("vqm_malloc( %p, %d ) returns address %p in bucket %d, real-size %d \n",
334
+	DBG("vqm_malloc( %p, %d ) returns address %p in bucket %d, real-size %d\n",
335 335
 		qm, demanded_size, (char*)new_chunk+sizeof(struct vqm_frag), 
336 336
 		bucket, size );
337 337
 
338
-	new_chunk->end_check=(char*)new_chunk+sizeof(struct vqm_frag)+demanded_size;
338
+	new_chunk->end_check=(char*)new_chunk+
339
+							sizeof(struct vqm_frag)+demanded_size;
339 340
 	memcpy(  new_chunk->end_check, END_CHECK_PATTERN, END_CHECK_PATTERN_LEN );
340 341
 	new_chunk->check=ST_CHECK_PATTERN;
341 342
 #endif
... ...
@@ -62,7 +62,8 @@
62 62
 #	define ST_CHECK_PATTERN   	0xf0f0f0f0
63 63
 #	define END_CHECK_PATTERN  	"sExP"
64 64
 #	define END_CHECK_PATTERN_LEN 	4
65
-#	define VQM_OVERHEAD (sizeof(struct vqm_frag)+ sizeof(struct vqm_frag_end)+END_CHECK_PATTERN_LEN)
65
+#	define VQM_OVERHEAD (sizeof(struct vqm_frag)+ \
66
+							sizeof(struct vqm_frag_end)+END_CHECK_PATTERN_LEN)
66 67
 #	define VQM_DEBUG_FRAG(qm, f) vqm_debug_frag( (qm), (f))
67 68
 #else
68 69
 #	define VQM_DEBUG_FRAG(qm, f)
... ...
@@ -549,7 +549,8 @@ char * build_res_buf_from_sip_res( struct sip_msg* msg,
549 549
 	new_len=len+lumps_len(msg->repl_add_rm);
550 550
 
551 551
 	DBG(" old size: %d, new size: %d\n", len, new_len);
552
-	new_buf=(char*)pkg_malloc(new_len+1); /* +1 is for debugging (\0 to print it )*/
552
+	new_buf=(char*)pkg_malloc(new_len+1); /* +1 is for debugging 
553
+											 (\0 to print it )*/
553 554
 	if (new_buf==0){
554 555
 		LOG(L_ERR, "ERROR: build_res_buf_from_sip_res: out of mem\n");
555 556
 		goto error;
... ...
@@ -76,7 +76,8 @@ error:
76 76
 
77 77
 
78 78
 
79
-struct action* mk_action(int type, int p1_type, int p2_type, void* p1, void* p2)
79
+struct action* mk_action(int type, int p1_type, int p2_type,
80
+											void* p1, void* p2)
80 81
 {
81 82
 	struct action* a;
82 83
 	a=(struct action*)malloc(sizeof(struct action));
... ...
@@ -228,7 +228,8 @@ void* find_param_export(char* mod, char* name, modparam_t type)
228 228
 			}
229 229
 		}
230 230
 	}
231
-	DBG("find_param_export: parameter <%s> or module <%s> not found\n", name, mod);
231
+	DBG("find_param_export: parameter <%s> or module <%s> not found\n",
232
+			name, mod);
232 233
 	return 0;
233 234
 }
234 235
 
... ...
@@ -272,7 +273,8 @@ int init_modules(void)
272 272
 	for(t = modules; t; t = t->next) {
273 273
 		if ((t->exports) && (t->exports->init_f))
274 274
 			if (t->exports->init_f() != 0) {
275
-				LOG(L_ERR, "init_modules(): Error while initializing module %s\n", t->exports->name);
275
+				LOG(L_ERR, "init_modules(): Error while initializing"
276
+							" module %s\n", t->exports->name);
276 277
 				return -1;
277 278
 			}
278 279
 	}
... ...
@@ -52,34 +52,30 @@ typedef enum {
52 52
 struct module_exports{
53 53
 	char* name;                     /* null terminated module name */
54 54
 	char** cmd_names;               /* cmd names registered by this modules */
55
-	cmd_function* cmd_pointers;     /* pointers to the corresponding functions */
56
-	int* param_no;                  /* number of parameters used by the function */
55
+	cmd_function* cmd_pointers;     /* pointers to the corresponding
56
+									   functions */
57
+	int* param_no;                  /* number of parameters used
58
+									   by the function */
57 59
 	fixup_function* fixup_pointers; /* pointers to functions called to "fix"
58
-					 * the params, e.g: precompile a re 
59
-					 */
60
-	int cmd_no;       /* number of registered commands
61
-			   * (size of cmd_{names,pointers}
62
-			   */
60
+										the params, e.g: precompile a re */
61
+	int cmd_no;                     /* number of registered commands
62
+										(size of cmd_{names,pointers} */
63 63
 
64 64
 	char** param_names;    /* parameter names registered by this modules */
65 65
 	modparam_t* param_types; /* Type of parameters */
66 66
 	void** param_pointers; /* Pointers to the corresponding memory locations */
67
-	int par_no;            /* Number of registered parameters */
67
+	int par_no;            /* number of registered parameters */
68 68
 
69 69
 
70 70
 	init_function init_f;         /* Initilization function */
71 71
 	response_function response_f; /* function used for responses,
72
-				       * returns yes or no;
73
-				       * can be null 
74
-				       */
72
+									returns yes or no; can be null */
75 73
 	destroy_function destroy_f;  /* function called when the module should
76
-				      * be "destroyed", e.g: on ser exit;
77
-				      * can be null 
78
-				      */
74
+									be "destroyed", e.g: on ser exit;
75
+									can be null */
79 76
 	onbreak_function onbreak_f;
80
-	child_init_function init_child_f;  /* Function will be called by all 
81
-					    * processes after the fork 
82
-					    */
77
+	child_init_function init_child_f;  /* function called by all processes
78
+										  after the fork */
83 79
 };
84 80
 
85 81
 struct sr_module{
... ...
@@ -93,7 +93,8 @@ int init_stats(int nr_of_processes)
93 93
 	stats_segments = nr_of_processes;
94 94
 
95 95
 	if(stats_register() == -1)
96
-		LOG(L_WARN, "init_stats(): Couldn't register stats with snmp module\n");
96
+		LOG(L_WARN, "init_stats(): Couldn't register stats"
97
+					" with snmp module\n");
97 98
 
98 99
 
99 100
 	return 0;
... ...
@@ -42,32 +42,36 @@
42 42
 
43 43
 
44 44
 #define _update_request( method, dir )			\
45
-	{ if (stat_file!=NULL) switch( method ) {	\
45
+	do{ if (stat_file!=NULL) switch( method ) {	\
46 46
           	case METHOD_INVITE: stats->dir##_requests_inv++; break;	\
47 47
           	case METHOD_ACK: stats->dir##_requests_ack++; break;		\
48 48
           	case METHOD_CANCEL: stats->dir##_requests_cnc++; break;	\
49 49
           	case METHOD_BYE: stats->dir##_requests_bye++; break;		\
50 50
           	case METHOD_OTHER: stats->dir##_requests_other++; break;	\
51
-          	default: LOG(L_ERR, "ERROR: unknown method in rq stats (%s)\n", #dir);	\
51
+          	default: LOG(L_ERR, "ERROR: unknown method in rq stats (%s)\n", \
52
+							#dir);	\
52 53
 		}	\
53
-        }
54
+	}while(0)
54 55
 
55 56
 
56 57
 /*
57 58
 #define update_received_request( method ) _update_request( method, received )
58 59
 #define update_sent_request( method ) _update_request( method, sent )
59 60
 
60
-#define update_received_response( statusclass ) _update_response( statusclass, received )
61
-#define update_sent_response( statusclass ) _update_response( statusclass, sent )
61
+#define update_received_response( statusclass ) \
62
+									_update_response( statusclass, received )
63
+#define update_sent_response( statusclass ) \
64
+									_update_response( statusclass, sent )
62 65
 #define update_received_drops	{  stats->received_drops++; }
63 66
 #define update_fail_on_send	{  stats->failed_on_send++; }
64 67
 */
65 68
 
66
-#define         _statusline(class, dir )       case class: stats->dir##_responses_##class++; break;
69
+#define         _statusline(class, dir )\
70
+						case class: stats->dir##_responses_##class++; break;
67 71
 
68 72
 /* FIXME: Don't have case for _other (see received_responses_other) */
69 73
 #define _update_response( statusclass, dir )		\
70
-        { if (stat_file!=NULL)                          \
74
+        do{ if (stat_file!=NULL)                          \
71 75
                 switch( statusclass ) {                 \
72 76
                         _statusline(1, dir)                   \
73 77
                         _statusline(2, dir)                   \
... ...
@@ -75,9 +79,10 @@
75 75
                         _statusline(4, dir)                   \
76 76
                         _statusline(5, dir)                   \
77 77
                         _statusline(6, dir)                   \
78
-                        default: LOG(L_INFO, "ERROR: unusual status code received in stats (%s)\n", #dir);    \
78
+                        default: LOG(L_INFO, "ERROR: unusual status code"\
79
+										 " received in stats (%s)\n", #dir); \
79 80
                 }       \
80
-        }
81
+        }while(0)
81 82
 
82 83
 #ifdef STATS
83 84
 #	define STATS_RX_REQUEST(method) _update_request(method, received)
... ...
@@ -322,8 +322,8 @@ int udp_rcv_loop()
322 322
 #endif
323 323
 #ifdef DBG_MSG_QA
324 324
 		if (!dbg_msg_qa(buf, len)) {
325
-			LOG(L_WARN, "WARNING: an incoming message didn't pass test, drop it: %.*s\n",
326
-				len, buf );
325
+			LOG(L_WARN, "WARNING: an incoming message didn't pass test,"
326
+						"  drop it: %.*s\n", len, buf );
327 327
 			continue;
328 328
 		}
329 329
 #endif
... ...
@@ -348,7 +348,8 @@ error:
348 348
 
349 349
 
350 350
 /* which socket to use? main socket or new one? */
351
-int udp_send(struct socket_info *source, char *buf, unsigned len, union sockaddr_union*  to)
351
+int udp_send(struct socket_info *source, char *buf, unsigned len,
352
+										union sockaddr_union*  to)
352 353
 {
353 354
 
354 355
 	int n;
... ...
@@ -46,7 +46,8 @@ struct sip_msg;
46 46
 #define trim_len( _len, _begin, _mystr ) \
47 47
 	do{ 	static char _c; \
48 48
 		(_len)=(_mystr).len; \
49
-		while ((_len) && ((_c=(_mystr).s[(_len)-1])==0 || _c=='\r' || _c=='\n' || _c==' ' || _c=='\t' )) \
49
+		while ((_len) && ((_c=(_mystr).s[(_len)-1])==0 || _c=='\r' || \
50
+					_c=='\n' || _c==' ' || _c=='\t' )) \
50 51
 			(_len)--; \
51 52
 		(_begin)=(_mystr).s; \
52 53
 		while ((_len) && ((_c=*(_begin))==' ' || _c=='\t')) { \