2 * Frontend command-line utility for Linux NVRAM layer
4 * Copyright 2004, Broadcom Corporation
7 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
25 fprintf(stderr
, "usage: nvram [get name] [set name=value] [unset name] [commit] [show]\n");
29 /* hack for some PMON default nvram values which have '\r' appended */
31 puts_trim_cr(char *str
)
34 if (len
&& (str
[len
-1] == '\r')) len
--;
35 printf("%.*s\n", len
, str
);
40 main(int argc
, char **argv
)
42 char *name
, *value
, buf
[NVRAM_SPACE
];
45 /* Skip program name */
52 /* Process the remaining arguments. */
53 for (; *argv
; argv
++) {
54 if (!strncmp(*argv
, "get", 3)) {
56 if ((value
= nvram_get(*argv
))) {
61 else if (!strncmp(*argv
, "set", 3)) {
63 strncpy(value
= buf
, *argv
, sizeof(buf
));
64 name
= strsep(&value
, "=");
65 nvram_set(name
, value
);
68 else if (!strncmp(*argv
, "unset", 5)) {
72 else if (!strncmp(*argv
, "commit", 5)) {
75 else if (!strncmp(*argv
, "show", 4) ||
76 !strncmp(*argv
, "getall", 6)) {
77 nvram_getall(buf
, sizeof(buf
));
78 for (name
= buf
; *name
; name
+= strlen(name
) + 1)
80 size
= sizeof(struct nvram_header
) + (int) name
- (int) buf
;
81 fprintf(stderr
, "size: %d bytes (%d left)\n", size
, NVRAM_SPACE
- size
);
This page took 0.063327 seconds and 5 git commands to generate.