From 47cace98369f60df2351a65801c8065bb7f9dbf0 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 18 Jun 2009 10:11:50 -0700 Subject: add file_getprop() to updater Add a function to read a property from a ".prop"-formatted file (key=value pairs, one per line, ignore # comment lines and blank lines). Move ErrorAbort to the core of edify; it's not specific to updater now that errors aren't stored in the app cookie. --- edify/expr.c | 13 +++++++++++++ edify/expr.h | 4 ++++ 2 files changed, 17 insertions(+) (limited to 'edify') diff --git a/edify/expr.c b/edify/expr.c index f1c5555..72e5100 100644 --- a/edify/expr.c +++ b/edify/expr.c @@ -417,3 +417,16 @@ char** ReadVarArgs(State* state, int argc, Expr* argv[]) { } return args; } + +// Use printf-style arguments to compose an error message to put into +// *state. Returns NULL. +char* ErrorAbort(State* state, char* format, ...) { + char* buffer = malloc(4096); + va_list v; + va_start(v, format); + vsnprintf(buffer, 4096, format, v); + va_end(v); + free(state->errmsg); + state->errmsg = buffer; + return NULL; +} diff --git a/edify/expr.h b/edify/expr.h index 671b499..d2e7392 100644 --- a/edify/expr.h +++ b/edify/expr.h @@ -118,5 +118,9 @@ int ReadArgs(State* state, Expr* argv[], int count, ...); // strings it contains. char** ReadVarArgs(State* state, int argc, Expr* argv[]); +// Use printf-style arguments to compose an error message to put into +// *state. Returns NULL. +char* ErrorAbort(State* state, char* format, ...); + #endif // _EXPRESSION_H -- cgit v1.1