summaryrefslogtreecommitdiff
path: root/openwrt/package/nvram
diff options
context:
space:
mode:
authorWaldemar Brodkorb <mail@waldemar-brodkorb.de>2006-01-31 15:22:43 +0000
committerWaldemar Brodkorb <mail@waldemar-brodkorb.de>2006-01-31 15:22:43 +0000
commitb0a0f0ebe4d4e43a24dc38ba927436911eddaaf8 (patch)
tree1f410336a5b6414a52ddf89d40eb3f625fadc2a4 /openwrt/package/nvram
parent37a9e05efb8768ac61e4ca190e86813351b779d1 (diff)
downloadmtk-20170518-b0a0f0ebe4d4e43a24dc38ba927436911eddaaf8.zip
mtk-20170518-b0a0f0ebe4d4e43a24dc38ba927436911eddaaf8.tar.gz
mtk-20170518-b0a0f0ebe4d4e43a24dc38ba927436911eddaaf8.tar.bz2
add changes to nvram from #254/#266, resolves problems on older wap54g, thx for report
SVN-Revision: 3089
Diffstat (limited to 'openwrt/package/nvram')
-rw-r--r--openwrt/package/nvram/src/main.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/openwrt/package/nvram/src/main.c b/openwrt/package/nvram/src/main.c
index a64430f..7af2672 100644
--- a/openwrt/package/nvram/src/main.c
+++ b/openwrt/package/nvram/src/main.c
@@ -26,6 +26,15 @@ usage(void)
exit(0);
}
+/* hack for some PMON default nvram values which have '\r' appended */
+void
+puts_trim_cr(char *str)
+{
+ int len= strlen(str);
+ if (len && (str[len-1] == '\r')) len--;
+ printf("%.*s\n", len, str);
+}
+
/* NVRAM utility */
int
main(int argc, char **argv)
@@ -44,8 +53,9 @@ main(int argc, char **argv)
for (; *argv; argv++) {
if (!strncmp(*argv, "get", 3)) {
if (*++argv) {
- if ((value = nvram_get(*argv)))
- puts(value);
+ if ((value = nvram_get(*argv))) {
+ puts_trim_cr(value);
+ }
}
}
else if (!strncmp(*argv, "set", 3)) {
@@ -66,7 +76,7 @@ main(int argc, char **argv)
!strncmp(*argv, "getall", 6)) {
nvram_getall(buf, sizeof(buf));
for (name = buf; *name; name += strlen(name) + 1)
- puts(name);
+ puts_trim_cr(name);
size = sizeof(struct nvram_header) + (int) name - (int) buf;
fprintf(stderr, "size: %d bytes (%d left)\n", size, NVRAM_SPACE - size);
}