aboutsummaryrefslogtreecommitdiffstats
path: root/cdr
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-20 01:29:08 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-20 01:29:08 +0000
commit1649bd82aa3ea58ba3410738cf4a57397f2e57e5 (patch)
treeacc89e63b485d8c94203012d5e0903eee1a02086 /cdr
parenta6cd0e53d77948d34b54d8a6c16afe734fc60b17 (diff)
various fixes regarding coding guidelines issues
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@28935 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cdr')
-rw-r--r--cdr/cdr_pgsql.c72
1 files changed, 24 insertions, 48 deletions
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index 6af1a93a7..a62e9f206 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -209,82 +209,60 @@ static int my_unload_module(void)
static int process_my_load_module(struct ast_config *cfg)
{
- int res;
struct ast_variable *var;
char *pgerror;
char *tmp;
- var = ast_variable_browse(cfg, "global");
- if (!var) {
- /* nothing configured */
+ if (!(var = ast_variable_browse(cfg, "global")))
return 0;
- }
- tmp = ast_variable_retrieve(cfg,"global","hostname");
- if (tmp == NULL) {
+ if (!(tmp = ast_variable_retrieve(cfg,"global","hostname"))) {
ast_log(LOG_WARNING,"PostgreSQL server hostname not specified. Assuming unix socket connection\n");
tmp = ""; /* connect via UNIX-socket by default */
}
- pghostname = strdup(tmp);
- if (pghostname == NULL) {
- ast_log(LOG_ERROR,"Out of memory error.\n");
+
+ if (!(pghostname = ast_strdup(tmp)))
return -1;
- }
- tmp = ast_variable_retrieve(cfg,"global","dbname");
- if (tmp == NULL) {
+ if (!(tmp = ast_variable_retrieve(cfg, "global", "dbname"))) {
ast_log(LOG_WARNING,"PostgreSQL database not specified. Assuming asterisk\n");
tmp = "asteriskcdrdb";
}
- pgdbname = strdup(tmp);
- if (pgdbname == NULL) {
- ast_log(LOG_ERROR,"Out of memory error.\n");
+
+ if (!(pgdbname = ast_strdup(tmp)))
return -1;
- }
- tmp = ast_variable_retrieve(cfg,"global","user");
- if (tmp == NULL) {
+ if (!(tmp = ast_variable_retrieve(cfg, "global", "user"))) {
ast_log(LOG_WARNING,"PostgreSQL database user not specified. Assuming root\n");
tmp = "root";
}
- pgdbuser = strdup(tmp);
- if (pgdbuser == NULL) {
- ast_log(LOG_ERROR,"Out of memory error.\n");
+
+ if (!(pgdbuser = ast_strdup(tmp)))
return -1;
- }
- tmp = ast_variable_retrieve(cfg,"global","password");
- if (tmp == NULL) {
+ if (!(tmp = ast_variable_retrieve(cfg, "global", "password"))) {
ast_log(LOG_WARNING,"PostgreSQL database password not specified. Assuming blank\n");
tmp = "";
}
- pgpassword = strdup(tmp);
- if (pgpassword == NULL) {
- ast_log(LOG_ERROR,"Out of memory error.\n");
+
+ if (!(pgpassword = ast_strdup(tmp)))
return -1;
- }
- tmp = ast_variable_retrieve(cfg,"global","port");
- if (tmp == NULL) {
+ if (!(tmp = ast_variable_retrieve(cfg,"global","port"))) {
ast_log(LOG_WARNING,"PostgreSQL database port not specified. Using default 5432.\n");
tmp = "5432";
}
- pgdbport = strdup(tmp);
- if (pgdbport == NULL) {
- ast_log(LOG_ERROR,"Out of memory error.\n");
+
+ if (!(pgdbport = ast_strdup(tmp)))
return -1;
- }
- tmp = ast_variable_retrieve(cfg,"global","table");
- if (tmp == NULL) {
+ if (!(tmp = ast_variable_retrieve(cfg, "global", "table"))) {
ast_log(LOG_WARNING,"CDR table not specified. Assuming cdr\n");
tmp = "cdr";
}
- table = strdup(tmp);
- if (table == NULL) {
- ast_log(LOG_ERROR,"Out of memory error.\n");
+
+ if (!(table = ast_strdup(tmp)))
return -1;
- }
if (option_debug) {
if (ast_strlen_zero(pghostname))
@@ -310,24 +288,22 @@ static int process_my_load_module(struct ast_config *cfg)
connected = 0;
}
- res = ast_cdr_register(name, desc, pgsql_log);
- if (res) {
- ast_log(LOG_ERROR, "Unable to register PGSQL CDR handling\n");
- }
- return res;
+ return ast_cdr_register(name, desc, pgsql_log);
}
static int my_load_module(void)
{
struct ast_config *cfg;
int res;
- cfg = ast_config_load(config);
- if (!cfg) {
+
+ if (!(cfg = ast_config_load(config))) {
ast_log(LOG_WARNING, "Unable to load config for PostgreSQL CDR's: %s\n", config);
return 0;
}
+
res = process_my_load_module(cfg);
ast_config_destroy(cfg);
+
return res;
}