#include <libubox/avl.h>
#include <libubox/avl-cmp.h>
#include "utils.h"
+#include <asm-generic/setup.h>
+#include <regex.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
void
__blobmsg_list_init(struct blobmsg_list *list, int offset, int len, blobmsg_list_cmp cmp)
return true;
}
+
+char* get_cmdline_val(const char* name, char* out, int len)
+{
+ char line[CMDLINE_SIZE + 1], *c, *sptr;
+ int fd = open("/proc/cmdline", O_RDONLY);
+ ssize_t r = read(fd, line, sizeof(line) - 1);
+ close(fd);
+
+ if (r <= 0)
+ return NULL;
+
+ line[r] = 0;
+
+ for (c = strtok_r(line, " \t\n", &sptr); c;
+ c = strtok_r(NULL, " \t\n", &sptr)) {
+ char *sep = strchr(c, '=');
+ ssize_t klen = sep - c;
+ if (klen < 0 || strncmp(name, c, klen) || name[klen] != 0)
+ continue;
+
+ strncpy(out, &sep[1], len);
+ out[len-1] = 0;
+ return out;
+ }
+
+ return NULL;
+}