Browse code

db_postgres: clang format of the code

Daniel-Constantin Mierla authored on 11/10/2017 16:23:19
Showing 1 changed files
... ...
@@ -37,40 +37,43 @@
37 37
 
38 38
 
39 39
 /*! Postgres specific connection data */
40
-struct pg_con {
41
-	struct db_id* id;        /*!< Connection identifier */
42
-	unsigned int ref;        /*!< Reference count */
43
-	struct pool_con* next;   /*!< Next connection in the pool */
40
+struct pg_con
41
+{
42
+	struct db_id *id;	  /*!< Connection identifier */
43
+	unsigned int ref;	  /*!< Reference count */
44
+	struct pool_con *next; /*!< Next connection in the pool */
44 45
 
45
-	int connected;      /*!< connection status */
46
-	char *sqlurl;		/*!< the url we are connected to, all connection memory parents from this */
47
-	PGconn *con;		/*!< this is the postgres connection */
48
-	PGresult *res;		/*!< this is the current result */
49
-	char**  row;		/*!< Actual row in the result */
50
-	time_t timestamp;	/*!< Timestamp of last query */
51
-	int affected_rows;	/*!< Number of rows affected by the last statement */
52
-	int transaction;	/*!< indicates whether a multi-query transaction is currently open */
46
+	int connected; /*!< connection status */
47
+	char *sqlurl; /*!< the url we are connected to, all connection memory parents from this */
48
+	PGconn *con;	   /*!< this is the postgres connection */
49
+	PGresult *res;	 /*!< this is the current result */
50
+	char **row;		   /*!< Actual row in the result */
51
+	time_t timestamp;  /*!< Timestamp of last query */
52
+	int affected_rows; /*!< Number of rows affected by the last statement */
53
+	int transaction; /*!< indicates whether a multi-query transaction is currently open */
53 54
 };
54 55
 
55
-#define CON_SQLURL(db_con)     (((struct pg_con*)((db_con)->tail))->sqlurl)
56
-#define CON_RESULT(db_con)     (((struct pg_con*)((db_con)->tail))->res)
57
-#define CON_CONNECTION(db_con) (((struct pg_con*)((db_con)->tail))->con)
58
-#define CON_CONNECTED(db_con)  (((struct pg_con*)((db_con)->tail))->connected)
59
-#define CON_ROW(db_con)	       (((struct pg_con*)((db_con)->tail))->row)
60
-#define CON_TIMESTAMP(db_con)  (((struct pg_con*)((db_con)->tail))->timestamp)
61
-#define CON_ID(db_con) 	       (((struct pg_con*)((db_con)->tail))->id)
62
-#define CON_AFFECTED(db_con)   (((struct pg_con*)((db_con)->tail))->affected_rows)
63
-#define CON_TRANSACTION(db_con) (((struct pg_con*)((db_con)->tail))->transaction)
56
+#define CON_SQLURL(db_con) (((struct pg_con *)((db_con)->tail))->sqlurl)
57
+#define CON_RESULT(db_con) (((struct pg_con *)((db_con)->tail))->res)
58
+#define CON_CONNECTION(db_con) (((struct pg_con *)((db_con)->tail))->con)
59
+#define CON_CONNECTED(db_con) (((struct pg_con *)((db_con)->tail))->connected)
60
+#define CON_ROW(db_con) (((struct pg_con *)((db_con)->tail))->row)
61
+#define CON_TIMESTAMP(db_con) (((struct pg_con *)((db_con)->tail))->timestamp)
62
+#define CON_ID(db_con) (((struct pg_con *)((db_con)->tail))->id)
63
+#define CON_AFFECTED(db_con) \
64
+	(((struct pg_con *)((db_con)->tail))->affected_rows)
65
+#define CON_TRANSACTION(db_con) \
66
+	(((struct pg_con *)((db_con)->tail))->transaction)
64 67
 
65 68
 /*
66 69
  * Create a new connection structure,
67 70
  * open the PostgreSQL connection and set reference count to 1
68 71
  */
69
-struct pg_con* db_postgres_new_connection(struct db_id* id);
72
+struct pg_con *db_postgres_new_connection(struct db_id *id);
70 73
 
71 74
 /*
72 75
  * Close the connection and release memory
73 76
  */
74
-void db_postgres_free_connection(struct pool_con* con);
77
+void db_postgres_free_connection(struct pool_con *con);
75 78
 
76 79
 #endif /* KM_PG_CON_H */
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,76 @@
1
+/*
2
+ * Copyright (C) 2003 August.Net Services, LLC
3
+ * Copyright (C) 2008 1&1 Internet AG
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 DB_POSTGRES :: Core
25
+ *  \ingroup db_postgres
26
+ *  Module: \ref db_mysql
27
+ */
28
+
29
+#ifndef KM_PG_CON_H
30
+#define KM_PG_CON_H
31
+
32
+#include "../../lib/srdb1/db_pool.h"
33
+#include "../../lib/srdb1/db_id.h"
34
+
35
+#include <time.h>
36
+#include <libpq-fe.h>
37
+
38
+
39
+/*! Postgres specific connection data */
40
+struct pg_con {
41
+	struct db_id* id;        /*!< Connection identifier */
42
+	unsigned int ref;        /*!< Reference count */
43
+	struct pool_con* next;   /*!< Next connection in the pool */
44
+
45
+	int connected;      /*!< connection status */
46
+	char *sqlurl;		/*!< the url we are connected to, all connection memory parents from this */
47
+	PGconn *con;		/*!< this is the postgres connection */
48
+	PGresult *res;		/*!< this is the current result */
49
+	char**  row;		/*!< Actual row in the result */
50
+	time_t timestamp;	/*!< Timestamp of last query */
51
+	int affected_rows;	/*!< Number of rows affected by the last statement */
52
+	int transaction;	/*!< indicates whether a multi-query transaction is currently open */
53
+};
54
+
55
+#define CON_SQLURL(db_con)     (((struct pg_con*)((db_con)->tail))->sqlurl)
56
+#define CON_RESULT(db_con)     (((struct pg_con*)((db_con)->tail))->res)
57
+#define CON_CONNECTION(db_con) (((struct pg_con*)((db_con)->tail))->con)
58
+#define CON_CONNECTED(db_con)  (((struct pg_con*)((db_con)->tail))->connected)
59
+#define CON_ROW(db_con)	       (((struct pg_con*)((db_con)->tail))->row)
60
+#define CON_TIMESTAMP(db_con)  (((struct pg_con*)((db_con)->tail))->timestamp)
61
+#define CON_ID(db_con) 	       (((struct pg_con*)((db_con)->tail))->id)
62
+#define CON_AFFECTED(db_con)   (((struct pg_con*)((db_con)->tail))->affected_rows)
63
+#define CON_TRANSACTION(db_con) (((struct pg_con*)((db_con)->tail))->transaction)
64
+
65
+/*
66
+ * Create a new connection structure,
67
+ * open the PostgreSQL connection and set reference count to 1
68
+ */
69
+struct pg_con* db_postgres_new_connection(struct db_id* id);
70
+
71
+/*
72
+ * Close the connection and release memory
73
+ */
74
+void db_postgres_free_connection(struct pool_con* con);
75
+
76
+#endif /* KM_PG_CON_H */