Browse code

http_client Fix formatting of source code

Olle E. Johansson authored on 04/04/2016 20:12:42
Showing 2 changed files
... ...
@@ -82,17 +82,17 @@ size_t write_function( void *ptr, size_t size, size_t nmemb, void *stream_ptr)
82 82
 
83 83
 
84 84
 	if (stream->max_size == 0 || stream->curr_size < stream->max_size) {
85
-	    char *tmp = (char *) pkg_realloc(stream->buf, stream->curr_size + (size * nmemb));
85
+		char *tmp = (char *) pkg_realloc(stream->buf, stream->curr_size + (size * nmemb));
86 86
 
87
-	    if (tmp == NULL) {
88
-	        LM_ERR("cannot allocate memory for stream\n");
89
-	        return CURLE_WRITE_ERROR;
87
+	    	if (tmp == NULL) {
88
+	        	LM_ERR("cannot allocate memory for stream\n");
89
+	        	return CURLE_WRITE_ERROR;
90 90
 		}
91
-	    stream->buf = tmp;
91
+	    	stream->buf = tmp;
92 92
 
93 93
 		memcpy(&stream->buf[stream->pos], (char *) ptr, (size * nmemb));
94 94
 
95
-	    stream->curr_size += ((size * nmemb));
95
+	    	stream->curr_size += ((size * nmemb));
96 96
 		stream->pos += (size * nmemb);
97 97
 
98 98
 	}  else {
... ...
@@ -321,9 +321,9 @@ static int curL_query_url(struct sip_msg* _m, const char* _url, str* _dst, const
321 321
 		if(url) {
322 322
 	    		LM_DBG("We visited URL: %s\n", url);
323 323
 			if (params->pconn) {
324
-			strncpy(params->pconn->redirecturl, url , sizeof(params->pconn->redirecturl));
325
-		}
326
-	    }
324
+				strncpy(params->pconn->redirecturl, url , sizeof(params->pconn->redirecturl));
325
+			}
326
+	    	}
327 327
 	}
328 328
 	if (params->pconn) {
329 329
 		params->pconn->last_result = stat;
... ...
@@ -379,7 +379,7 @@ static int curL_query_url(struct sip_msg* _m, const char* _url, str* _dst, const
379 379
 		curl_easy_cleanup(curl);
380 380
 	}
381 381
 	if (stream.buf != NULL) {
382
-	    pkg_free(stream.buf);
382
+		pkg_free(stream.buf);
383 383
 	}
384 384
 	return stat;
385 385
 }
