about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-07-17 21:52:04 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-07-17 21:52:04 +0200
commit7e17d9d631f9d47e9a03901c97a54649cd3542eb (patch)
tree6bb8211281f121c2d6f05bba0ab2e3bc2bab8b0e
parent796531b22db24b48192ab4f00a22e1606726fcb6 (diff)
downloadmblaze-7e17d9d631f9d47e9a03901c97a54649cd3542eb.tar.gz
mblaze-7e17d9d631f9d47e9a03901c97a54649cd3542eb.tar.xz
mblaze-7e17d9d631f9d47e9a03901c97a54649cd3542eb.zip
scan: look up mails in map instead of line numbers
-rw-r--r--Makefile2
-rw-r--r--scan.c13
2 files changed, 9 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 6760978..c23e443 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ ALL = scan thread hdr show list unmime mseq
 
 all: $(ALL)
 
-scan: blaze822.o scan.o rfc2047.o
+scan: blaze822.o scan.o seq.o rfc2047.o
 thread: blaze822.o thread.o
 hdr: blaze822.o hdr.o rfc2047.o
 show: blaze822.o show.o rfc2045.o rfc2047.c
diff --git a/scan.c b/scan.c
index 3da54fe..d370f14 100644
--- a/scan.c
+++ b/scan.c
@@ -30,13 +30,9 @@ u8putstr(FILE *out, char *s, size_t l, int pad)
 			putc(' ', out);
 }
 
-long lineno;
-
 void
 oneline(char *file)
 {
-	lineno++;
-
 	int indent = 0;
 	while (*file == ' ' || *file == '\t') {
 		indent++;
@@ -117,7 +113,11 @@ oneline(char *file)
 	}
 	blaze822_decode_rfc2047(subjdec, subj, sizeof subjdec - 1, "UTF-8");
 
-	printf("%c%c %-3ld %-10s  ", flag1, flag2, lineno, date);
+	long lineno = blaze822_seq_find(file);
+	if (lineno)
+		printf("%c%c %-3ld %-10s  ", flag1, flag2, lineno, date);
+	else
+		printf("%c%c     %-10s  ", flag1, flag2, date);
 	u8putstr(stdout, fromdec, 17, 1);
 	printf("  ");
 	int z;
@@ -132,6 +132,9 @@ oneline(char *file)
 int
 main(int argc, char *argv[])
 {
+	char *seqmap = blaze822_seq_open(0);
+	blaze822_seq_load(seqmap);
+
 	int i = blaze822_loop(argc-1, argv+1, oneline);
 
 	printf("%d mails scanned\n", i);