X-Git-Url: http://git.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=cli.c;h=b48567faf90bce689491514b54315897c708c9a3;hp=4bc023445b2c1d59114aaaa4b8745e6e981019a3;hb=236f7468c5eb30f1381a7059cf780b7fe173ec48;hpb=789aa0a4105c34212c2a4a1be7b0c6095691139c diff --git a/cli.c b/cli.c index 4bc0234..b48567f 100644 --- a/cli.c +++ b/cli.c @@ -1,4 +1,5 @@ /* + * cli - Command Line Interface for the Unified Configuration Interface * Copyright (C) 2008 Felix Fietkau * * This program is free software; you can redistribute it and/or modify @@ -11,134 +12,486 @@ * GNU General Public License for more details. */ #include +#include #include +#include #include "uci.h" +#define MAX_ARGS 4 /* max command line arguments for batch mode */ + +static const char *delimiter = " "; +static const char *appname; +static enum { + CLI_FLAG_MERGE = (1 << 0), + CLI_FLAG_QUIET = (1 << 1), + CLI_FLAG_NOCOMMIT = (1 << 2), + CLI_FLAG_BATCH = (1 << 3), +} flags; + +static FILE *input; + static struct uci_context *ctx; -static char *buf = NULL; -static int buflen = 256; +enum { + /* section cmds */ + CMD_GET, + CMD_SET, + CMD_ADD_LIST, + CMD_DEL, + CMD_RENAME, + CMD_REVERT, + /* package cmds */ + CMD_SHOW, + CMD_CHANGES, + CMD_EXPORT, + CMD_COMMIT, + /* other cmds */ + CMD_ADD, + CMD_IMPORT, + CMD_HELP, +}; + +static int uci_cmd(int argc, char **argv); -static void uci_usage(int argc, char **argv) +static void uci_usage(void) { fprintf(stderr, "Usage: %s [] []\n\n" "Commands:\n" - "\tshow [[.
[.