summaryrefslogtreecommitdiffstats
path: root/package/nvram/src/main.c
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-07-24 19:58:14 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-07-24 19:58:14 +0000
commit102ad2157b31642e029c8c176de1cc5b22c96599 (patch)
tree056c21ee081ea7e79141723c2b6a0d083c49a348 /package/nvram/src/main.c
parentb7740460b2e2f7d1249a001275eb1cb015cabb31 (diff)
move wificonf and nvram stuff back to package/, remove build_mipsel/root, run install part of package/ for every board/kernel - fixes dependency mess
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@1540 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/nvram/src/main.c')
-rw-r--r--package/nvram/src/main.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/package/nvram/src/main.c b/package/nvram/src/main.c
new file mode 100644
index 000000000..a64430f7b
--- /dev/null
+++ b/package/nvram/src/main.c
@@ -0,0 +1,78 @@
+/*
+ * Frontend command-line utility for Linux NVRAM layer
+ *
+ * Copyright 2004, Broadcom Corporation
+ * All Rights Reserved.
+ *
+ * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
+ * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
+ * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
+ *
+ * $Id$
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <typedefs.h>
+#include <bcmnvram.h>
+
+static void
+usage(void)
+{
+ fprintf(stderr, "usage: nvram [get name] [set name=value] [unset name] [show]\n");
+ exit(0);
+}
+
+/* NVRAM utility */
+int
+main(int argc, char **argv)
+{
+ char *name, *value, buf[NVRAM_SPACE];
+ int size;
+
+ /* Skip program name */
+ --argc;
+ ++argv;
+
+ if (!*argv)
+ usage();
+
+ /* Process the remaining arguments. */
+ for (; *argv; argv++) {
+ if (!strncmp(*argv, "get", 3)) {
+ if (*++argv) {
+ if ((value = nvram_get(*argv)))
+ puts(value);
+ }
+ }
+ else if (!strncmp(*argv, "set", 3)) {
+ if (*++argv) {
+ strncpy(value = buf, *argv, sizeof(buf));
+ name = strsep(&value, "=");
+ nvram_set(name, value);
+ }
+ }
+ else if (!strncmp(*argv, "unset", 5)) {
+ if (*++argv)
+ nvram_unset(*argv);
+ }
+ else if (!strncmp(*argv, "commit", 5)) {
+ nvram_commit();
+ }
+ else if (!strncmp(*argv, "show", 4) ||
+ !strncmp(*argv, "getall", 6)) {
+ nvram_getall(buf, sizeof(buf));
+ for (name = buf; *name; name += strlen(name) + 1)
+ puts(name);
+ size = sizeof(struct nvram_header) + (int) name - (int) buf;
+ fprintf(stderr, "size: %d bytes (%d left)\n", size, NVRAM_SPACE - size);
+ }
+ if (!*argv)
+ break;
+ }
+
+ return 0;
+}