* json doesn't need to escape singlequotes
authorWilfried Göesgens <willi@citadel.org>
Mon, 26 Jan 2009 00:28:20 +0000 (00:28 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 26 Jan 2009 00:28:20 +0000 (00:28 +0000)
+ add possibility to json serializer to free the struct, so usage gets smarter
* make params of wildfire calls similar
* take 1st frame to find binary name, as 0 will be libcitadel

libcitadel/lib/json.c
libcitadel/lib/libcitadel.h
libcitadel/lib/stringbuf.c
libcitadel/lib/wildfire.c

index 044be9cdf38b338d83a9c57f7bb52bae863a94f4..8690f4e2b7b3d851fbc86e281b766d914de19339 100644 (file)
@@ -179,7 +179,7 @@ void JsonObjectAppend(JsonValue *Array, JsonValue *Val)
 
 
 
-void SerializeJson(StrBuf *Target, JsonValue *Val)
+void SerializeJson(StrBuf *Target, JsonValue *Val, int FreeVal)
 {
        void *vValue, *vPrevious;
        JsonValue *SubVal;
@@ -215,7 +215,7 @@ void SerializeJson(StrBuf *Target, JsonValue *Val)
                                StrBufAppendBufPlain(Target, HKEY(","), 0);
 
                        SubVal = (JsonValue*) vValue;
-                       SerializeJson(Target, SubVal);
+                       SerializeJson(Target, SubVal, 0);
                        vPrevious = vValue;
                }
                StrBufAppendBufPlain(Target, HKEY("]"), 0);
@@ -237,13 +237,15 @@ void SerializeJson(StrBuf *Target, JsonValue *Val)
                        StrBufAppendBuf(Target, SubVal->Name, 0);
                        StrBufAppendBufPlain(Target, HKEY("\":"), 0);
 
-                       SerializeJson(Target, SubVal);
+                       SerializeJson(Target, SubVal, 0);
                        vPrevious = vValue;
                }
                StrBufAppendBufPlain(Target, HKEY("}"), 0);
                break;
        }
-
+       if(FreeVal) {
+               DeleteJSONValue(Val);
+       }
 }
 
 
index a20bf1a1d9ec454b98feed75acaa8d6e43e0208d..6137d0f145427ddeb0ad5bff35abc1ea7f211726 100644 (file)
@@ -485,7 +485,7 @@ void JsonArrayAppend(JsonValue *Array, JsonValue *Val);
 
 void JsonObjectAppend(JsonValue *Array, JsonValue *Val);
 
-void SerializeJson(StrBuf *Target, JsonValue *Val);
+void SerializeJson(StrBuf *Target, JsonValue *Val, int FreeVal);
 
 
 
@@ -505,9 +505,9 @@ typedef enum _WF_MessageType {
        eEXCEPTION
 } WF_MessageType;
 
-JsonValue *WildFireException(StrBuf *Message,
-                            const char *Filename, long FileLen,
+JsonValue *WildFireException(const char *Filename, long FileLen,
                             long LineNo,
+                            StrBuf *Message,
                             int StackOffset);
 
 void WildFireAddArray(JsonValue *ReportBase, JsonValue *Array, WF_MessageType Type);
index e3e1e239cf96b33afbc249530a36be461e6402bb..de57379dacb99dfc535314b3789a8ac1f5e2ccc2 100644 (file)
@@ -653,11 +653,6 @@ long StrECMAEscAppend(StrBuf *Target, const StrBuf *Source, const char *PlainIn)
                        memcpy(bptr, "\\\"", 2);
                        bptr += 2;
                        Target->BufUsed += 2;
-               }
-               else if (*aptr == '\'') {
-                       memcpy(bptr, "\\\'", 2);
-                       bptr += 2;
-                       Target->BufUsed += 2;
                } else if (*aptr == '\\') {
                  memcpy(bptr, "\\\\", 2);
                  bptr += 2;
index 9fe53faa2ea8def2a371c29c81fa1b938f62ce6e..6d6669034c3d5c9e8617dd710b59c9bd4e9bc480 100644 (file)
 
 
 ConstStr WF_MsgStrs[] = {
+       {HKEY("LOG")},
        {HKEY("INFO")},
        {HKEY("WARN")},
        {HKEY("ERROR")},
-       {HKEY("LOG")},
        {HKEY("TRACE")},
        {HKEY("EXCEPTION")}
 };
@@ -218,7 +218,7 @@ void WildFireInitBacktrace(const char *argvNull, int AddBaseFrameSkip)
        BaseFrames --;
        BaseFrames += AddBaseFrameSkip;
        strings = backtrace_symbols(stack_frames, size);
-       for (i = 0; i < size; i++) {
+       for (i = 1; i < size; i++) {
                if (strings != NULL){
                        ParseBacktrace(strings[i], Function, 
                                       FileName, 
@@ -258,9 +258,9 @@ void WildFireInitBacktrace(const char *argvNull, int AddBaseFrameSkip)
 }
 
 
-JsonValue *WildFireException(StrBuf *Message,
-                            const char *Filename, long FileLen,
+JsonValue *WildFireException(const char *Filename, long FileLen,
                             long LineNo,
+                            StrBuf *Message,
                             int StackOffset)
 {
        JsonValue *ExcClass;