Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=b35da539ea60ccf71deb1b7043a57ddd210d9ee5

commit b35da539ea60ccf71deb1b7043a57ddd210d9ee5
Author: James Buren <[email protected]>
Date:   Sat Jul 14 23:06:26 2012 -0500

initial draft of backend

diff --git a/backend.c b/backend.c
new file mode 100644
index 0000000..f4e27b7
--- /dev/null
+++ b/backend.c
@@ -0,0 +1,49 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
+#include <errno.h>
+#include "backend.h"
+
+static FILE *out = 0;
+static char *text = 0;
+static size_t size = 0;
+static bool memory = false;
+
+extern int backend_set_log_to_file(const char *path)
+{
+       // Refuse to change output target more than once.
+       if(out != 0)
+       {
+               errno = EINVAL;
+
+               return -1;
+       }
+
+       out = fopen(path,"wb");
+
+       if(out == 0)
+               return -1;
+
+       return 0;
+}
+
+extern int backend_set_log_to_memory(void)
+{
+       // Refuse to change output target more than once.
+       if(out != 0)
+       {
+               errno = EINVAL;
+
+               return -1;
+       }
+
+       out = open_memstream(&text,&size);
+
+       if(out == 0)
+               return -1;
+
+       memory = true;
+
+       return 0;
+}
diff --git a/backend.h b/backend.h
new file mode 100644
index 0000000..9543857
--- /dev/null
+++ b/backend.h
@@ -0,0 +1,4 @@
+#pragma once
+
+extern int backend_log_to_file(const char *path);
+extern int backend_set_log_to_memory(void);
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to