-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathargs.c
More file actions
39 lines (34 loc) · 894 Bytes
/
Copy pathargs.c
File metadata and controls
39 lines (34 loc) · 894 Bytes
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
#include <stdio.h>
#include <getopt.h>
#include "args.h"
static struct option long_options[] =
{
{ "text", required_argument, NULL, 't' },
{ "index", no_argument, NULL, 'i' },
{ "suffix-links", no_argument, NULL, 's' },
{ NULL, 0, NULL, 0 }
};
int decode_switches ( int argc, char * argv [], struct TArgs * args )
{
int oi;
int opt;
args -> text = NULL;
args -> index = 0;
args -> suf_link = 0;
while ( ( opt = getopt_long ( argc, argv, "t:is", long_options, &oi ) ) != -1 )
{
switch ( opt )
{
case 't':
args -> text = optarg;
break;
case 'i':
args -> index = 1;
break;
case 's':
args -> suf_link = 1;
break;
}
}
return ( optind );
}