Browse code

http_client: clang format the code

Daniel-Constantin Mierla authored on 05/12/2017 14:20:55
Showing 1 changed files
... ...
@@ -32,75 +32,62 @@
32 32
 #include "curlcon.h"
33 33
 
34 34
 
35
-static const char* curl_rpc_listcon_doc[2] = {
36
-	"List all CURL connection definitions",
37
-	0
38
-};
35
+static const char *curl_rpc_listcon_doc[2] = {
36
+		"List all CURL connection definitions", 0};
39 37
 
40 38
 
41 39
 /*
42 40
  * RPC command to print curl destination sets
43 41
  */
44
-static void curl_rpc_listcon(rpc_t* rpc, void* ctx)
42
+static void curl_rpc_listcon(rpc_t *rpc, void *ctx)
45 43
 {
46
-	void* th;
47
-	void* rh;
44
+	void *th;
45
+	void *rh;
48 46
 	curl_con_t *cc;
49 47
 
50 48
 	cc = _curl_con_root;
51
-	if(cc==NULL)
52
-	{
49
+	if(cc == NULL) {
53 50
 		LM_ERR("no connection definitions\n");
54 51
 		rpc->fault(ctx, 500, "No Connection Definitions");
55 52
 		return;
56 53
 	}
57 54
 
58 55
 	/* add entry node */
59
-	if (rpc->add(ctx, "{", &th) < 0)
60
-	{
56
+	if(rpc->add(ctx, "{", &th) < 0) {
61 57
 		rpc->fault(ctx, 500, "Internal error root reply");
62 58
 		return;
63 59
 	}
64 60
 
65
-        while(cc)
66
-        {
67
-		int timeout = (int) cc->timeout;
68
-		if (rpc->struct_add(th, "{", "CONNECTION", &rh) < 0)
69
-		{
61
+	while(cc) {
62
+		int timeout = (int)cc->timeout;
63
+		if(rpc->struct_add(th, "{", "CONNECTION", &rh) < 0) {
70 64
 			rpc->fault(ctx, 500, "Internal error set structure");
71 65
 			return;
72 66
 		}
73 67
 
74
-		if(rpc->struct_add(rh, "SSSSSSd", 
75
-				"NAME", &cc->name,
76
-				"SCHEMA", &cc->schema,
77
-				"URI", &cc->url,
78
-				"USERNAME", &cc->username,
79
-				"PASSWORD", &cc->password,
80
-				"FAILOVER", &cc->failover,
81
-				"TIMEOUT", timeout
82
-				) < 0) {
68
+		if(rpc->struct_add(rh, "SSSSSSd", "NAME", &cc->name, "SCHEMA",
69
+				   &cc->schema, "URI", &cc->url, "USERNAME", &cc->username,
70
+				   "PASSWORD", &cc->password, "FAILOVER", &cc->failover,
71
+				   "TIMEOUT", timeout)
72
+				< 0) {
83 73
 			rpc->fault(ctx, 500, "Internal error set structure");
84 74
 			return;
85 75
 		}
86
-                cc = cc->next;
87
-        }
76
+		cc = cc->next;
77
+	}
88 78
 	return;
89 79
 }
90 80
 
91 81
 rpc_export_t curl_rpc_cmds[] = {
92
-	{"httpclient.listcon",   curl_rpc_listcon,
93
-		curl_rpc_listcon_doc,   0},
94
-	{0, 0, 0, 0}
95
-};
82
+		{"httpclient.listcon", curl_rpc_listcon, curl_rpc_listcon_doc, 0},
83
+		{0, 0, 0, 0}};
96 84
 
97 85
 /**
98 86
  * register RPC commands
99 87
  */
100 88
 int curl_init_rpc(void)
101 89
 {
102
-	if (rpc_register_array(curl_rpc_cmds)!=0)
103
-	{
90
+	if(rpc_register_array(curl_rpc_cmds) != 0) {
104 91
 		LM_ERR("failed to register RPC commands\n");
105 92
 		return -1;
106 93
 	}
Browse code

core, lib, modules: updated include paths for header files

Daniel-Constantin Mierla authored on 07/12/2016 11:07:22
Showing 1 changed files
... ...
@@ -25,9 +25,9 @@
25 25
  * \ingroup http_client
26 26
  */
27 27
 
28
-#include "../../dprint.h"
29
-#include "../../rpc.h"
30
-#include "../../rpc_lookup.h"
28
+#include "../../core/dprint.h"
29
+#include "../../core/rpc.h"
30
+#include "../../core/rpc_lookup.h"
31 31
 #include "http_client.h"
32 32
 #include "curlcon.h"
33 33
 
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,108 @@
1
+/*
2
+ * Copyright (C) 2015 Olle E. Johansson, Edvina AB
3
+ * RPC functions
4
+ *
5
+ * This file is part of kamailio, a free SIP server.
6
+ *
7
+ * Kamailio is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 2 of the License, or
10
+ * (at your option) any later version
11
+ *
12
+ * Kamailio is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program; if not, write to the Free Software
19
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
+ */
21
+
22
+
23
+/*! \file
24
+ * \brief  Kamailio http_client :: RPC functions
25
+ * \ingroup http_client
26
+ */
27
+
28
+#include "../../dprint.h"
29
+#include "../../rpc.h"
30
+#include "../../rpc_lookup.h"
31
+#include "http_client.h"
32
+#include "curlcon.h"
33
+
34
+
35
+static const char* curl_rpc_listcon_doc[2] = {
36
+	"List all CURL connection definitions",
37
+	0
38
+};
39
+
40
+
41
+/*
42
+ * RPC command to print curl destination sets
43
+ */
44
+static void curl_rpc_listcon(rpc_t* rpc, void* ctx)
45
+{
46
+	void* th;
47
+	void* rh;
48
+	curl_con_t *cc;
49
+
50
+	cc = _curl_con_root;
51
+	if(cc==NULL)
52
+	{
53
+		LM_ERR("no connection definitions\n");
54
+		rpc->fault(ctx, 500, "No Connection Definitions");
55
+		return;
56
+	}
57
+
58
+	/* add entry node */
59
+	if (rpc->add(ctx, "{", &th) < 0)
60
+	{
61
+		rpc->fault(ctx, 500, "Internal error root reply");
62
+		return;
63
+	}
64
+
65
+        while(cc)
66
+        {
67
+		int timeout = (int) cc->timeout;
68
+		if (rpc->struct_add(th, "{", "CONNECTION", &rh) < 0)
69
+		{
70
+			rpc->fault(ctx, 500, "Internal error set structure");
71
+			return;
72
+		}
73
+
74
+		if(rpc->struct_add(rh, "SSSSSSd", 
75
+				"NAME", &cc->name,
76
+				"SCHEMA", &cc->schema,
77
+				"URI", &cc->url,
78
+				"USERNAME", &cc->username,
79
+				"PASSWORD", &cc->password,
80
+				"FAILOVER", &cc->failover,
81
+				"TIMEOUT", timeout
82
+				) < 0) {
83
+			rpc->fault(ctx, 500, "Internal error set structure");
84
+			return;
85
+		}
86
+                cc = cc->next;
87
+        }
88
+	return;
89
+}
90
+
91
+rpc_export_t curl_rpc_cmds[] = {
92
+	{"httpclient.listcon",   curl_rpc_listcon,
93
+		curl_rpc_listcon_doc,   0},
94
+	{0, 0, 0, 0}
95
+};
96
+
97
+/**
98
+ * register RPC commands
99
+ */
100
+int curl_init_rpc(void)
101
+{
102
+	if (rpc_register_array(curl_rpc_cmds)!=0)
103
+	{
104
+		LM_ERR("failed to register RPC commands\n");
105
+		return -1;
106
+	}
107
+	return 0;
108
+}