Back to index

libcitadel  8.12
wildfire_test.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 
00005 #include <sys/types.h>
00006 #include <sys/stat.h>
00007 #include <dirent.h>
00008 #include <errno.h>
00009 
00010 #include <fcntl.h>
00011 
00012 #include <unistd.h>
00013 #include <stddef.h>
00014 
00015 
00016 #include "../lib/libcitadel.h"
00017 
00018 static void CreateWildfireSampleMessage(StrBuf *OutBuf)
00019 {
00020        JsonValue *Error;
00021               
00022        StrBuf *Buf;
00023        StrBuf *Header;
00024        StrBuf *Json;
00025        int n = 1;
00026 
00027        Header = NewStrBuf();
00028        Json = NewStrBuf();
00029 
00030        Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Info message"), eINFO);
00031        SerializeJson(Json, Error, 1);
00032        WildFireSerializePayload(Json, Header, &n, NULL);
00033        StrBufAppendBuf(OutBuf, Header, 0);
00034        FlushStrBuf(Json);
00035        FlushStrBuf(Header);
00036 
00037        Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__,  HKEY("Warn message"), eWARN);
00038        SerializeJson(Json, Error, 1);
00039        WildFireSerializePayload(Json, Header, &n, NULL);
00040        StrBufAppendBuf(OutBuf, Header, 0);
00041        FlushStrBuf(Json);
00042        FlushStrBuf(Header);
00043 
00044        Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Error message"), eERROR);
00045        SerializeJson(Json, Error, 1);
00046        WildFireSerializePayload(Json, Header, &n, NULL);
00047        StrBufAppendBuf(OutBuf, Header, 0);
00048        FlushStrBuf(Json);
00049        FlushStrBuf(Header);
00050 
00051        Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Info message"), eINFO);
00052        SerializeJson(Json, Error, 1);
00053        WildFireSerializePayload(Json, Header, &n, NULL);
00054        StrBufAppendBuf(OutBuf, Header, 0);
00055        FlushStrBuf(Json);
00056        FlushStrBuf(Header);
00057 
00058        Error = WildFireMessagePlain(HKEY(__FILE__), __LINE__, HKEY("Info message"), eINFO);
00059        SerializeJson(Json, Error, 1);
00060        WildFireSerializePayload(Json, Header, &n, NULL);
00061        StrBufAppendBuf(OutBuf, Header, 0);
00062        FlushStrBuf(Json);
00063        FlushStrBuf(Header);
00064 
00065 
00066        Buf = NewStrBufPlain(HKEY("test error message"));
00067        Error = WildFireException(HKEY(__FILE__), __LINE__, Buf, 1);
00068        SerializeJson(Json, Error, 1);
00069        WildFireSerializePayload(Json, Header, &n, NULL);
00070        StrBufAppendBuf(OutBuf, Header, 0);
00071 
00072        FreeStrBuf(&Buf);
00073        FreeStrBuf(&Json);
00074        FreeStrBuf(&Header);
00075 
00076 }
00077 
00078 int main(int argc, char* argv[])
00079 {
00080        StrBuf *WFBuf;
00081        StrBuf *OutBuf;
00082        StrBuf *Info;
00083        int nWildfireHeaders = 0;
00084 
00085        StartLibCitadel(8);
00086        printf("%s == %d?\n", libcitadel_version_string(), libcitadel_version_number());
00087        
00088        
00089        WildFireInitBacktrace(argv[0], 0);
00090 
00091        WFBuf = NewStrBuf();
00092        OutBuf = NewStrBuf();
00093        Info = NewStrBufPlain(HKEY("this is just a test message"));
00094        SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1);
00095        SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1);
00096        SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1);
00097        SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1);
00098        SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1);
00099        SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1);
00100        SerializeJson(WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1);
00101        
00102        WildFireSerializePayload(WFBuf, OutBuf, &nWildfireHeaders, NULL);
00103 
00104        CreateWildfireSampleMessage(OutBuf);
00105        printf("%s\n\n", ChrPtr(OutBuf));
00106 
00107        FreeStrBuf(&WFBuf);
00108        FreeStrBuf(&OutBuf);
00109        FreeStrBuf(&Info);
00110        ShutDownLibCitadel();
00111        return 0;
00112 }