-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommand.c
68 lines (48 loc) · 1.29 KB
/
command.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
#include "stride.h"
FILE *efopen(char *file, char *mode, char *progname) /* fopen file, die if can't */
{
FILE *fp;
if( (fp=fopen(file,mode)) )
return fp;
else
die("%s: can't open file %s mode %s\n",progname,file,mode);
return(FAILURE);
}
int Uniq(char **List, int ListLength)
{
int i, j;
for( i=1; i<ListLength-1; i++ ) {
if( *List[i] != '-' ) continue;
for( j=i+1; j<ListLength; j++ ) {
if( *List[j] != '-' ) continue;
if( !strcmp(List[i],List[j] ) ) return(0);
}
}
return(1);
}
BOOLEAN Specified(char **List, int ListLength, char Option)
{
int i;
for( i=1; i<ListLength; i++ )
if( *List[i] == '-' && *(List[i]+1) == Option )
return(YES);
return(NO);
}
int Parse(char **List, int ListLength, char *Option)
{
int i;
for( i=1; i<ListLength; i++ ) {
if( *List[i] != '-' ) continue;
if( !strcmp(List[i],Option) ) return(i);
}
return(0);
}
int CollectOptions(char **List, int ListLength, int Stream, int *Options)
{
int OptCnt, i;
OptCnt = 0;
for( i=1; i<ListLength; i++ )
if( *List[i] == '-' && !isdigit( *(List[i]+1) ) && atoi( List[i]+2 ) == Stream )
Options[OptCnt++] = i;
return(OptCnt);
}