2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2014-12-19 01:48:05 +01:00
|
|
|
#pragma once
|
|
|
|
|
2018-10-10 17:44:09 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2014-12-19 01:48:05 +01:00
|
|
|
#define VERB_ANY ((unsigned) -1)
|
2017-12-11 23:10:11 +01:00
|
|
|
|
|
|
|
typedef enum VerbFlags {
|
2020-04-30 13:59:33 +02:00
|
|
|
VERB_DEFAULT = 1 << 0, /* The verb to run if no verb is specified */
|
|
|
|
VERB_ONLINE_ONLY = 1 << 1, /* Just do nothing when running in chroot or offline */
|
2017-12-11 23:10:11 +01:00
|
|
|
} VerbFlags;
|
2014-12-19 01:48:05 +01:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const char *verb;
|
|
|
|
unsigned min_args, max_args;
|
2017-12-11 23:10:11 +01:00
|
|
|
VerbFlags flags;
|
2014-12-19 01:48:05 +01:00
|
|
|
int (* const dispatch)(int argc, char *argv[], void *userdata);
|
|
|
|
} Verb;
|
|
|
|
|
2017-12-13 22:04:41 +01:00
|
|
|
bool running_in_chroot_or_offline(void);
|
|
|
|
|
2020-04-30 14:20:31 +02:00
|
|
|
const Verb* verbs_find_verb(const char *name, const Verb verbs[]);
|
2014-12-19 01:48:05 +01:00
|
|
|
int dispatch_verb(int argc, char *argv[], const Verb verbs[], void *userdata);
|