From fdc72de3b406dd496f577ac54c935c99ac39fd9e Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 17 Sep 2023 19:29:16 -0400 Subject: [PATCH] I have no words to describe the fuckery I am trying to reverse-enginner here. Ever heard of COMMENTS? --- libcitadel/lib/wildfire.c | 117 +++----------------------------------- 1 file changed, 8 insertions(+), 109 deletions(-) diff --git a/libcitadel/lib/wildfire.c b/libcitadel/lib/wildfire.c index b15c9825a..02a2cb914 100644 --- a/libcitadel/lib/wildfire.c +++ b/libcitadel/lib/wildfire.c @@ -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 #include @@ -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); - -} - -*/ -- 2.30.2