summaryrefslogtreecommitdiffstats
path: root/boot/bootargs.c
blob: 81ba57dedcde9a519b0d6a12c98f317c481903d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "bootargs.h"
#include "boot.h"
#include "string.h"
#include <stdint.h>
#include "print.h"

char*
bootargs_getarg(const char *key)
{
    size_t keylen = strlen(key);
    char *arg = jove_bootargs;
    for(; (uintptr_t)arg < (uintptr_t)jove_bootargs + jove_bootargs_len; arg += strlen(arg) + 1) {
        size_t arglen = strlen(arg);
        if(arglen < keylen) continue;

        for(size_t i = 0; i < keylen; i++) {
            if(arg[i] != key[i]) goto eol;
        }
        if(arg[keylen] != '=') continue;
        return arg + keylen + 1;
eol:
        continue;
    }
    return NULL;
}