[Frugalware-git] yaxmenu: utility.c * add xgetfile
James Buren
ryuo at frugalware.org
Mon Dec 7 20:12:14 CET 2009
Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=yaxmenu.git;a=commitdiff;h=c56cd8fb36768f68f9c2189d7838fc680f211200
commit c56cd8fb36768f68f9c2189d7838fc680f211200
Author: James Buren <ryuo at frugalware.org>
Date: Mon Dec 7 13:11:58 2009 -0600
utility.c
* add xgetfile
diff --git a/src/utility.c b/src/utility.c
index ba56763..c254d62 100644
--- a/src/utility.c
+++ b/src/utility.c
@@ -19,6 +19,7 @@
// THE SOFTWARE.
#include "globals.h"
+#include "flags.h"
#include "utility.h"
static const char comment_char = '#';
@@ -111,6 +112,27 @@ char *xstrtrim(char *str) {
return str;
}
+FILE *xgetfile(const char *fmt,...) {
+ FILE *file;
+ char path[PATH_MAX];
+ va_list args;
+
+ assert(fmt);
+
+ va_start(args,fmt);
+
+ xvsnprintf(path,fmt,args);
+
+ file = fopen(path,"r");
+
+ if(!file && G->flags & FLAG_VERBOSE)
+ eprintf("%s: %s\n",strerror(errno),path);
+
+ va_end(args);
+
+ return file;
+}
+
size_t xparsefile(FILE *file,parser_callback_t fun) {
char line[LINE_MAX];
size_t num;
More information about the Frugalware-git
mailing list