From 99981540182c29049e971a3cb9a772d7f107b2ab Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 20 Jan 2008 22:16:59 +0100 Subject: [PATCH] add support for listing config files --- .gitignore | 4 ++-- Makefile | 19 +++++++++++----- cli.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ libuci.c | 12 ++++++++++ list.c | 30 +++++++++++++++++++++++++ parse.c | 4 ---- test.c | 30 ------------------------- uci.h | 15 +++++++++++-- 8 files changed, 135 insertions(+), 43 deletions(-) create mode 100644 cli.c delete mode 100644 test.c diff --git a/.gitignore b/.gitignore index 5d893ce..fabbfaa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -parsetest -*.o +uci +*.[oa] .*.swp diff --git a/Makefile b/Makefile index 645ec65..ec382ed 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,21 @@ +COPTS=-g -O2 +CFLAGS=$(COPTS) -Wall -pedantic -std=gnu99 -Wno-unused -Werror + +AR=ar CC=gcc -CFLAGS=-g -O2 -Wall -pedantic -std=gnu99 -Wno-unused -Werror +RANLIB=ranlib + +all: uci -all: parsetest -parsetest: libuci.o test.o +cli.o: cli.c uci.h +uci: cli.o libuci.a $(CC) $(CFLAGS) -o $@ $^ libuci.o: libuci.c parse.c uci.h list.c err.h -test.o: test.c uci.h +libuci.a: libuci.o + rm -f $@ + $(AR) rc $@ $^ + $(RANLIB) $@ clean: - rm -f parsetest *.o + rm -f uci *.[oa] diff --git a/cli.c b/cli.c new file mode 100644 index 0000000..d83e257 --- /dev/null +++ b/cli.c @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2008 Felix Fietkau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include +#include +#include "uci.h" + +static struct uci_context *ctx; + +static void uci_usage(int argc, char **argv) +{ + fprintf(stderr, + "Usage: %s [options] [arguments]\n\n" + "Commands:\n" + "\tshow [[.
[.