Skip to content

Commit

Permalink
db_berkeley: 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 8e9863e commit 1dc0bbb
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/modules/db_berkeley/bdb_cmd.h
Expand Up @@ -52,7 +52,7 @@
*/
typedef struct _bdb_cmd
{
db_drv_t gen; /**< Generic part of the data structure (must be first */
db_drv_t gen; /**< Generic part of the data structure (must be first */
bdb_con_t *bcon; /**< DB connection handle */
DB *dbp; /**< DB structure handle */
DBC *dbcp; /**< DB cursor handle */
Expand Down
2 changes: 1 addition & 1 deletion src/modules/db_berkeley/bdb_con.h
Expand Up @@ -61,7 +61,7 @@ typedef struct _bdb_con
{
db_pool_entry_t gen; /**< Generic part of the structure */
bdb_db_t *dbp; /**< DB structure handle */
unsigned int flags; /**< Flags */
unsigned int flags; /**< Flags */
} bdb_con_t, *bdb_con_p;

/** Create a new bdb_con structure.
Expand Down
4 changes: 2 additions & 2 deletions src/modules/db_berkeley/bdb_lib.c
Expand Up @@ -138,7 +138,7 @@ int bdblib_close(bdb_db_p _db_p, str *dirpath)

if(_tbc->dtp->name.len == dirpath->len
&& !strncasecmp(
_tbc->dtp->name.s, dirpath->s, dirpath->len)) {
_tbc->dtp->name.s, dirpath->s, dirpath->len)) {
DBG("DB %.*s \n", dirpath->len, dirpath->s);
_db = _tbc->dtp->db;
if(_db)
Expand Down Expand Up @@ -229,7 +229,7 @@ int bdblib_reopen(bdb_db_p _db_p, str *dirpath)

if(_tbc->dtp->name.len == dirpath->len
&& !strncasecmp(
_tbc->dtp->name.s, dirpath->s, dirpath->len)) {
_tbc->dtp->name.s, dirpath->s, dirpath->len)) {
ERR("DB %.*s \n", dirpath->len, dirpath->s);
if(!_tbc->dtp->db) {
if((rc = db_create(&_db, _env, 0)) != 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/modules/db_berkeley/bdb_lib.h
Expand Up @@ -86,7 +86,7 @@ typedef struct
long long ll_val; /**< long long value */
double double_val; /**< double value */
time_t time_val; /**< unix time_t value */
const char *string_val; /**< zero terminated string */
const char *string_val; /**< zero terminated string */
str str_val; /**< str type string value */
str blob_val; /**< binary object data */
unsigned int bitmap_val; /**< Bitmap data type */
Expand Down Expand Up @@ -119,8 +119,8 @@ typedef struct _bdb_table
int nkeys;
int ro; /*db readonly flag*/
int logflags; /*flags indication what-where to journal log */
FILE *fp; /*jlog file pointer */
time_t t; /*jlog creation time */
FILE *fp; /*jlog file pointer */
time_t t; /*jlog creation time */
ino_t ino;
} bdb_table_t, *bdb_table_p;

Expand Down
52 changes: 25 additions & 27 deletions src/modules/db_berkeley/bdb_mod.c
Expand Up @@ -62,23 +62,21 @@ static void bdb_mod_destroy(void);
/*
* Exported functions
*/
static cmd_export_t cmds[] = {
{"db_ctx", (cmd_function)NULL, 0, 0, 0, 0},
{"db_con", (cmd_function)bdb_con, 0, 0, 0, 0},
{"db_uri", (cmd_function)bdb_uri, 0, 0, 0, 0},
{"db_cmd", (cmd_function)bdb_cmd, 0, 0, 0, 0},
{"db_put", (cmd_function)bdb_cmd_exec, 0, 0, 0, 0},
{"db_del", (cmd_function)bdb_cmd_exec, 0, 0, 0, 0},
{"db_get", (cmd_function)bdb_cmd_exec, 0, 0, 0, 0},
{"db_upd", (cmd_function)bdb_cmd_exec, 0, 0, 0, 0},
{"db_sql", (cmd_function)bdb_cmd_exec, 0, 0, 0, 0},
{"db_first", (cmd_function)bdb_cmd_first, 0, 0, 0, 0},
{"db_next", (cmd_function)bdb_cmd_next, 0, 0, 0, 0},
{"db_res", (cmd_function)bdb_res, 0, 0, 0, 0},
{"db_fld", (cmd_function)bdb_fld, 0, 0, 0, 0},
{"db_bind_api", (cmd_function)bdb_bind_api, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0}
};
static cmd_export_t cmds[] = {{"db_ctx", (cmd_function)NULL, 0, 0, 0, 0},
{"db_con", (cmd_function)bdb_con, 0, 0, 0, 0},
{"db_uri", (cmd_function)bdb_uri, 0, 0, 0, 0},
{"db_cmd", (cmd_function)bdb_cmd, 0, 0, 0, 0},
{"db_put", (cmd_function)bdb_cmd_exec, 0, 0, 0, 0},
{"db_del", (cmd_function)bdb_cmd_exec, 0, 0, 0, 0},
{"db_get", (cmd_function)bdb_cmd_exec, 0, 0, 0, 0},
{"db_upd", (cmd_function)bdb_cmd_exec, 0, 0, 0, 0},
{"db_sql", (cmd_function)bdb_cmd_exec, 0, 0, 0, 0},
{"db_first", (cmd_function)bdb_cmd_first, 0, 0, 0, 0},
{"db_next", (cmd_function)bdb_cmd_next, 0, 0, 0, 0},
{"db_res", (cmd_function)bdb_res, 0, 0, 0, 0},
{"db_fld", (cmd_function)bdb_fld, 0, 0, 0, 0},
{"db_bind_api", (cmd_function)bdb_bind_api, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0}};

