Browse files

Starting airbrake client with the xpath idea

  • Loading branch information...
1 parent 6816526 commit edebfe49492fea6ed2447d0308339d2a8478b56c @abedra committed Jan 14, 2012
Showing with 12 additions and 98 deletions.
  1. +3 −0 Makefile
  2. +0 −2 README.md
  3. +8 −12 test/xpathTest.c → airbrakeClient.c
  4. +0 −11 test/Makefile
  5. +0 −72 test/xmlHandler.c
  6. +1 −1 todo.org
View
3 Makefile
@@ -1,5 +1,8 @@
bungleo:
gcc -Wall -pedantic -Werror -O3 bungleoClient.c bungleoServer.c bungleo.c -o bungleo -lzmq -lhiredis -ljson -ltofu
+airbrakeClient:
+ gcc -o airbrakeClient `xml2-config --cflags` airbrakeClient.c `xml2-config --libs`
+
clean:
rm bungleo
View
2 README.md
@@ -4,8 +4,6 @@ bungle-o is a data capturing service built on top of zeromq, tofu, and redis. It
## Dependencies
-For compiling the Tofu library
-
jansson
wget http://www.digip.org/jansson/releases/jansson-2.2.1.tar.gz
View
20 test/xpathTest.c → airbrakeClient.c
@@ -22,17 +22,10 @@ char *search(char *q, xmlDocPtr doc, xmlXPathContextPtr xpathCtx) {
nodes = xpathObj->nodesetval;
size = (nodes) ? nodes->nodeNr : 0;
- if (size == 1) {
- printf("node %s\n", xmlNodeGetContent(nodes->nodeTab[0]));
- } else {
- for (i = 0; i < size; i++) {
- cur = nodes->nodeTab[i];
- printf("node %s\n", xmlNodeGetContent(cur));
- }
- }
+ result = xmlNodeGetContent(nodes->nodeTab[0]);
xmlXPathFreeObject(xpathObj);
- result = "";
+
return result;
}
@@ -41,7 +34,7 @@ int main(int argc, char **argv)
xmlDocPtr doc;
xmlXPathContextPtr xpathCtx;
- char *filename;
+ char *filename, *class, *message;
filename = argv[1];
@@ -58,8 +51,11 @@ int main(int argc, char **argv)
return 1;
}
- search("/notice/error/class", doc, xpathCtx);
- search("/notice/error/message", doc, xpathCtx);
+ class = search("/notice/error/class", doc, xpathCtx);
+ message = search("/notice/error/message", doc, xpathCtx);
+
+ printf("class: %s\n", class);
+ printf("message: %s\n", message);
xmlXPathFreeContext(xpathCtx);
xmlFreeDoc(doc);
View
11 test/Makefile
@@ -1,11 +0,0 @@
-all: xml xpath
-
-xml:
- gcc -o xml `xml2-config --cflags` xmlHandler.c `xml2-config --libs`
-
-xpath:
- gcc -o xpath `xml2-config --cflags` xpathTest.c `xml2-config --libs`
-
-clean:
- rm xml
- rm xpath
View
72 test/xmlHandler.c
@@ -1,72 +0,0 @@
-#include <stdio.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-typedef struct {
- char *class;
- char *message;
- char *url;
- char *component;
- char *action;
- char *controller;
- char *projectRoot;
- char *environment;
- char *hostname;
-} airbrakeException;
-
-airbrakeException *read(const char *filename) {
- xmlDocPtr doc;
- xmlNodePtr cur;
- airbrakeException *e = malloc(sizeof(airbrakeException));
-
- doc = xmlParseFile(filename);
-
- if (doc == NULL) {
- fprintf(stderr, "Failed to parse %s\n", filename);
- return;
- }
-
- cur = xmlDocGetRootElement(doc);
-
- if (cur == NULL) {
- fprintf(stderr, "empty document\n");
- xmlFreeDoc(doc);
- return;
- }
-
- if (xmlStrcmp(cur->name, (const xmlChar*) "notice")) {
- fprintf(stderr, "wrong document type, root node != notice");
- xmlFreeDoc(doc);
- return;
- }
-
- cur = cur->xmlChildrenNode;
- while (cur != NULL) {
- if (!xmlStrcmp(cur->name, (const xmlChar *) "error")) {
- fprintf(stderr, "Found error node %s\n", cur->name);
- }
- cur = cur->next;
- }
-
- e->class = "ExceptionTest";
- e->message = "Message";
-
- xmlFreeDoc(doc);
- return e;
-}
-
-int main(int argc, char **argv)
-{
- airbrakeException *e;
-
- if (argc != 2) return 1;
-
- e = read(argv[1]);
- printf("Got error from class %s with message %s\n", e->class, e->message);
-
- if (e) free(e);
- xmlCleanupParser();
- xmlMemoryDump();
-
- return 0;
-}
View
2 todo.org
@@ -1,5 +1,5 @@
* DONE combine into single executable with cli args to start server/client
CLOSED: [2012-01-05 Thu 13:21]
-* TODO run through valgrind and cleanup mess
+* INPR run through valgrind and cleanup mess
* TODO put together proper configure (possibly autoconf)
* TODO add benchmarking bits

0 comments on commit edebfe4

Please sign in to comment.