[asterisk-commits] ivaxer: branch ivaxer/ast_storage r279387 - in /team/ivaxer/ast_storage: incl...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Jul 25 10:40:19 CDT 2010
Author: ivaxer
Date: Sun Jul 25 10:40:15 2010
New Revision: 279387
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=279387
Log:
CODING GUIDELINES fixes
Modified:
team/ivaxer/ast_storage/include/asterisk/storage.h
team/ivaxer/ast_storage/main/file.c
team/ivaxer/ast_storage/main/storage.c
team/ivaxer/ast_storage/res/res_storage_odbc.c
Modified: team/ivaxer/ast_storage/include/asterisk/storage.h
URL: http://svnview.digium.com/svn/asterisk/team/ivaxer/ast_storage/include/asterisk/storage.h?view=diff&rev=279387&r1=279386&r2=279387
==============================================================================
--- team/ivaxer/ast_storage/include/asterisk/storage.h (original)
+++ team/ivaxer/ast_storage/include/asterisk/storage.h Sun Jul 25 10:40:15 2010
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 2006, Digium, Inc.
+ * Copyright (C) 2010, Digium, Inc.
*
* Jason Parker <jparker at digium.com>
*
@@ -20,6 +20,7 @@
* \brief Generic File Storage Engine Support.
*
* \author Jason Parker <jparker at digium.com>
+ * \author John Khvatov <ivaxer at gmail.com>
*/
#ifndef _ASTERISK_STORAGE_H
Modified: team/ivaxer/ast_storage/main/file.c
URL: http://svnview.digium.com/svn/asterisk/team/ivaxer/ast_storage/main/file.c?view=diff&rev=279387&r1=279386&r2=279387
==============================================================================
--- team/ivaxer/ast_storage/main/file.c (original)
+++ team/ivaxer/ast_storage/main/file.c Sun Jul 25 10:40:15 2010
@@ -1011,8 +1011,9 @@
fs = NULL;
if (!ast_exts_compare(f->exts, type))
continue;
- else
+ else {
format_found = 1;
+ }
fn = build_filename(filename, type);
errno = 0;
@@ -1039,8 +1040,9 @@
}
AST_RWLIST_UNLOCK(&formats);
- if (!format_found)
+ if (!format_found) {
ast_log(LOG_WARNING, "No such format '%s'\n", type);
+ }
return fs;
}
Modified: team/ivaxer/ast_storage/main/storage.c
URL: http://svnview.digium.com/svn/asterisk/team/ivaxer/ast_storage/main/storage.c?view=diff&rev=279387&r1=279386&r2=279387
==============================================================================
--- team/ivaxer/ast_storage/main/storage.c (original)
+++ team/ivaxer/ast_storage/main/storage.c Sun Jul 25 10:40:15 2010
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2007, Digium, Inc.
+ * Copyright (C) 2010, Digium, Inc.
*
* Mark Spencer <markster at digium.com>
*
@@ -18,9 +18,10 @@
/*! \file
*
- * \brief Generic File Format Support.
- *
- * \author Mark Spencer <markster at digium.com>
+ * \brief Generic File Storage Engine Support.
+ *
+ * \author Mark Spencer <markster at digium.com>uh
+ * \author John Khvatov <ivaxer at gmail.com>
*/
#include "asterisk.h"
@@ -59,7 +60,7 @@
}
*tmp = *be;
tmp->module = mod;
-
+
memset(&tmp->list, 0, sizeof(tmp->list));
AST_RWLIST_INSERT_TAIL(&storage_engines, tmp, list);
@@ -209,7 +210,7 @@
}
ast_copy_string(fo->objectname, to, sizeof(fo->objectname));
-
+
if (ast_storage_put(st, fo, NULL)) {
ast_log(LOG_WARNING, "Unable to copy '%s' to '%s': put() failed\n", from, to);
ast_storage_fileobject_release(fo);
@@ -225,7 +226,8 @@
return st && st->be->listdir ? st->be->listdir(st, pathname) : NULL;
}
-void ast_storage_fileobject_release(struct ast_storage_fileobject *fo) {
+void ast_storage_fileobject_release(struct ast_storage_fileobject *fo)
+{
struct ast_storage_fileinst *inst;
if (!fo) {
@@ -245,7 +247,8 @@
ast_free(fo);
}
-void ast_storage_fileinst_release(struct ast_storage_fileinst *fi) {
+void ast_storage_fileinst_release(struct ast_storage_fileinst *fi)
+{
if (!fi) {
return;
}
@@ -259,7 +262,8 @@
ast_free(fi);
}
-void ast_storage_dirobject_release(struct ast_storage_dirobject *dobj) {
+void ast_storage_dirobject_release(struct ast_storage_dirobject *dobj)
+{
struct ast_storage_fileobject *fo;
if (!dobj) {
@@ -297,15 +301,18 @@
case CLI_GENERATE:
return NULL;
}
-
- if (a->argc != 4)
+
+ if (a->argc != 4) {
return CLI_SHOWUSAGE;
+ }
uri = ast_strdupa(a->argv[3]);
- if ((fn = strrchr(uri, '/')))
+ if ((fn = strrchr(uri, '/'))) {
*fn++ = '\0';
- else
+ }
+ else {
return CLI_SUCCESS;
+ }
if ((st = ast_storage_request(uri))) {
ast_cli(a->fd, "File information\n");
@@ -347,8 +354,9 @@
return NULL;
}
- if(a->argc != 3)
+ if(a->argc != 3) {
return CLI_SHOWUSAGE;
+ }
ast_cli(a->fd, "Storage Engine\n");
@@ -399,8 +407,9 @@
return complete_storage_show_engines(a);
}
- if (a->argc != 4)
+ if (a->argc != 4) {
return CLI_SHOWUSAGE;
+ }
if ((be = ast_storage_getbyname(a->argv[3]))) {
ast_cli(a->fd, "Storage Engine: %s\n", be->name);
@@ -420,8 +429,9 @@
be->status((struct ast_storage *)be, fd);
*/
}
- } else
+ } else {
ast_cli(a->fd, "No storage engine named '%s' found.\n", a->argv[3]);
+ }
return CLI_SUCCESS;
}
#endif
@@ -454,17 +464,17 @@
}
st = ast_storage_request(uri);
- if(!st) {
+ if (!st) {
return AST_TEST_FAIL;
}
ret = ast_storage_copy(st, "test", "huest");
- if(ret) {
+ if (ret) {
return AST_TEST_FAIL;
}
ret = ast_storage_release(st);
- if(ret) {
+ if (ret) {
return AST_TEST_FAIL;
}
Modified: team/ivaxer/ast_storage/res/res_storage_odbc.c
URL: http://svnview.digium.com/svn/asterisk/team/ivaxer/ast_storage/res/res_storage_odbc.c?view=diff&rev=279387&r1=279386&r2=279387
==============================================================================
--- team/ivaxer/ast_storage/res/res_storage_odbc.c (original)
+++ team/ivaxer/ast_storage/res/res_storage_odbc.c Sun Jul 25 10:40:15 2010
@@ -1,9 +1,9 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 2006, Tilghman Lesher
+ * Copyright (C) 2010, John Khvatov
*
- * Tilghman Lesher <res_storage_odbc__v001 at the-tilghman.com>
+ * John Khvatov <ivaxer at gmail.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
@@ -18,11 +18,11 @@
/*! \file
*
- * \brief ODBC based storage engine
- * \author Tilghman Lesher <res_storage_odbc__v001 at the-tilghman.com>
+ * \brief ODBC storage engine backend
+ * \author John Khvatov <ivaxer at gmail.com>
* \ingroup res
*/
-
+
/*** MODULEINFO
<depend>unixodbc</depend>
<depend>res_odbc</depend>
@@ -114,8 +114,10 @@
{
struct odbc_storage_pvt *pvt;
- if (!st)
+ if (!st) {
return 0;
+ }
+
if (st->storage_pvt) {
pvt = (struct odbc_storage_pvt *) st->storage_pvt;
if (pvt->conn) {
@@ -223,7 +225,8 @@
return st;
}
-static struct ast_storage_fileinst *fetch_fileinst(SQLHSTMT stmt) {
+static struct ast_storage_fileinst *fetch_fileinst(SQLHSTMT stmt)
+{
SQLRETURN ret;
SQLSMALLINT colcount, colid, collen;
SQLULEN colsize;
@@ -238,7 +241,7 @@
if (ret == SQL_NO_DATA) {
return NULL;
}
- if(!SQL_SUCCEEDED(ret)) {
+ if (!SQL_SUCCEEDED(ret)) {
ast_log(LOG_WARNING, "SQL Fetch error!");
return NULL;
}
@@ -250,18 +253,18 @@
}
fi = create_fileinst();
- if(!fi) {
+ if (!fi) {
return NULL;
}
for (colid = 1; colid <= colcount; colid++) {
ret = SQLDescribeCol(stmt, colid, (SQLCHAR *)coltitle, sizeof(coltitle), &collen,
&datatype, &colsize, &decimaldigits, &nullable);
- if(!SQL_SUCCEEDED(ret)) {
+ if (!SQL_SUCCEEDED(ret)) {
ast_log(LOG_WARNING, "SQL Describe Column error!");
goto error;
}
- if(!strcasecmp(coltitle, "recording")) {
+ if (!strcasecmp(coltitle, "recording")) {
size_t ndata;
off_t offset;
void *fdm;
@@ -314,9 +317,9 @@
ast_copy_string(fi->localfile, tmpfile_fmt, sizeof(fi->localfile));
}
- else if(!strcasecmp(coltitle, "extension")) {
+ else if (!strcasecmp(coltitle, "extension")) {
ret = SQLGetData(stmt, colid, SQL_CHAR, rowdata, sizeof(rowdata), NULL);
- if(!SQL_SUCCEEDED(ret)) {
+ if (!SQL_SUCCEEDED(ret)) {
ast_log(LOG_WARNING, "SQL Get Data error!");
goto error;
}
@@ -331,7 +334,8 @@
return NULL;
}
-static SQLHSTMT prepare_get_query(struct odbc_obj *obj, void *arg) {
+static SQLHSTMT prepare_get_query(struct odbc_obj *obj, void *arg)
+{
SQLHSTMT stmt;
SQLRETURN ret;
struct get_query_data *qdata = (struct get_query_data *) arg;
@@ -385,15 +389,14 @@
}
}
- /*
+ /*
* TODO: objectname may contain relative or absolute path.
*/
pathname = ost->pathname;
if (exts) {
snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE pathname=? AND filename=? AND (extension=? OR extension=?)", ost->tablename);
- }
- else {
+ } else {
snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE pathname=? AND filename=?", ost->tablename);
}
@@ -402,8 +405,7 @@
qdata.pathname = pathname;
if (exts) {
qdata.ext = ext;
- }
- else {
+ } else {
qdata.ext = NULL;
}
@@ -446,11 +448,11 @@
}
-static SQLHSTMT execute_put_query(struct odbc_obj *obj, void *arg) {
+static SQLHSTMT execute_put_query(struct odbc_obj *obj, void *arg)
+{
SQLRETURN ret;
SQLHSTMT stmt;
struct put_query_data *qdata = (struct put_query_data *) arg;
-
ret = SQLAllocHandle(SQL_HANDLE_STMT, obj->con, &stmt);
if (!SQL_SUCCEEDED(ret)) {
@@ -468,7 +470,7 @@
SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, qdata->metadata_len, 0, (void *)qdata->metadata, 0, &qdata->metadata_ind);
ret = SQLExecDirect(stmt, (unsigned char *)qdata->sql, SQL_NTS);
- if(!SQL_SUCCEEDED(ret)) {
+ if (!SQL_SUCCEEDED(ret)) {
ast_log(LOG_WARNING, "SQL Exec Direct failed!");
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
return NULL;
@@ -477,7 +479,8 @@
return stmt;
}
-static int open_fileinst(struct ast_storage_fileinst *fi, int *fd, int *fdlen, void **fdm) {
+static int open_fileinst(struct ast_storage_fileinst *fi, int *fd, int *fdlen, void **fdm)
+{
int local_fd, local_fdlen;
void *local_fdm;
@@ -513,7 +516,6 @@
void *fdm, *mfdm;
int putret = -1;
-
if (!fo) {
ast_log(LOG_WARNING, "fileobject is null!\n");
return -1;
@@ -538,12 +540,12 @@
mfi = fo->metadata;
- if(!fi) {
+ if (!fi) {
ast_log(LOG_WARNING, "Unable to find file instance for put()\n");
return -1;
}
- if(!mfi) {
+ if (!mfi) {
ast_log(LOG_WARNING, "put() failed: metadata fileinst not found\n");
return -1;
}
@@ -569,7 +571,7 @@
qdata.metadata_len = qdata.metadata_ind = mfdlen;
stmt = ast_odbc_direct_execute(ost->conn, execute_put_query, (void *) &qdata);
- if(!stmt) {
+ if (!stmt) {
ast_log(LOG_WARNING, "SQL Execute failed!");
goto error;
}
@@ -657,7 +659,7 @@
}
st = se_create(uri);
- if(!st) {
+ if (!st) {
return AST_TEST_FAIL;
}
@@ -673,7 +675,7 @@
AST_RWLIST_UNLOCK(&pvt->columns);
ret = se_release(st);
- if(ret) {
+ if (ret) {
return AST_TEST_FAIL;
}
@@ -701,12 +703,12 @@
}
st = se_create(uri);
- if(!st) {
+ if (!st) {
return AST_TEST_FAIL;
}
fo = se_get(st, "test", "wav");
- if(!fo) {
+ if (!fo) {
return AST_TEST_FAIL;
}
@@ -727,7 +729,7 @@
ast_storage_fileobject_release(fo);
ret = se_release(st);
- if(ret) {
+ if (ret) {
return AST_TEST_FAIL;
}
@@ -754,12 +756,12 @@
}
st = se_create(uri);
- if(!st) {
+ if (!st) {
return AST_TEST_FAIL;
}
fo = se_get(st, "test", "wav");
- if(!fo) {
+ if (!fo) {
return AST_TEST_FAIL;
}
@@ -773,7 +775,7 @@
ast_storage_fileobject_release(fo);
ret = se_release(st);
- if(ret) {
+ if (ret) {
return AST_TEST_FAIL;
}
More information about the asterisk-commits
mailing list