forked from blechschmidt/massdns
-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcmd.h
30 lines (26 loc) · 758 Bytes
/
cmd.h
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
30
#include "massdns.h"
#ifndef MASSDNS_CMD_H
#define MASSDNS_CMD_H
void expect_arg(int i)
{
if (i + 1 >= context.cmd_args.argc)
{
fprintf(stderr, "Missing argument value for %s.\n", context.cmd_args.argv[i]);
context.cmd_args.help_function();
exit(1);
}
}
unsigned long long expect_arg_nonneg(int i, unsigned long long min, unsigned long long max)
{
expect_arg(i);
char *endptr;
unsigned long long result = strtoull(context.cmd_args.argv[i + 1], &endptr, 10);
if(*endptr != 0 || result < min || result > max)
{
fprintf(stderr, "The argument %s requires a value between %llu and %llu.\n",
context.cmd_args.argv[i], min, max);
exit(1);
}
return result;
}
#endif