Skip to content

Commit

Permalink
db_flatstore: align functions export to new format
Browse files Browse the repository at this point in the history
  • Loading branch information
rvlad-patrascu committed Apr 8, 2019
1 parent 1c778df commit 7b594ff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions modules/db_flatstore/flat_con.c
Expand Up @@ -48,7 +48,7 @@ static char* get_name(struct flat_id* id)
return 0;
}
if (flat_suffix) {
if (fixup_get_svalue(&flat_dummy_msg, flat_suffix, &suffix) < 0) {
if (pv_printf_s(&flat_dummy_msg, flat_suffix, &suffix) != 0) {
LM_ERR("bad suffix - using default \"%s\"\n", FILE_SUFFIX);
suffix.s = FILE_SUFFIX;
suffix.len = FILE_SUFFIX_LEN;
Expand All @@ -58,7 +58,7 @@ static char* get_name(struct flat_id* id)
suffix.len = 0;
}
if (flat_prefix) {
if (fixup_get_svalue(&flat_dummy_msg, flat_prefix, &prefix) < 0) {
if (pv_printf_s(&flat_dummy_msg, flat_prefix, &prefix) != 0) {
LM_ERR("bad prefix - discarding\n");
prefix.s = 0;
prefix.len = 0;
Expand Down
34 changes: 16 additions & 18 deletions modules/db_flatstore/flatstore_mod.c
Expand Up @@ -67,10 +67,10 @@ char* flat_delimiter = "|";
* suffix and prefix of the logging file
* can be a formatted string
*/
char * flat_suffix_s = FILE_SUFFIX;
gparam_p flat_suffix;
char * flat_prefix_s = NULL;
gparam_p flat_prefix;
str flat_suffix_s = str_init(FILE_SUFFIX);
pv_elem_t *flat_suffix = NULL;
str flat_prefix_s = {0,0};
pv_elem_t *flat_prefix = NULL;

/*
* Timestamp of the last log rotation request from
Expand All @@ -84,8 +84,8 @@ time_t local_timestamp;
* Flatstore database module interface
*/
static cmd_export_t cmds[] = {
{"db_bind_api", (cmd_function)db_flat_bind_api, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0}
{"db_bind_api", (cmd_function)db_flat_bind_api, {{0,0,0}},0},
{0,0,{{0,0,0}},0}
};

/*
Expand All @@ -94,8 +94,8 @@ static cmd_export_t cmds[] = {
static param_export_t params[] = {
{"flush", INT_PARAM, &flat_flush},
{"delimiter", STR_PARAM, &flat_delimiter},
{"suffix", STR_PARAM, &flat_suffix_s},
{"prefix", STR_PARAM, &flat_prefix_s},
{"suffix", STR_PARAM, &flat_suffix_s.s},
{"prefix", STR_PARAM, &flat_prefix_s.s},
{"single_file", INT_PARAM, &flat_single_file},
{0, 0, 0}
};
Expand Down Expand Up @@ -147,24 +147,22 @@ static int mod_init(void)
*flat_rotate = time(0);
local_timestamp = *flat_rotate;

flat_suffix_s.len = strlen(flat_suffix_s.s);
flat_prefix_s.len = strlen(flat_prefix_s.s);

/* parse prefix and suffix */
if (flat_suffix_s && strlen(flat_suffix_s)) {
if (fixup_spve((void **)&flat_suffix_s)) {
if (flat_suffix_s.s && flat_suffix_s.len) {
if (pv_parse_format(&flat_suffix_s, &flat_suffix) < 0) {
LM_ERR("cannot parse log suffix\n");
return -1;
}
flat_suffix = (gparam_p)flat_suffix_s;
} else {
flat_suffix = 0;
}
if (flat_prefix_s && strlen(flat_prefix_s)) {
if (fixup_spve((void **)&flat_prefix_s)) {

if (flat_prefix_s.s && flat_prefix_s.len) {
if (pv_parse_format(&flat_prefix_s, &flat_prefix) < 0) {
LM_ERR("cannot parse log prefix\n");
return -1;
}
flat_prefix = (gparam_p)flat_prefix_s;
} else {
flat_prefix = 0;
}

return 0;
Expand Down
7 changes: 4 additions & 3 deletions modules/db_flatstore/flatstore_mod.h
Expand Up @@ -29,7 +29,8 @@
#define FLATSTORE_MOD_H

#include <time.h>
#include "../../mod_fix.h"

#include "../../pvar.h"

/*
* Process number used in filenames
Expand Down Expand Up @@ -72,8 +73,8 @@ extern time_t local_timestamp;
/*
* Suffix and prefix for logs
*/
extern gparam_p flat_suffix;
extern gparam_p flat_prefix;
extern pv_elem_t *flat_suffix;
extern pv_elem_t *flat_prefix;

extern int flat_single_file;

Expand Down

0 comments on commit 7b594ff

Please sign in to comment.