forked from crash-utility/crash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.c
99 lines (85 loc) · 2.48 KB
/
test.c
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* test.c - core analysis suite
*
* Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
* Copyright (C) 2002, 2003, 2004, 2005, 2011 David Anderson
* Copyright (C) 2002, 2003, 2004, 2005, 2011 Red Hat, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "defs.h"
#include <getopt.h>
static struct option test_long_options[] = {
{"no", no_argument, 0, 0},
{"req", required_argument, 0, 0},
{0, 0, 0, 0}
};
/*
* Test your stuff here first if you'd like. If anything's being done
* below in this routine, consider it leftover trash...
*/
void
cmd_test(void)
{
int c;
int option_index;
while ((c = getopt_long(argcnt, args, "",
test_long_options, &option_index)) != EOF) {
switch(c)
{
case 0:
if (STREQ(test_long_options[option_index].name, "no"))
fprintf(fp, "no argument\n");
if (STREQ(test_long_options[option_index].name, "req"))
fprintf(fp, "required argument: %s\n", optarg);
break;
default:
argerrs++;
break;
}
}
if (argerrs)
cmd_usage(pc->curcmd, SYNOPSIS);
while (args[optind]) {
;
optind++;
}
}
/*
* Scratch routine for testing a feature on a per-task basis by entering
* the "foreach test" command. Like cmd_test(), anything that's being done
* below in this routine can be considered trash.
*/
void
foreach_test(ulong task, ulong flags)
{
}
/*
* Template for building a new command.
*/
void
cmd_template(void)
{
int c;
while ((c = getopt(argcnt, args, "")) != EOF) {
switch(c)
{
default:
argerrs++;
break;
}
}
if (argerrs)
cmd_usage(pc->curcmd, SYNOPSIS);
while (args[optind]) {
;
optind++;
}
}