s->len = 0;
s->pos = i;
+ if (!ctx->cmdline[i]) {
+ return false;
+ }
+
while((c = ctx->cmdline[i++])) {
if (c == ' ') {
while ((c = ctx->cmdline[i++]) && c == ' ');
state = PARSE_VAL;
s = &ctx->val;
s->len = 0;
- s->pos = i + 1;
+ s->pos = i;
continue;
}
}
- while ((c = ctx->cmdline[i++]) && c != ' ') {
- s->len++;
- }
-
- i--;
+ s->len++;
}
- ctx->pos = i;
+ ctx->pos = i - 1;
- return !!c;
+ return true;
}
#define MAX_KEYSIZE 16
{
struct extractor ctx = { .cmdline = cmd_line, .pos = 0 };
- while(extract_next_option(&ctx)) {
+ INFO("active kcmds");
+
+ // first option is always kernel itself
+ extract_next_option(&ctx);
+
+ while (extract_next_option(&ctx)) {
if (!ctx.key.len) {
continue;
}
memcpy(kopt->buf, &cmd_line[ctx.key.pos], ctx.key.len);
+ kopt->hashkey = HSTR(kopt->buf, ctx.key.len);
+ hstr_rehash(&kopt->hashkey, HSTR_FULL_HASH);
+
if (ctx.val.len) {
kopt->value = &kopt->buf[ctx.key.len + 1];
size_t max_val_len = maxlen - ctx.key.len;
}
memcpy(kopt->value, &cmd_line[ctx.val.pos], ctx.val.len);
+ INFO(" %-10s =%s", kopt->hashkey.value, kopt->value);
+ }
+ else {
+ INFO(" %s", kopt->hashkey.value);
}
- kopt->hashkey = HSTR(kopt->buf, ctx.key.len);
- hstr_rehash(&kopt->hashkey, HSTR_FULL_HASH);
-
hashtable_hash_in(options, &kopt->node, kopt->hashkey.hash);
}
}