I have no words to describe the fuckery I am trying to reverse-enginner here. Ever...
authorArt Cancro <ajc@citadel.org>
Sun, 17 Sep 2023 23:29:16 +0000 (19:29 -0400)
committerArt Cancro <ajc@citadel.org>
Sun, 17 Sep 2023 23:29:16 +0000 (19:29 -0400)
libcitadel/lib/wildfire.c

index b15c9825a7bd2d3d9aef401f55c35e3072bb81ae..02a2cb9145ca57a8858921a1cc7327f165c7a4f4 100644 (file)
@@ -1,8 +1,6 @@
 // This doesn't belong in the build but WebCit-classic depends on it.
 // When we move to WebCit-NG we will axe this.
 
-/*@{*/
-
 #include "sysdep.h"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -35,11 +33,8 @@ static JsonValue *WFInfo(const char *Filename, long fnlen, long LineNo, WF_Messa
 
        Val = NewJsonObject(NULL, 0);
        JsonObjectAppend(Val, NewJsonPlainString(HKEY("Type"), WF_MsgStrs[Type].Key, WF_MsgStrs[Type].len));
-       JsonObjectAppend(Val, 
-                        NewJsonPlainString(HKEY("File"), 
-                                           Filename, fnlen));
-       JsonObjectAppend(Val, 
-                        NewJsonNumber(HKEY("Line"), LineNo));
+       JsonObjectAppend(Val, NewJsonPlainString(HKEY("File"), Filename, fnlen));
+       JsonObjectAppend(Val, NewJsonNumber(HKEY("Line"), LineNo));
        return Val;
 }
                            
