1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include <stdbool.h>
5 
6 #define VERB_ANY (UINT_MAX)
7 
8 typedef enum VerbFlags {
9         VERB_DEFAULT      = 1 << 0,  /* The verb to run if no verb is specified */
10         VERB_ONLINE_ONLY  = 1 << 1,  /* Just do nothing when running in chroot or offline */
11 } VerbFlags;
12 
13 typedef struct {
14         const char *verb;
15         unsigned min_args, max_args;
16         VerbFlags flags;
17         int (* const dispatch)(int argc, char *argv[], void *userdata);
18 } Verb;
19 
20 bool running_in_chroot_or_offline(void);
21 
22 const Verb* verbs_find_verb(const char *name, const Verb verbs[]);
23 int dispatch_verb(int argc, char *argv[], const Verb verbs[], void *userdata);
24