Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=1719c34be8a433d9e44da4fd88008e628ac784e8
commit 1719c34be8a433d9e44da4fd88008e628ac784e8 Author: James Buren <[email protected]> Date: Sat Jul 14 23:20:12 2012 -0500 expose a log printf function diff --git a/backend.c b/backend.c index f4e27b7..031a834 100644 --- a/backend.c +++ b/backend.c @@ -1,6 +1,7 @@ #include <stdlib.h> #include <stdio.h> #include <stdbool.h> +#include <stdarg.h> #include <string.h> #include <errno.h> #include "backend.h" @@ -9,6 +10,7 @@ static FILE *out = 0; static char *text = 0; static size_t size = 0; static bool memory = false; +static long errors = 0; extern int backend_set_log_to_file(const char *path) { @@ -47,3 +49,29 @@ extern int backend_set_log_to_memory(void) return 0; } + +extern int backend_log(const char *format,...) +{ + va_list args; + int rv = 0; + + if(out == 0 || format == 0) + { + errno = EINVAL; + + return -1; + } + + va_start(args,format); + + if(vfprintf(out,format,args) < 0 || fflush(out) == EOF) + { + ++errors; + + rv = -1; + } + + va_end(args); + + return rv; +} diff --git a/backend.h b/backend.h index 9543857..fe09980 100644 --- a/backend.h +++ b/backend.h @@ -2,3 +2,4 @@ extern int backend_log_to_file(const char *path); extern int backend_set_log_to_memory(void); +extern int backend_log(const char *format,...) __attribute__((format(printf,1,2))); _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
