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
26
27
28
29
38
39
48
49
50
51
52
53
54
55
56
57
65
66
67
/* ... */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include <helper/command.h>
#include <helper/nvp.h>
const struct nvp *nvp_name2value(const struct nvp *p, const char *name)
{
while (p->name) {
if (strcmp(name, p->name) == 0)
break;
p++;
}while (p->name) { ... }
return p;
}{ ... }
const struct nvp *nvp_value2name(const struct nvp *p, int value)
{
while (p->name) {
if (value == p->value)
break;
p++;
}while (p->name) { ... }
return p;
}{ ... }
void nvp_unknown_command_print(struct command_invocation *cmd, const struct nvp *nvp,
const char *param_name, const char *param_value)
{
if (param_name)
command_print_sameline(cmd, "%s: Unknown: %s, try one of: ", param_name, param_value);
else
command_print_sameline(cmd, "Unknown param: %s, try one of: ", param_value);
while (nvp->name) {
if ((nvp + 1)->name)
command_print_sameline(cmd, "%s, ", nvp->name);
else
command_print(cmd, "or %s", nvp->name);
nvp++;
}while (nvp->name) { ... }
}{ ... }