]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/proc-cmdline.h
util-lib: various improvements to kernel command line parsing
[thirdparty/systemd.git] / src / basic / proc-cmdline.h
CommitLineData
4e731273
LP
1#pragma once
2
3/***
4 This file is part of systemd.
5
6 Copyright 2010 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
1d84ad94
LP
22#include <stdbool.h>
23
24#include "log.h"
25
26enum {
27 PROC_CMDLINE_STRIP_RD_PREFIX = 1,
28 PROC_CMDLINE_VALUE_OPTIONAL = 2,
29};
30
31typedef int (*proc_cmdline_parse_t)(const char *key, const char *value, void *data);
32
4e731273 33int proc_cmdline(char **ret);
1d84ad94
LP
34
35int proc_cmdline_parse(const proc_cmdline_parse_t parse, void *userdata, unsigned flags);
36
37int proc_cmdline_get_key(const char *parameter, unsigned flags, char **value);
38int proc_cmdline_get_bool(const char *key, bool *ret);
39
40char *proc_cmdline_key_startswith(const char *s, const char *prefix);
41bool proc_cmdline_key_streq(const char *x, const char *y);
4e731273
LP
42
43int shall_restore_state(void);
c573dcfe 44const char* runlevel_to_target(const char *rl);
1d84ad94
LP
45
46/* A little helper call, to be used in proc_cmdline_parse_t callbacks */
47static inline bool proc_cmdline_value_missing(const char *key, const char *value) {
48 if (!value) {
49 log_warning("Missing argument for %s= kernel command line switch, ignoring.", key);
50 return true;
51 }
52
53 return false;
54}