mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-05-07 08:21:08 +00:00
Coding style, fix some C90 warnings about mixed decls/code
This commit is contained in:
parent
5401c60493
commit
18feeb1067
@ -8,6 +8,7 @@ else
|
|||||||
LOCAL_LDFLAGS=-L/usr/postgres/8.3/lib -R/usr/postgres/8.3/lib -lpq -static
|
LOCAL_LDFLAGS=-L/usr/postgres/8.3/lib -R/usr/postgres/8.3/lib -lpq -static
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
|
LOCAL_CFLAGS=-I/usr/include/postgresql
|
||||||
LOCAL_LDFLAGS=-lpq -static
|
LOCAL_LDFLAGS=-lpq -static
|
||||||
endif
|
endif
|
||||||
include ../../../../build/modmake.rules
|
include ../../../../build/modmake.rules
|
||||||
|
@ -190,6 +190,8 @@ static int save_cdr(const char* const table, const char* const template, const c
|
|||||||
char* query;
|
char* query;
|
||||||
const char* const query_template = "INSERT INTO %s (%s) VALUES (%s);";
|
const char* const query_template = "INSERT INTO %s (%s) VALUES (%s);";
|
||||||
PGresult* res;
|
PGresult* res;
|
||||||
|
char *spaceColumns, *pt, *nullValues, *temp, *tp;
|
||||||
|
int spaceCounter = 0, nullCounter = 0, charCounter = 0;
|
||||||
|
|
||||||
if (!table || !*table || !template || !*template || !cdr || !*cdr) {
|
if (!table || !*table || !template || !*template || !cdr || !*cdr) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Bad parameter\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Bad parameter\n");
|
||||||
@ -218,112 +220,112 @@ static int save_cdr(const char* const table, const char* const template, const c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
vlen = p - values;
|
vlen = p - values;
|
||||||
/*
|
|
||||||
Patch for changing spaces (; ;) in the template paterns to NULL (ex.) ; ; --PACH--> null
|
/*
|
||||||
- added new functionality - space removing
|
* Patch for changing spaces (; ;) in the template paterns to NULL
|
||||||
*/
|
* (eg.) ; ; --PATCH--> null
|
||||||
char *spaceColumns;
|
* - added new functionality - space removing
|
||||||
int spaceCounter=0;
|
*/
|
||||||
for (p=columns; *p; ++p)
|
for (p = columns; *p; ++p) {
|
||||||
{
|
if (*p == ' ') {
|
||||||
if (*p==' ')
|
|
||||||
{
|
|
||||||
spaceCounter++;
|
spaceCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spaceColumns = (char*)malloc(clen-spaceCounter+1);
|
|
||||||
char *pt=spaceColumns;
|
spaceColumns = (char *) malloc(clen - spaceCounter + 1);
|
||||||
for (p=columns; *p; ++p)
|
pt = spaceColumns;
|
||||||
{
|
|
||||||
if (*p!=' ')
|
for (p = columns; *p; ++p) {
|
||||||
{
|
if (*p != ' ') {
|
||||||
*pt=*p;
|
*pt=*p;
|
||||||
pt++;
|
pt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*pt=0;
|
|
||||||
pt=columns;
|
*pt = 0;
|
||||||
columns=spaceColumns;
|
pt = columns;
|
||||||
|
columns = spaceColumns;
|
||||||
free(pt);
|
free(pt);
|
||||||
char *nullValues;
|
|
||||||
int nullCounter=0;
|
for (p = values; *p; ++p) {
|
||||||
int charCounter=0;
|
if (*p == ',') {
|
||||||
for (p=values; *p; ++p)
|
if (charCounter == 0) {
|
||||||
{
|
|
||||||
if (*p==',')
|
|
||||||
{
|
|
||||||
if (charCounter==0)
|
|
||||||
{
|
|
||||||
nullCounter++;
|
nullCounter++;
|
||||||
}
|
}
|
||||||
charCounter=0;
|
charCounter = 0;
|
||||||
}
|
} else if (*p != ' ' && *p != '\'') {
|
||||||
else if (*p!=' ' && *p!='\'')
|
|
||||||
{
|
|
||||||
charCounter++;
|
charCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (charCounter==0)
|
|
||||||
{
|
if (charCounter == 0) {
|
||||||
nullCounter++;
|
nullCounter++;
|
||||||
}
|
}
|
||||||
charCounter=0;
|
|
||||||
nullCounter*=4;
|
charCounter = 0;
|
||||||
vlen+=nullCounter;
|
nullCounter *= 4;
|
||||||
nullValues=(char*)malloc(strlen(values)+nullCounter+1);
|
vlen += nullCounter;
|
||||||
charCounter=0;
|
nullValues = (char *) malloc(strlen(values) + nullCounter + 1);
|
||||||
char *temp=nullValues;
|
charCounter = 0;
|
||||||
char *tp=nullValues;
|
temp = nullValues;
|
||||||
for (p=values; *p; ++tp,++p)
|
tp = nullValues;
|
||||||
{
|
|
||||||
if (*p==',')
|
for (p = values; *p; ++tp, ++p) {
|
||||||
{
|
if (*p == ',') {
|
||||||
if (charCounter==0)
|
if (charCounter == 0) {
|
||||||
{
|
temp++;
|
||||||
|
*temp = 'n';
|
||||||
|
temp++;
|
||||||
|
if (temp == tp) tp++;
|
||||||
|
*temp = 'u';
|
||||||
|
temp++;
|
||||||
|
if (temp == tp) tp++;
|
||||||
|
*temp = 'l';
|
||||||
|
temp++;
|
||||||
|
if (temp == tp) tp++;
|
||||||
|
*temp = 'l';
|
||||||
|
temp++;
|
||||||
|
while (temp != tp) {
|
||||||
|
*temp = ' ';
|
||||||
temp++;
|
temp++;
|
||||||
*temp='n';temp++;
|
|
||||||
if (temp==tp) tp++;
|
|
||||||
*temp='u';temp++;
|
|
||||||
if (temp==tp) tp++;
|
|
||||||
*temp='l';temp++;
|
|
||||||
if (temp==tp) tp++;
|
|
||||||
*temp='l';temp++;
|
|
||||||
while (temp!=tp)
|
|
||||||
{
|
|
||||||
*temp=' ';temp++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
charCounter=0;
|
charCounter = 0;
|
||||||
temp=tp;
|
temp = tp;
|
||||||
}
|
} else if (*p != ' ' && *p != '\'') {
|
||||||
else if (*p!=' ' && *p!='\'')
|
|
||||||
{
|
|
||||||
charCounter++;
|
charCounter++;
|
||||||
}
|
}
|
||||||
*tp=*p;
|
*tp = *p;
|
||||||
}
|
}
|
||||||
if (charCounter==0)
|
|
||||||
{
|
if (charCounter == 0) {
|
||||||
|
temp++;
|
||||||
|
*temp = 'n';
|
||||||
|
temp++;
|
||||||
|
if (temp == tp) tp++;
|
||||||
|
*temp = 'u';
|
||||||
|
temp++;
|
||||||
|
if (temp == tp) tp++;
|
||||||
|
*temp = 'l';
|
||||||
|
temp++;
|
||||||
|
if (temp == tp) tp++;
|
||||||
|
*temp = 'l';
|
||||||
|
temp++;
|
||||||
|
while (temp != tp) {
|
||||||
|
*temp = ' ';
|
||||||
temp++;
|
temp++;
|
||||||
*temp='n';temp++;
|
|
||||||
if (temp==tp) tp++;
|
|
||||||
*temp='u';temp++;
|
|
||||||
if (temp==tp) tp++;
|
|
||||||
*temp='l';temp++;
|
|
||||||
if (temp==tp) tp++;
|
|
||||||
*temp='l';temp++;
|
|
||||||
while (temp!=tp)
|
|
||||||
{
|
|
||||||
*temp=' ';temp++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
charCounter=0;
|
|
||||||
temp=tp;
|
charCounter = 0;
|
||||||
*tp=0;
|
temp = tp;
|
||||||
tp=values;
|
*tp = 0;
|
||||||
values=nullValues;
|
tp = values;
|
||||||
|
values = nullValues;
|
||||||
free(tp);
|
free(tp);
|
||||||
//-----------------------------END_OF_PATCH----------------------------------------------------------------
|
|
||||||
|
//----------------------------- END_OF_PATCH -------------------------------
|
||||||
|
|
||||||
query = malloc(strlen(query_template) - 6 + strlen(table) + clen + vlen + 1);
|
query = malloc(strlen(query_template) - 6 + strlen(table) + clen + vlen + 1);
|
||||||
sprintf(query, query_template, table, columns, values);
|
sprintf(query, query_template, table, columns, values);
|
||||||
free(columns);
|
free(columns);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user