Skip to content

Commit

Permalink
matrix: clang-format for coherent indentation and coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed May 18, 2023
1 parent e20a865 commit d6f57ba
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 186 deletions.
30 changes: 16 additions & 14 deletions src/modules/matrix/db_matrix.c
Expand Up @@ -23,7 +23,7 @@
/* TODO assign read-write or read-only URI, introduce a parameter in XML */

//extern str matrix_db_url;
db1_con_t * matrix_dbh = NULL;
db1_con_t *matrix_dbh = NULL;
db_func_t matrix_dbf;

str matrix_table = str_init("matrix");
Expand All @@ -40,8 +40,9 @@ const unsigned int matrix_version = 1;
/*
* Closes the DB connection.
*/
void matrix_db_close(void) {
if (matrix_dbh) {
void matrix_db_close(void)
{
if(matrix_dbh) {
matrix_dbf.close(matrix_dbh);
matrix_dbh = NULL;
}
Expand All @@ -54,22 +55,23 @@ void matrix_db_close(void) {
*
* \return 0 means ok, -1 means an error occurred.
*/
int matrix_db_init(void) {
if (!matrix_db_url.s || !matrix_db_url.len) {
int matrix_db_init(void)
{
if(!matrix_db_url.s || !matrix_db_url.len) {
LM_ERR("you have to set the db_url module parameter.\n");
return -1;
}
if (db_bind_mod(&matrix_db_url, &matrix_dbf) < 0) {
if(db_bind_mod(&matrix_db_url, &matrix_dbf) < 0) {
LM_ERR("can't bind database module.\n");
return -1;
}
if ((matrix_dbh = matrix_dbf.init(&matrix_db_url)) == NULL) {
if((matrix_dbh = matrix_dbf.init(&matrix_db_url)) == NULL) {
LM_ERR("can't connect to database.\n");
return -1;
}
if (
(db_check_table_version(&matrix_dbf, matrix_dbh, &matrix_table, matrix_version) < 0)
) {
if((db_check_table_version(
&matrix_dbf, matrix_dbh, &matrix_table, matrix_version)
< 0)) {
DB_TABLE_VERSION_ERROR(matrix_table);
matrix_db_close();
return -1;
Expand All @@ -86,14 +88,14 @@ int matrix_db_init(void) {
*
* \return 0 means ok, -1 means an error occurred.
*/
int matrix_db_open(void) {
if (matrix_dbh) {
int matrix_db_open(void)
{
if(matrix_dbh) {
matrix_dbf.close(matrix_dbh);
}
if ((matrix_dbh = matrix_dbf.init(&matrix_db_url)) == NULL) {
if((matrix_dbh = matrix_dbf.init(&matrix_db_url)) == NULL) {
LM_ERR("can't connect to database.\n");
return -1;
}
return 0;
}

14 changes: 7 additions & 7 deletions src/modules/matrix/db_matrix.h
Expand Up @@ -32,23 +32,23 @@
/* database variables */

extern str matrix_db_url;
extern db1_con_t * matrix_dbh;
extern db1_con_t *matrix_dbh;
extern db_func_t matrix_dbf;

#define matrix_DB_URL { "db_url", PARAM_STR, &matrix_db_url },
#define matrix_DB_URL {"db_url", PARAM_STR, &matrix_db_url},

#define matrix_DB_TABLE { "matrix_table", PARAM_STR, &matrix_table },
#define matrix_DB_TABLE {"matrix_table", PARAM_STR, &matrix_table},

extern str matrix_table;

/* column names */
extern str matrix_first_col;
extern str matrix_second_col;
extern str matrix_res_col;
#define matrix_DB_COLS \
{ "matrix_first_col", PARAM_STR, &matrix_first_col }, \
{ "matrix_second_col", PARAM_STR, &matrix_second_col }, \
{ "matrix_res_col", PARAM_STR, &matrix_res_col }, \
#define matrix_DB_COLS \
{"matrix_first_col", PARAM_STR, &matrix_first_col}, \
{"matrix_second_col", PARAM_STR, &matrix_second_col}, \
{"matrix_res_col", PARAM_STR, &matrix_res_col},

/* table version */
extern const unsigned int matrix_version;
Expand Down

0 comments on commit d6f57ba

Please sign in to comment.