@@ -48,8 +43,7 @@ JsonValue *WildFireMessage(const char *Filename, long fnlen, long LineNo, StrBuf
        JsonValue *Ret;
 
        Ret = NewJsonArray(NULL, 0);
-       JsonArrayAppend(Ret, WFInfo(Filename, fnlen,
-                                   LineNo, Type));
+       JsonArrayAppend(Ret, WFInfo(Filename, fnlen, LineNo, Type));
 
        JsonArrayAppend(Ret, NewJsonString(NULL, 0, Msg, NEWJSONSTRING_COPYBUF));
        return Ret;
@@ -195,9 +189,7 @@ void WildFireInitBacktrace(const char *argvNull, int AddBaseFrameSkip) {
        strings = backtrace_symbols(stack_frames, size);
        for (i = 1; i < size; i++) {
                if (strings != NULL){
-                       ParseBacktrace(strings[i], Function, 
-                                      FileName, 
-                                      &FunctionLine);
+                       ParseBacktrace(strings[i], Function, FileName, &FunctionLine);
                        FullBinaryName = NewStrBufDup(FileName);
                        size = i;
                }
@@ -270,26 +262,16 @@ JsonValue *WildFireException(const char *Filename, long FileLen, long LineNo, St
                strings = backtrace_symbols(stack_frames, size);
                for (i = StackOffset + 1; i < size; i++) {
                        if (strings != NULL){
-                               ParseBacktrace(strings[i], Function, 
-                                              FileName,
-                                              &FunctionLine);
-                               
+                               ParseBacktrace(strings[i], Function, FileName, &FunctionLine);
                        }
                        StrBufPrintf(Pointer, "%p\n", stack_frames[i]);
-                       
-                       addr2lineBacktrace(Function, 
-                                          FileName, 
-                                          Pointer, 
-                                          Buf, 
-                                          &FunctionLine);
-
+                       addr2lineBacktrace(Function, FileName, Pointer, Buf, &FunctionLine);
                        Frame = NewJsonObject(NULL, 0);
                        JsonArrayAppend(Trace, Frame);
                        JsonObjectAppend(Frame, NewJsonString(HKEY("function"), Function, NEWJSONSTRING_COPYBUF));
                        JsonObjectAppend(Frame, NewJsonString(HKEY("file"), FileName, NEWJSONSTRING_COPYBUF));
                        JsonObjectAppend(Frame, NewJsonNumber(HKEY("line"), FunctionLine));
                        JsonObjectAppend(Frame, NewJsonArray(HKEY("args"))); // not supported
-
                        FunctionLine = 0;
                        FlushStrBuf(FileName);
                        FlushStrBuf(Function);
@@ -364,21 +346,11 @@ void WildFireSerializePayload(StrBuf *JsonBuffer, StrBuf *OutBuf, int *MsgCount,
                        Cat = empty;
                }
                if (OutBuf != NULL) {
-                       StrBufAppendPrintf(OutBuf, 
-                                          "%s: %s|%s|%s\r\n", 
-                                          ChrPtr(HeaderName), 
-                                          ChrPtr(N),
-                                          ChrPtr(Buf), 
-                                          Cat);
+                       StrBufAppendPrintf(OutBuf, "%s: %s|%s|%s\r\n", ChrPtr(HeaderName), ChrPtr(N), ChrPtr(Buf), Cat);
                }
                else {
-                       StrBufAppendPrintf(Header, 
-                                          "%s|%s|%s", 
-                                          ChrPtr(N),
-                                          ChrPtr(Buf), 
-                                          Cat);
+                       StrBufAppendPrintf(Header, "%s|%s|%s", ChrPtr(N), ChrPtr(Buf), Cat);
                        AddHdr(ChrPtr(HeaderName), ChrPtr(Header));
-                       
                }
 
                FlushStrBuf(N);
@@ -392,76 +364,3 @@ void WildFireSerializePayload(StrBuf *JsonBuffer, StrBuf *OutBuf, int *MsgCount,
        FreeStrBuf(&Buf);
        FreeStrBuf(&HeaderName);
 }
-
-
-
-
-
-
-/* this is how we do it...
-void CreateWildfireSampleMessage(void)
-{
-       JsonValue *Error;
-               
-       StrBuf *Buf;
-       StrBuf *Header;
-       StrBuf *Json;
-       int n = 1;
-
-       Header = NewStrBuf();
-       Json = NewStrBuf();
-
-       Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Info message"), eINFO);
-       SerializeJson(Json, Error);
-       WildFireSerializePayload(Json, Header, &n, NULL);
-       StrBufAppendBuf(WC->HBuf, Header, 0);
-       DeleteJSONValue(Error);
-       FlushStrBuf(Json);
-       FlushStrBuf(Header);
-
-       Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__,  HKEY("Warn message"), eWARN);
-       SerializeJson(Json, Error);
-       WildFireSerializePayload(Json, Header, &n, NULL);
-       StrBufAppendBuf(WC->HBuf, Header, 0);
-       DeleteJSONValue(Error);
-       FlushStrBuf(Json);
-       FlushStrBuf(Header);
-
-       Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Error message"), eERROR);
-       SerializeJson(Json, Error);
-       WildFireSerializePayload(Json, Header, &n, NULL);
-       StrBufAppendBuf(WC->HBuf, Header, 0);
-       DeleteJSONValue(Error);
-       FlushStrBuf(Json);
-       FlushStrBuf(Header);
-
-       Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Info message"), eINFO);
-       SerializeJson(Json, Error);
-       WildFireSerializePayload(Json, Header, &n, NULL);
-       StrBufAppendBuf(WC->HBuf, Header, 0);
-       DeleteJSONValue(Error);
-       FlushStrBuf(Json);
-       FlushStrBuf(Header);
-
-       Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Info message"), eINFO);
-       SerializeJson(Json, Error);
-       WildFireSerializePayload(Json, Header, &n, NULL);
-       StrBufAppendBuf(WC->HBuf, Header, 0);
-       DeleteJSONValue(Error);
-       FlushStrBuf(Json);
-       FlushStrBuf(Header);
-
-
-       Buf = NewStrBufPlain(HKEY("test error message"));
-       Error = WildFireException(Buf, HKEY(__FILE__), __LINE__, 1);
-       SerializeJson(Json, Error);
-       WildFireSerializePayload(Json, Header, &n, NULL);
-       StrBufAppendBuf(WC->HBuf, Header, 0);
-       DeleteJSONValue(Error);
-
-       FlushStrBuf(Json);
-       FlushStrBuf(Header);
-
-}
-
-*/