]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Coding style, fix some C90 warnings about mixed decls/code
authorDaniel Swarbrick <daniel@seventhsignal.de>
Thu, 30 Dec 2010 23:01:53 +0000 (00:01 +0100)
committerDaniel Swarbrick <daniel@seventhsignal.de>
Thu, 30 Dec 2010 23:01:53 +0000 (00:01 +0100)
src/mod/event_handlers/mod_cdr_pg_csv/Makefile
src/mod/event_handlers/mod_cdr_pg_csv/mod_cdr_pg_csv.c

index b2d393f39912c3e90a5018cb6f509a3d1d043bd2..91c48be50b191504f5f55c7003a7aedc7e682053 100644 (file)
@@ -8,6 +8,7 @@ else
 LOCAL_LDFLAGS=-L/usr/postgres/8.3/lib -R/usr/postgres/8.3/lib -lpq -static
 endif
 else
+LOCAL_CFLAGS=-I/usr/include/postgresql
 LOCAL_LDFLAGS=-lpq -static
 endif
 include ../../../../build/modmake.rules
index ccd747873e2a2544e8f3caa73c9396dcef7f4b2f..02014e4c66e0df0d9657b42a4e396c73bd7c225f 100644 (file)
@@ -186,10 +186,12 @@ static int save_cdr(const char* const table, const char* const template, const c
        char* values;
        char* p;
        unsigned clen;
-        unsigned vlen;
+       unsigned vlen;
        char* query;
        const char* const query_template = "INSERT INTO %s (%s) VALUES (%s);";
        PGresult* res;
+       char *spaceColumns, *pt, *nullValues, *temp, *tp;
+       int spaceCounter = 0, nullCounter = 0, charCounter = 0;
 
        if (!table || !*table || !template || !*template || !cdr || !*cdr) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Bad parameter\n");
@@ -199,9 +201,9 @@ static int save_cdr(const char* const table, const char* const template, const c
        columns = strdup(template);
        for (p = columns; *p; ++p) {
                switch (*p) {
-               case '$': case '"': case '{': case '}': case ';':
-                       *p = ' ';
-                       break;
+                       case '$': case '"': case '{': case '}': case ';':
+                               *p = ' ';
+                               break;
                }
        }
        clen = p - columns;
@@ -209,121 +211,121 @@ static int save_cdr(const char* const table, const char* const template, const c
        values = strdup(cdr);
        for (p = values; *p; ++p) {
                switch(*p) {
-               case '"':
-                       *p = '\'';
-                       break;
-               case ';':
-                       *p = ' ';
-                       break;
+                       case '"':
+                               *p = '\'';
+                               break;
+                       case ';':
+                               *p = ' ';
+                               break;
                }
        }
        vlen = p - values;
-/*
-         Patch for changing spaces (; ;) in the template paterns to NULL   (ex.)  ; ; --PACH--> null
-         - added new functionality - space removing
-*/
-        char *spaceColumns;
-       int spaceCounter=0;
-       for (p=columns; *p; ++p)
-       {
-               if (*p==' ')
-               {
+
+       /*
+        * Patch for changing spaces (; ;) in the template paterns to NULL
+        * (eg.) ; ; --PATCH--> null
+        * - added new functionality - space removing
+        */
+       for (p = columns; *p; ++p) {
+               if (*p == ' ') {
                        spaceCounter++;
                }
        }
-       spaceColumns = (char*)malloc(clen-spaceCounter+1);
-       char *pt=spaceColumns;
-       for (p=columns; *p; ++p)
-       {
-               if (*p!=' ')
-               {
+
+       spaceColumns = (char *) malloc(clen - spaceCounter + 1);
+       pt = spaceColumns;
+
+       for (p = columns; *p; ++p) {
+               if (*p != ' ') {
                        *pt=*p;
                        pt++;
                }
        }
-       *pt=0;
-       pt=columns;
-       columns=spaceColumns;
+
+       *pt = 0;
+       pt = columns;
+       columns = spaceColumns;
        free(pt);
-       char *nullValues;
-       int nullCounter=0;
-       int charCounter=0;
-       for (p=values; *p; ++p)
-       {
-               if (*p==',')
-               {
-                       if (charCounter==0)
-                       {
+
+       for (p = values; *p; ++p) {
+               if (*p == ',') {
+                       if (charCounter == 0) {
                                nullCounter++;
                        }
-                       charCounter=0;
-               }
-               else if (*p!=' ' && *p!='\'')
-               {
+                       charCounter = 0;
+               } else if (*p != ' ' && *p != '\'') {
                        charCounter++;
                }
        }
-       if (charCounter==0)
-       {
+
+       if (charCounter == 0) {
                nullCounter++;
        }
-       charCounter=0;
-       nullCounter*=4;
-       vlen+=nullCounter;
-       nullValues=(char*)malloc(strlen(values)+nullCounter+1);
-       charCounter=0;
-       char *temp=nullValues;
-       char *tp=nullValues;
-       for (p=values; *p; ++tp,++p)
-       {
-           if (*p==',')
-               {
-                       if (charCounter==0)
-                       {
+
+       charCounter = 0;
+       nullCounter *= 4;
+       vlen += nullCounter;
+       nullValues = (char *) malloc(strlen(values) + nullCounter + 1);
+       charCounter = 0;
+       temp = nullValues;
+       tp = nullValues;
+
+       for (p = values; *p; ++tp, ++p) {
+               if (*p == ',') {
+                       if (charCounter == 0) {
+                               temp++;
+                               *temp = 'n';
+                               temp++;
+                               if (temp == tp) tp++;
+                               *temp = 'u';
+                               temp++;
+                               if (temp == tp) tp++;
+                               *temp = 'l';
                                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++;
+                               if (temp == tp) tp++;
+                               *temp = 'l';
+                               temp++;
+                               while (temp != tp) {
+                                       *temp = ' ';
+                                       temp++;
                                }
                        }
-                       charCounter=0;
-                       temp=tp;
-               }
-               else if (*p!=' ' && *p!='\'')
-               {
+                       charCounter = 0;
+                       temp = tp;
+               } else if (*p != ' ' && *p != '\'') {
                        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 = '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;
-       *tp=0;
-       tp=values;
-       values=nullValues;
+
+       charCounter = 0;
+       temp = tp;
+       *tp = 0;
+       tp = values;
+       values = nullValues;
        free(tp);
-//-----------------------------END_OF_PATCH----------------------------------------------------------------
+
+       //----------------------------- END_OF_PATCH -------------------------------
+
        query = malloc(strlen(query_template) - 6 + strlen(table) + clen + vlen + 1);
        sprintf(query, query_template, table, columns, values);
        free(columns);