mblaze/mseq.c

40 lines
599 B
C
Raw Normal View History

2016-07-16 16:45:39 +00:00
#include <stdio.h>
2016-07-18 15:06:41 +00:00
#include <stdlib.h>
#include <unistd.h>
2016-07-16 16:45:39 +00:00
2016-07-17 19:51:41 +00:00
#include "blaze822.h"
2016-07-16 16:45:39 +00:00
2016-07-20 11:46:39 +00:00
static int nflag;
2016-07-16 16:45:39 +00:00
int
main(int argc, char *argv[])
{
2016-07-20 11:46:39 +00:00
int c;
while ((c = getopt(argc, argv, "n")) != -1)
switch(c) {
case 'n': nflag = 1; break;
default:
// XXX usage
exit(1);
}
2016-07-17 19:51:41 +00:00
char *map = blaze822_seq_open(0);
2016-07-16 16:45:39 +00:00
if (!map)
return 1;
int i;
char *f;
struct blaze822_seq_iter iter = { 0 };
2016-07-20 11:46:39 +00:00
for (i = optind; i < argc; i++) {
while ((f = blaze822_seq_next(map, argv[i], &iter))) {
2016-07-20 11:46:39 +00:00
if (nflag)
printf("%ld\n", iter.line-1);
else
printf("%s\n", f);
free(f);
2016-07-16 16:45:39 +00:00
}
}
return 0;
}