Browse code

core: coherent whitespacing and indentation

Daniel-Constantin Mierla authored on 25/05/2017 03:29:13
Showing 9 changed files
... ...
@@ -40,7 +40,7 @@
40 40
 #include <string.h>
41 41
 #include <stdio.h>
42 42
 #include <stdlib.h>
43
-#include <sys/time.h>    
43
+#include <sys/time.h>
44 44
 #include <sys/resource.h> /* setrlimit */
45 45
 #include <unistd.h>
46 46
 #include <pwd.h>
... ...
@@ -101,7 +101,7 @@ void daemon_status_init()
101 101
 int daemon_status_pre_daemonize(void)
102 102
 {
103 103
 	int ret;
104
-	
104
+
105 105
 retry:
106 106
 	ret = pipe(daemon_status_fd);
107 107
 	if (ret < 0 && errno == EINTR)
... ...
@@ -123,7 +123,7 @@ retry:
123 123
 int daemon_status_wait(char* status)
124 124
 {
125 125
 	int ret;
126
-	
126
+
127 127
 	/* close the output side of the pipe */
128 128
 	if (daemon_status_fd[1] != -1) {
129 129
 		close(daemon_status_fd[1]);
... ...
@@ -249,7 +249,7 @@ int enable_dumpable(void)
249 249
  * pid_file - if set the pid will be written here (ascii).
250 250
  * pgid_file - if set, the pgid will be written here (ascii).
251 251
  * log_stderr - if not set syslog will be opened (openlog(name,...))
252
- * 
252
+ *
253 253
  *
254 254
  * Side-effects:
255 255
  *  sets own_pgid after becoming session leader (own process group).
... ...
@@ -280,7 +280,7 @@ int daemonize(char*  name,  int status_wait)
280 280
 		LM_CRIT("Cannot chroot to %s: %s\n", chroot_dir, strerror(errno));
281 281
 		goto error;
282 282
 	}
283
-	
283
+
284 284
 	if (chdir(working_dir)<0){
285 285
 		LM_CRIT("cannot chdir to %s: %s\n", working_dir, strerror(errno));
286 286
 		goto error;
... ...
@@ -329,7 +329,7 @@ int daemonize(char*  name,  int status_wait)
329 329
 
330 330
 	/* added by noh: create a pid file for the main process */
331 331
 	if (pid_file!=0){
332
-		
332
+
333 333
 		if ((pid_stream=fopen(pid_file, "r"))!=NULL){
334 334
 			if (fscanf(pid_stream, "%d", &p) < 0) {
335 335
 				LM_WARN("could not parse pid file %s\n", pid_file);
... ...
@@ -350,7 +350,7 @@ int daemonize(char*  name,  int status_wait)
350 350
 		}
351 351
 		pid=getpid();
352 352
 		if ((pid_stream=fopen(pid_file, "w"))==NULL){
353
-			LM_WARN("unable to create pid file %s: %s\n", 
353
+			LM_WARN("unable to create pid file %s: %s\n",
354 354
 				pid_file, strerror(errno));
355 355
 			goto error;
356 356
 		}else{
... ...
@@ -396,7 +396,7 @@ int daemonize(char*  name,  int status_wait)
396 396
 								  value*/
397 397
 		}
398 398
 	}
399
-	
399
+
400 400
 	/* try to replace stdin, stdout & stderr with /dev/null */
401 401
 	if (freopen("/dev/null", "r", stdin)==0){
402 402
 		LM_ERR("unable to replace stdin with /dev/null: %s\n",
... ...
@@ -414,7 +414,7 @@ int daemonize(char*  name,  int status_wait)
414 414
 				strerror(errno));
415 415
 		/* continue, leave it open */
416 416
 	};
417
-	
417
+
418 418
 	/* close all but the daemon_status_fd output as the main process
419 419
 	  must still write into it to tell the parent to exit with 0 */
420 420
 	closelog();
... ...
@@ -422,7 +422,7 @@ int daemonize(char*  name,  int status_wait)
422 422
 		if(r !=  daemon_status_fd[1])
423 423
 			close(r);
424 424
 	}
425
-	
425
+
426 426
 	if (log_stderr==0)
427 427
 		openlog(name, LOG_PID|LOG_CONS, cfg_get(core, core_cfg, log_facility));
428 428
 		/* LOG_CONS, LOG_PERRROR ? */
... ...
@@ -438,7 +438,7 @@ error:
438 438
 int do_suid()
439 439
 {
440 440
 	struct passwd *pw;
441
-	
441
+
442 442
 	if (gid){
443 443
 		if(gid!=getgid()) {
444 444
 			if(setgid(gid)<0){
... ...
@@ -447,7 +447,7 @@ int do_suid()
447 447
 			}
448 448
 		}
449 449
 	}
450
-	
450
+
451 451
 	if(uid){
452 452
 		if (!(pw = getpwuid(uid))){
453 453
 			LM_CRIT("user lookup failed: %s\n", strerror(errno));
... ...
@@ -455,7 +455,7 @@ int do_suid()
455 455
 		}
456 456
 		if(uid!=getuid()) {
457 457
 			if(initgroups(pw->pw_name, pw->pw_gid)<0){
458
-				LM_CRIT("cannot set supplementary groups: %s\n", 
458
+				LM_CRIT("cannot set supplementary groups: %s\n",
459 459
 							strerror(errno));
460 460
 				goto error;
461 461
 			}
... ...
@@ -481,7 +481,7 @@ int increase_open_fds(int target)
481 481
 {
482 482
 	struct rlimit lim;
483 483
 	struct rlimit orig;
484
-	
484
+
485 485
 	if (getrlimit(RLIMIT_NOFILE, &lim)<0){
486 486
 		LM_CRIT("cannot get the maximum number of file descriptors: %s\n",
487 487
 				strerror(errno));
... ...
@@ -498,7 +498,7 @@ int increase_open_fds(int target)
498 498
 	}else{
499 499
 		/* more than the hard limit */
500 500
 		LM_INFO("trying to increase the open file limit"
501
-				" past the hard limit (%ld -> %d)\n", 
501
+				" past the hard limit (%ld -> %d)\n",
502 502
 				(unsigned long)lim.rlim_max, target);
503 503
 		lim.rlim_max=target;
504 504
 		lim.rlim_cur=target;
... ...
@@ -535,7 +535,7 @@ int set_core_dump(int enable, long unsigned int size)
535 535
 {
536 536
 	struct rlimit lim;
537 537
 	struct rlimit newlim;
538
-	
538
+
539 539
 	if (enable){
540 540
 		if (getrlimit(RLIMIT_CORE, &lim)<0){
541 541
 			LM_CRIT("cannot get the maximum core size: %s\n",
... ...
@@ -603,11 +603,11 @@ error:
603 603
 #else /* if MLOCKALL not defined return error */
604 604
 		LM_WARN("failed to lock the memory pages: no mlockall support\n");
605 605
 	return -1;
606
-#endif 
606
+#endif
607 607
 }
608 608
 
609 609
 
610
-/*! \brief tries to set real time priority 
610
+/*! \brief tries to set real time priority
611 611
  * policy: 0 - SCHED_OTHER, 1 - SCHED_RR, 2 - SCHED_FIFO */
612 612
 int set_rt_prio(int prio, int policy)
613 613
 {
... ...
@@ -615,7 +615,7 @@ int set_rt_prio(int prio, int policy)
615 615
 	struct sched_param sch_p;
616 616
 	int min_prio, max_prio;
617 617
 	int sched_policy;
618
-	
618
+
619 619
 	switch(policy){
620 620
 		case 0:
621 621
 			sched_policy=SCHED_OTHER;
... ...
@@ -18,11 +18,11 @@
18 18
  * \file
19 19
  * \brief Kamailio core :: Daemonize
20 20
  * \author andrei
21
- *      
22
- * \ingroup core 
23
- * Module: \ref core                    
24
- *  
25
- * 
21
+ *
22
+ * \ingroup core
23
+ * Module: \ref core
24
+ *
25
+ *
26 26
  */
27 27
 
28 28
 #ifndef _daemonize_h
... ...
@@ -1,7 +1,6 @@
1 1
 /*
2 2
  * proxy list & assoc. functions
3 3
  *
4
- *
5 4
  * Copyright (C) 2001-2003 FhG Fokus
6 5
  *
7 6
  * This file is part of Kamailio, a free SIP server.
... ...
@@ -16,8 +15,8 @@
16 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 16
  * GNU General Public License for more details.
18 17
  *
19
- * You should have received a copy of the GNU General Public License 
20
- * along with this program; if not, write to the Free Software 
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
21 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 21
  */
23 22
 
... ...
@@ -54,9 +53,9 @@ struct proxy_l* proxies=0;
54 53
 
55 54
 
56 55
 
57
-/* searches for the proxy named 'name', on port 'port' with 
56
+/* searches for the proxy named 'name', on port 'port' with
58 57
    proto 'proto'; if proto==0 => proto wildcard (will match any proto)
59
-   returns: pointer to proxy_l on success or 0 if not found */ 
58
+   returns: pointer to proxy_l on success or 0 if not found */
60 59
 static struct proxy_l* find_proxy(str *name, unsigned short port, int proto)
61 60
 {
62 61
 	struct proxy_l* t;
... ...
@@ -206,7 +205,7 @@ void free_shm_hostent(struct hostent* dst)
206 205
 struct proxy_l* add_proxy(str* name, unsigned short port, int proto)
207 206
 {
208 207
 	struct proxy_l* p;
209
-	
208
+
210 209
 	if ((p=find_proxy(name, port, proto))!=0) return p;
211 210
 	if ((p=mk_proxy(name, port, proto))==0) goto error;
212 211
 	/* add p to the proxy list */
... ...
@@ -13,13 +13,13 @@
13 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
  * GNU General Public License for more details.
15 15
  *
16
- * You should have received a copy of the GNU General Public License 
17
- * along with this program; if not, write to the Free Software 
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 19
  */
20 20
 /*!
21 21
  * \file
22
- * \brief Kamailio core :: Proxy 
22
+ * \brief Kamailio core :: Proxy
23 23
  * \ingroup core
24 24
  * \author andrei
25 25
  * Module: \ref core
... ...
@@ -40,7 +40,7 @@ struct proxy_l{
40 40
 	unsigned short port;
41 41
 	unsigned short reserved; /*align*/
42 42
 	int proto;
43
-	
43
+
44 44
 	/* socket ? */
45 45
 
46 46
 	int addr_idx;	/* crt. addr. idx. */
... ...
@@ -62,7 +62,6 @@ void free_proxy(struct proxy_l* p);
62 62
 void free_shm_proxy(struct proxy_l* p);
63 63
 
64 64
 
65
-
66 65
 /** returns 0 on success, -1 on error (unknown af/bug) */
67 66
 inline static int proxy2su(union sockaddr_union* su, struct proxy_l* p)
68 67
 {
... ...
@@ -73,13 +72,12 @@ inline static int proxy2su(union sockaddr_union* su, struct proxy_l* p)
73 72
 		else p->addr_idx=0;
74 73
 		p->ok=1;
75 74
 	}
76
-	
75
+
77 76
 	return hostent2su(su, &p->host, p->addr_idx,
78 77
 				(p->port)?p->port:((p->proto==PROTO_TLS)?SIPS_PORT:SIP_PORT) );
79 78
 }
80 79
 
81 80
 
82
-
83 81
 /** mark proxy either as ok (err>=0) or as bad (err<0) */
84 82
 inline static void proxy_mark(struct proxy_l* p, int err)
85 83
 {
... ...
@@ -92,6 +90,5 @@ inline static void proxy_mark(struct proxy_l* p, int err)
92 90
 }
93 91
 
94 92
 
95
-
96 93
 #endif
97 94
 
... ...
@@ -1,4 +1,4 @@
1
-/* 
1
+/*
2 2
  * Copyright (C) 2010 iptelorg GmbH
3 3
  *
4 4
  * Permission to use, copy, modify, and distribute this software for any
... ...
@@ -1,4 +1,4 @@
1
-/* 
1
+/*
2 2
  * Copyright (C) 2010 iptelorg GmbH
3 3
  *
4 4
  * Permission to use, copy, modify, and distribute this software for any
... ...
@@ -13,8 +13,8 @@
13 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
  * GNU General Public License for more details.
15 15
  *
16
- * You should have received a copy of the GNU General Public License 
17
- * along with this program; if not, write to the Free Software 
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 19
  */
20 20
 
... ...
@@ -36,14 +36,14 @@ void (*set_sig_h(int sig, void (*handler) (int) ))(int)
36 36
 {
37 37
 	struct sigaction act;
38 38
 	struct sigaction old;
39
-	
39
+
40 40
 	memset(&act, 0, sizeof(act));
41 41
 	act.sa_handler=handler;
42 42
 	/*
43 43
 	sigemptyset(&act.sa_mask);
44 44
 	act.sa_flags=0;
45 45
 	*/
46
-	/* sa_sigaction not set, we use sa_hanlder instead */ 
46
+	/* sa_sigaction not set, we use sa_hanlder instead */
47 47
 	return (sigaction (sig, &act, &old)==-1)?SIG_ERR:old.sa_handler;
48 48
 }
49 49
 #endif
... ...
@@ -13,8 +13,8 @@
13 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
  * GNU General Public License for more details.
15 15
  *
16
- * You should have received a copy of the GNU General Public License 
17
- * along with this program; if not, write to the Free Software 
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18 18
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19 19
  */
20 20
 /*! \file
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- * Copyright (C) 2007 iptelorg GmbH 
2
+ * Copyright (C) 2007 iptelorg GmbH
3 3
  *
4 4
  * Permission to use, copy, modify, and distribute this software for any
5 5
  * purpose with or without fee is hereby granted, provided that the above
... ...
@@ -63,14 +63,14 @@ struct tls_hooks{
63 63
 	int  (*on_tcpconn_init)(struct tcp_connection *c, int sock);
64 64
 	void (*tcpconn_clean)(struct tcp_connection* c);
65 65
 	void (*tcpconn_close)(struct tcp_connection*c , int fd);
66
-	
66
+
67 67
 	/* per listening socket init, called on kamailio startup (after modules,
68 68
 	 *  process table, init() and udp socket initialization)*/
69 69
 	int (*init_si)(struct socket_info* si);
70 70
 	/* generic init function (called at kamailio init, after module initialization
71 71
 	 *  and process table creation)*/
72 72
 	int (*init)(void);
73
-	/* destroy function, called after the modules are destroyed, and 
73
+	/* destroy function, called after the modules are destroyed, and
74 74
 	 * after  destroy_tcp() */
75 75
 	void (*destroy)(void);
76 76
 	/* generic pre-init function (called at kamailio start, before module