68 lines
1.2 KiB
C
68 lines
1.2 KiB
C
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sysexits.h>
|
|
#include <unistd.h>
|
|
#include "noargvzero.h"
|
|
|
|
extern char *optarg; /* getopt(3); unistd.h */
|
|
extern int optind, opterr, optopt; /* getopt(3); unistd.h */
|
|
|
|
void
|
|
occurrences(FILE *f, char *s){
|
|
|
|
}
|
|
|
|
void
|
|
usage(char *name){
|
|
fprintf(stderr,
|
|
"Usage: %s (-b [list] (-n))"
|
|
"\t|(-c [list])"
|
|
"\t|(-f [list] (-d [delim]) (-s))"
|
|
"\t[file...]\n", name);
|
|
exit(EX_USAGE);
|
|
}
|
|
|
|
int
|
|
main(int argc, char *argv[]){
|
|
int c;
|
|
char *delimiter;
|
|
char *list;
|
|
char mode;
|
|
|
|
NOARGVZERO(argv[0]);
|
|
|
|
/* perhaps mode could be specified after submodal stuff. this would
|
|
* move checks to after argument parsing though which could take more
|
|
* time. */
|
|
mode = 0;
|
|
submode = 0;
|
|
while((c = getopt(argc, argv, "b:c:d:f:ns")) != -1)
|
|
switch(c){
|
|
case 'b': case 'c': case 'f':
|
|
if(mode != 0)
|
|
usage(argv[0]);
|
|
mode = c;
|
|
list = optarg;
|
|
break;
|
|
|
|
case 'd':
|
|
if(mode != 'f')
|
|
usage(argv[0]);
|
|
delimiter = optarg;
|
|
break;
|
|
|
|
case 'n': case 's':
|
|
if((c == 's' && mode != 'f')
|
|
|| (c == 'b' && mode != 'b'))
|
|
usage(argv[0]);
|
|
submode = c;
|
|
break;
|
|
|
|
default:
|
|
usage(argv[0]);
|
|
}
|
|
|
|
return EX_OK;
|
|
}
|