... ...
@@ -455,8 +455,7 @@ int curl_con_query_url(struct sip_msg* _m, const str *connection, const str* url
455 455
 	if (url && (url->len > 0) && (url->s != NULL)) {
456 456
 		int url_len = conn->schema.len + 3 + conn->url.len + 1 + url->len + 1;
457 457
 		urlbuf = pkg_malloc(url_len);
458
-		if (urlbuf == NULL)
459
-		{
458
+		if (urlbuf == NULL) {
460 459
 			res = -1;
461 460
 			goto error;
462 461
 		}
... ...
@@ -468,8 +467,7 @@ int curl_con_query_url(struct sip_msg* _m, const str *connection, const str* url
468 468
 	} else {
469 469
 		int url_len = conn->schema.len + 3 + conn->url.len + 1;
470 470
 		urlbuf = pkg_malloc(url_len);
471
-		if (urlbuf == NULL)
472
-		{
471
+		if (urlbuf == NULL) {
473 472
 			res = -1;
474 473
 			goto error;
475 474
 		}
... ...
@@ -484,10 +482,10 @@ int curl_con_query_url(struct sip_msg* _m, const str *connection, const str* url
484 484
 		/* Allocated using pkg_memory */
485 485
 		postdata = as_asciiz((str*)post);
486 486
 		if (postdata  == NULL) {
487
-	    	    ERR("Curl: No memory left\n");
488
-		    res = -1;
489
-		    goto error;
490
-	            }
487
+	    	    	ERR("Curl: No memory left\n");
488
+		    	res = -1;
489
+		    	goto error;
490
+	        }
491 491
 		LM_DBG("***** #### ***** CURL POST data: %s Content-type %s\n", postdata, contenttype);
492 492
 	}
493 493
 
... ...
@@ -164,7 +164,7 @@ static param_export_t params[] = {
164 164
 	{"httpcon",  PARAM_STRING|USE_FUNC_PARAM, (void*)curl_con_param},
165 165
 	{"authmetod", PARAM_INT, &default_authmethod },
166 166
 	{"keep_connections", PARAM_INT, &default_keep_connections },
167
-    	{0, 0, 0}
167
+	{0, 0, 0}
168 168
 };
169 169
 
170 170
 
... ...
@@ -172,26 +172,26 @@ static param_export_t params[] = {
172 172
  * \brief Exported Pseudo variables
173 173
  */
174 174
 static pv_export_t mod_pvs[] = {
175
-    {{"curlerror", (sizeof("curlerror")-1)}, /* Curl error codes */
176
-     PVT_OTHER, pv_get_curlerror, 0, pv_parse_curlerror, 0, 0, 0},
175
+	{{"curlerror", (sizeof("curlerror")-1)}, /* Curl error codes */
176
+	PVT_OTHER, pv_get_curlerror, 0, pv_parse_curlerror, 0, 0, 0},
177 177
 
178
-    {{0, 0}, 0, 0, 0, 0, 0, 0, 0}
178
+	{{0, 0}, 0, 0, 0, 0, 0, 0, 0}
179 179
 };
180 180
 
181 181
 /* Module interface */
182 182
 struct module_exports exports = {
183
-    "http_client",
184
-    DEFAULT_DLFLAGS, /* dlopen flags */
185
-    cmds,      /* Exported functions */
186
-    params,    /* Exported parameters */
187
-    0,         /* exported statistics */
188
-    0,   	/* exported MI functions */
189
-    mod_pvs,         /* exported pseudo-variables */
190
-    0,         /* extra processes */
191
-    mod_init,  /* module initialization function */
192
-    0,         /* response function*/
193
-    destroy,   /* destroy function */
194
-    child_init /* per-child init function */
183
+	"http_client",
184
+	DEFAULT_DLFLAGS, /* dlopen flags */
185
+	cmds,      /* Exported functions */
186
+	params,    /* Exported parameters */
187
+	0,         /* exported statistics */
188
+	0,   	/* exported MI functions */
189
+	mod_pvs,         /* exported pseudo-variables */
190
+	0,         /* extra processes */
191
+	mod_init,  /* module initialization function */
192
+	0,         /* response function*/
193
+	destroy,   /* destroy function */
194
+	child_init /* per-child init function */
195 195
 };
196 196
 
197 197
 counter_handle_t connections;	/* Number of connection definitions */
... ...
@@ -350,24 +350,24 @@ error:
350 350
  */
351 351
 static int fixup_http_query_get(void** param, int param_no)
352 352
 {
353
-    if (param_no == 1) {
354
-	return fixup_spve_null(param, 1);
355
-    }
356
-
357
-    if (param_no == 2) {
358
-	if (fixup_pvar_null(param, 1) != 0) {
359
-	    LM_ERR("failed to fixup result pvar\n");
360
-	    return -1;
353
+	if (param_no == 1) {
354
+		return fixup_spve_null(param, 1);
361 355
 	}
362
-	if (((pv_spec_t *)(*param))->setf == NULL) {
363
-	    LM_ERR("result pvar is not writeble\n");
364
-	    return -1;
356
+
357
+	if (param_no == 2) {
358
+		if (fixup_pvar_null(param, 1) != 0) {
359
+			LM_ERR("failed to fixup result pvar\n");
360
+			return -1;
361
+		}
362
+		if (((pv_spec_t *)(*param))->setf == NULL) {
363
+			LM_ERR("result pvar is not writeble\n");
364
+			return -1;
365
+		}
366
+		return 0;
365 367
 	}
366
-	return 0;
367
-    }
368 368
 
369
-    LM_ERR("invalid parameter number <%d>\n", param_no);
370
-    return -1;
369
+	LM_ERR("invalid parameter number <%d>\n", param_no);
370
+	return -1;
371 371
 }
372 372
 
373 373
 /*
... ...
@@ -376,7 +376,7 @@ static int fixup_http_query_get(void** param, int param_no)
376 376
 static int fixup_free_http_query_get(void** param, int param_no)
377 377
 {
378 378
     if (param_no == 1) {
379
-        return fixup_free_spve_null(param, 1);
379
+		return fixup_free_spve_null(param, 1);
380 380
     }
381 381
 
382 382
     if (param_no == 2) {
... ...
@@ -401,7 +401,7 @@ static int fixup_curl_connect(void** param, int param_no)
401 401
     }
402 402
     /* URL and data may contain pvar */
403 403
     if (param_no == 2) {
404
-        return fixup_spve_null(param, 1);
404
+		return fixup_spve_null(param, 1);
405 405
     }
406 406
     if (param_no == 3) {
407 407
 	if (fixup_pvar_null(param, 1) != 0) {
... ...
@@ -433,7 +433,7 @@ static int fixup_curl_connect_post(void** param, int param_no)
433 433
     }
434 434
     /* URL and data may contain pvar */
435 435
     if (param_no == 2 || param_no == 4) {
436
-        return fixup_spve_null(param, 1);
436
+		return fixup_spve_null(param, 1);
437 437
     }
438 438
     if (param_no == 5) {
439 439
 	if (fixup_pvar_null(param, 1) != 0) {
... ...
@@ -462,7 +462,7 @@ static int fixup_free_curl_connect_post(void** param, int param_no)
462 462
 	return 0;
463 463
     }
464 464
     if (param_no == 2 || param_no == 4) {
465
-        return fixup_free_spve_null(param, 1);
465
+		return fixup_free_spve_null(param, 1);
466 466
     }
467 467
 
468 468
     if (param_no == 5) {
... ...
@@ -483,7 +483,7 @@ static int fixup_free_curl_connect(void** param, int param_no)
483 483
 	return 0;
484 484
     }
485 485
     if (param_no == 2) {
486
-        return fixup_free_spve_null(param, 1);
486
+		return fixup_free_spve_null(param, 1);
487 487
     }
488 488
 
489 489
     if (param_no == 3) {
... ...
@@ -607,7 +607,7 @@ static int fixup_http_query_post(void** param, int param_no)
607 607
 static int fixup_free_http_query_post(void** param, int param_no)
608 608
 {
609 609
     if ((param_no == 1) || (param_no == 2)) {
610
-        return fixup_free_spve_null(param, 1);
610
+		return fixup_free_spve_null(param, 1);
611 611
     }
612 612
 
613 613
     if (param_no == 3) {
... ...
@@ -757,16 +757,16 @@ static int fixup_curl_get_redirect(void** param, int param_no)
757 757
  */
758 758
 static int fixup_free_curl_get_redirect(void** param, int param_no)
759 759
 {
760
-    if (param_no == 1) {
761
-	/* Char strings don't need freeing */
762
-	return 0;
763
-    }
764
-    if (param_no == 2) {
765
-        return fixup_free_spve_null(param, 1);
766
-    }
760
+	if (param_no == 1) {
761
+		/* Char strings don't need freeing */
762
+		return 0;
763
+	}
764
+	if (param_no == 2) {
765
+		return fixup_free_spve_null(param, 1);
766
+	}
767 767
 
768
-    LM_ERR("invalid parameter number <%d>\n", param_no);
769
-    return -1;
768
+	LM_ERR("invalid parameter number <%d>\n", param_no);
769
+	return -1;
770 770
 }
771 771
 
772 772
 /*