/*
* Exported parameters
Expand All @@ -89,16 +87,16 @@ static param_export_t params[] = {{"auto_reload", INT_PARAM, &auto_reload},
{0, 0, 0}};

struct module_exports exports = {
"db_berkeley", /* module name */
DEFAULT_DLFLAGS, /* dlopen flags */
cmds, /* cmd (cfg function) exports */
params, /* param exports */
0, /* RPC method exports */
0, /* pseudo-variables exports */
0, /* response handling function */
bdb_mod_init, /* module init function */
0, /* per-child init function */
bdb_mod_destroy /* module destroy function */
"db_berkeley", /* module name */
DEFAULT_DLFLAGS, /* dlopen flags */
cmds, /* cmd (cfg function) exports */
params, /* param exports */
0, /* RPC method exports */
0, /* pseudo-variables exports */
0, /* response handling function */
bdb_mod_init, /* module init function */
0, /* per-child init function */
bdb_mod_destroy /* module destroy function */
};

int mod_register(char *path, int *dlflags, void *p1, void *p2)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/db_berkeley/db_berkeley.c
Expand Up @@ -718,7 +718,7 @@ int bdb_insert(db1_con_t *_h, db_key_t *_k, db_val_t *_v, int _n)
switch(ret) {
/*The following are all critical/fatal */
case DB_LOCK_DEADLOCK:
/* The operation was selected to resolve a deadlock. */
/* The operation was selected to resolve a deadlock. */

case DB_RUNRECOVERY:
default:
Expand Down
4 changes: 2 additions & 2 deletions src/modules/db_berkeley/km_bdb_lib.h
Expand Up @@ -96,8 +96,8 @@ typedef struct _table
int nkeys;
int ro; /*db readonly flag*/
int logflags; /*flags indication what-where to journal log */
FILE *fp; /*jlog file pointer */
time_t t; /*jlog creation time */
FILE *fp; /*jlog file pointer */
time_t t; /*jlog creation time */
ino_t ino;
} table_t, *table_p;

Expand Down
26 changes: 13 additions & 13 deletions src/modules/db_berkeley/km_bdb_res.c
Expand Up @@ -381,7 +381,7 @@ int *bdb_get_colmap(table_p _dtp, db_key_t *_k, int _n)
for(j = 0; j < _dtp->ncols; j++) {
if(_k[i]->len == _dtp->colp[j]->name.len
&& !strncasecmp(_k[i]->s, _dtp->colp[j]->name.s,
_dtp->colp[j]->name.len)) {
_dtp->colp[j]->name.len)) {
_lref[i] = j;
break;
}
Expand Down Expand Up @@ -502,20 +502,20 @@ int bdb_cmp_val(db_val_t *_vp, db_val_t *_v)

switch(VAL_TYPE(_v)) {
case DB1_INT:
return (_vp->val.int_val < _v->val.int_val)
? -1
: (_vp->val.int_val > _v->val.int_val) ? 1 : 0;
return (_vp->val.int_val < _v->val.int_val) ? -1
: (_vp->val.int_val > _v->val.int_val) ? 1
: 0;
case DB1_BIGINT:
LM_ERR("BIGINT not supported");
return -1;
case DB1_DOUBLE:
return (_vp->val.double_val < _v->val.double_val)
? -1
: (_vp->val.double_val > _v->val.double_val) ? 1 : 0;
return (_vp->val.double_val < _v->val.double_val) ? -1
: (_vp->val.double_val > _v->val.double_val) ? 1
: 0;
case DB1_DATETIME:
return (_vp->val.int_val < _v->val.time_val)
? -1
: (_vp->val.int_val > _v->val.time_val) ? 1 : 0;
return (_vp->val.int_val < _v->val.time_val) ? -1
: (_vp->val.int_val > _v->val.time_val) ? 1
: 0;
case DB1_STRING:
_l = strlen(_v->val.string_val);
_l = (_l > _vp->val.str_val.len) ? _vp->val.str_val.len : _l;
Expand Down Expand Up @@ -550,9 +550,9 @@ int bdb_cmp_val(db_val_t *_vp, db_val_t *_v)
return -1;
return 1;
case DB1_BITMAP:
return (_vp->val.int_val < _v->val.bitmap_val)
? -1
: (_vp->val.int_val > _v->val.bitmap_val) ? 1 : 0;
return (_vp->val.int_val < _v->val.bitmap_val) ? -1
: (_vp->val.int_val > _v->val.bitmap_val) ? 1
: 0;
default:
break;
}
Expand Down

0 comments on commit 1dc0bbb

Please sign in to comment.