summaryrefslogtreecommitdiff
path: root/libuci.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2008-01-28 02:58:23 +0100
committerFelix Fietkau <nbd@openwrt.org>2008-01-28 02:58:23 +0100
commitf0be94e4d8d2a0c8ab35b932e88170cc37cca4af (patch)
tree47dd95e2bfece7667ce2aa136b753412698035f9 /libuci.c
parent63bc3390aa42f1177da9fb0a71415f31899ae680 (diff)
downloaduci-f0be94e4d8d2a0c8ab35b932e88170cc37cca4af.tar.gz
implement uci_set, improve error handling
Diffstat (limited to 'libuci.c')
-rw-r--r--libuci.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libuci.c b/libuci.c
index 400acd8..c0b4ab0 100644
--- a/libuci.c
+++ b/libuci.c
@@ -73,7 +73,7 @@ int uci_cleanup(struct uci_context *ctx)
return 0;
}
-void uci_perror(struct uci_context *ctx, const char *str)
+void uci_perror(struct uci_context *ctx, const char *prefix)
{
int err;
@@ -85,15 +85,20 @@ void uci_perror(struct uci_context *ctx, const char *str)
if ((err < 0) || (err >= UCI_ERR_LAST))
err = UCI_ERR_UNKNOWN;
+ if (prefix)
+ fprintf(stderr, "%s: ", prefix);
+ if (ctx->func)
+ fprintf(stderr, "%s: ", ctx->func);
+
switch (err) {
case UCI_ERR_PARSE:
if (ctx->pctx) {
- fprintf(stderr, "%s: %s (%s) at line %d, byte %d\n", str, uci_errstr[err], (ctx->pctx->reason ? ctx->pctx->reason : "unknown"), ctx->pctx->line, ctx->pctx->byte);
+ fprintf(stderr, "%s (%s) at line %d, byte %d\n", uci_errstr[err], (ctx->pctx->reason ? ctx->pctx->reason : "unknown"), ctx->pctx->line, ctx->pctx->byte);
break;
}
/* fall through */
default:
- fprintf(stderr, "%s: %s\n", str, uci_errstr[err]);
+ fprintf(stderr, "%s\n", uci_errstr[err]);
break;
}
}