Commit ab042b1f authored by Richard Curnow's avatar Richard Curnow

Corresponds to CVS V0.5pre3

Original rev  : rc@rc0.org.uk--historical/mairix--history--0--patch-8
parent ce0c3623
NEW IN VERSION 0.5
==================
* When -a option is used for search, avoid symlinking the same message twice if
it matches more than one query.
* Fixes to rpm spec file.
* Fix handling of = in base64-encoded attachments.
* Support non POSIX locales.
* Support rfc2047 encoding in headers.
* Create vfolder if it doesn't already exist.
* Allow searching on complete email addresses as well as individual words in
to, cc and from fields.
NEW IN VERSION 0.4
==================
......
/*
$Header: /cvs/src/mairix/db.c,v 1.3 2002/07/28 23:18:16 richard Exp $
$Header: /cvs/src/mairix/db.c,v 1.4 2002/09/11 22:07:20 richard Exp $
mairix - message index builder and finder for maildir folders.
......@@ -295,17 +295,36 @@ static void add_angled_terms(int file_index, struct toktable *table, char *s)/*{
/*}}}*/
/* Macro for what characters can make up token strings */
#define CHAR_VALID(x) (isalnum(x) || ((x) == '_'))
static void tokenise_string(int file_index, struct toktable *table, char *data)/*{{{*/
static unsigned char special_table[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 00-0f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10-1f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, /* 20-2f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 30-3f */
2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40-4f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, /* 50-5f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60-6f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70-7f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80-8f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 90-9f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* a0-af */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* b0-bf */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* c0-cf */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* d0-df */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* e0-ef */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* f0-ff */
};
#define CHAR_VALID(x,mask) (isalnum(x) || (special_table[(unsigned int)(unsigned char) x] & mask))
static void tokenise_string(int file_index, struct toktable *table, char *data, int match_mask)/*{{{*/
{
char *ss, *es, old_es;
ss = data;
for (;;) {
while (*ss && !CHAR_VALID(*ss)) ss++;
while (*ss && !CHAR_VALID(*ss,match_mask)) ss++;
if (!*ss) break;
es = ss + 1;
while (*es && CHAR_VALID(*es)) es++;
while (*es && CHAR_VALID(*es,match_mask)) es++;
/* deal with token [ss,es) */
old_es = *es;
......@@ -328,7 +347,7 @@ static void tokenise_html_string(int file_index, struct toktable *table, char *d
ss = data;
for (;;) {
/* Assume < and > are never valid token characters ! */
while (*ss && !CHAR_VALID(*ss)) {
while (*ss && !CHAR_VALID(*ss, 1)) {
if (*ss++ == '<') {
/* Skip over HTML tag */
while (*ss && (*ss != '>')) ss++;
......@@ -337,7 +356,7 @@ static void tokenise_html_string(int file_index, struct toktable *table, char *d
if (!*ss) break;
es = ss + 1;
while (*es && CHAR_VALID(*es)) es++;
while (*es && CHAR_VALID(*es, 1)) es++;
/* deal with token [ss,es) */
old_es = *es;
......@@ -355,15 +374,25 @@ static void tokenise_message(int file_index, struct database *db, struct rfc822
{
struct attachment *a;
if (msg->hdrs.to) tokenise_string(file_index, db->to, msg->hdrs.to);
if (msg->hdrs.cc) tokenise_string(file_index, db->cc, msg->hdrs.cc);
if (msg->hdrs.from) tokenise_string(file_index, db->from, msg->hdrs.from);
if (msg->hdrs.subject) tokenise_string(file_index, db->subject, msg->hdrs.subject);
/* Match on whole addresses in these headers as well as the individual words */
if (msg->hdrs.to) {
tokenise_string(file_index, db->to, msg->hdrs.to, 1);
tokenise_string(file_index, db->to, msg->hdrs.to, 2);
}
if (msg->hdrs.cc) {
tokenise_string(file_index, db->cc, msg->hdrs.cc, 1);
tokenise_string(file_index, db->cc, msg->hdrs.cc, 2);
}
if (msg->hdrs.from) {
tokenise_string(file_index, db->from, msg->hdrs.from, 1);
tokenise_string(file_index, db->from, msg->hdrs.from, 2);
}
if (msg->hdrs.subject) tokenise_string(file_index, db->subject, msg->hdrs.subject, 1);
for (a=msg->atts.next; a!=&msg->atts; a=a->next) {
switch (a->ct) {
case CT_TEXT_PLAIN:
tokenise_string(file_index, db->body, a->data.normal.bytes);
tokenise_string(file_index, db->body, a->data.normal.bytes, 1);
break;
case CT_TEXT_HTML:
tokenise_html_string(file_index, db->body, a->data.normal.bytes);
......
/*
$Header: /cvs/src/mairix/mairix.c,v 1.5 2002/09/09 20:45:43 richard Exp $
$Header: /cvs/src/mairix/mairix.c,v 1.7 2002/09/11 22:06:53 richard Exp $
mairix - message index builder and finder for maildir folders.
......@@ -28,6 +28,7 @@
#include <pwd.h>
#include <unistd.h>
#include <ctype.h>
#include <locale.h>
int verbose = 0;
......@@ -135,7 +136,9 @@ static void parse_rc_file(char *name)/*{{{*/
else if (!strncasecmp(p, "vfolder", 7)) vfolder = copy_value(p);
else if (!strncasecmp(p, "database", 8)) database_path = copy_value(p);
else {
fprintf(stderr, "Unrecognized option at line %d in %s\n", lineno, name);
if (verbose) {
fprintf(stderr, "Unrecognized option at line %d in %s\n", lineno, name);
}
}
}
......@@ -184,7 +187,7 @@ static int check_message_list_for_duplicates(struct msgpath_array *msgs)/*{{{*/
static char *get_version(void)/*{{{*/
{
static char buffer[256];
static char cvs_version[] = "$Name: V0_5_pre1 $";
static char cvs_version[] = "$Name: V0_5_pre3 $";
char *p, *q;
for (p=cvs_version; *p; p++) {
if (*p == ':') {
......@@ -218,7 +221,7 @@ static void print_copyright(void)/*{{{*/
get_version());
}
/*}}}*/
static void usage(void)
static void usage(void)/*{{{*/
{
print_copyright();
......@@ -249,7 +252,7 @@ static void usage(void)
" (See documentation for more examples)\n"
);
}
/*}}}*/
/* Notes on folder management: {{{
Assumption is that the user wants to keep the 'vfolder' directories under a
......@@ -289,6 +292,8 @@ int main (int argc, char **argv)/*{{{*/
int any_purges = 0;
int do_help = 0;
setlocale(LC_CTYPE, "");
while (++argv, --argc) {
if (!*argv) {
break;
......
Summary: A maildir indexer and searcher
Name: mairix
Version: 0.5_pre2
Version: 0.5
Release: 1
Source: mairix-%{version}
Source: mairix-%{version}.tar.gz
Copyright: GPL
Group: Application/Internet
Packager: Richard P. Curnow
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
BuildRoot: %{_tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
mairix is a tool for indexing email messages stored in maildir format folders
......@@ -28,7 +28,7 @@ cd $RPM_BUILD_DIR/mairix-%{version}
make install prefix=$RPM_BUILD_ROOT/usr
mkdir -p $RPM_BUILD_ROOT/usr/share/info
cp mairix.info* $RPM_BUILD_ROOT/usr/share/info
cp README mairix.txt mairix.html mairix.pdf dotmairixrc.eg ..
cp README mairix.txt mairix.html dotmairixrc.eg ..
%files
/usr/bin/mairix
......
......@@ -172,6 +172,18 @@ contain particular words. @emph{mairix} defines a word as any string of
alphanumeric characters + underscore. Any whitespace, punctuation, hyphens etc
are treated as word boundaries.
@emph{mairix} has special handling for the @t{To:}, @t{Cc:} and @t{From:}
headers. Besides the normal word scan, these headers are scanned a second
time, where the characters @samp{@@}, @samp{-} and @samp{.} are also treated as
word characters. This allows most (if not all) email addresses to appear in
the database as single words. So if you have a mail from
@t{wibble@@foobar.zzz}, it will match on both these searches
@example
mairix f:foobar
mairix f:wibble@@foobar.zzz
@end example
It should be clear by now that the searching cannot be used to find messages
matching general regular expressions. Personally, I don't find that much use
anyway for locating old messages - I'm far more likely to remember particular
......
/*
$Header: /cvs/src/mairix/rfc822.c,v 1.3 2002/07/28 23:18:16 richard Exp $
$Header: /cvs/src/mairix/rfc822.c,v 1.7 2002/09/11 22:13:23 richard Exp $
mairix - message index builder and finder for maildir folders.
**********************************************************************
* Copyright (C) Richard P. Curnow 2002
* rfc2047 decode Copyright (C) Mikael Ylikoski 2002
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
......@@ -22,7 +23,6 @@
**********************************************************************
*/
#include "mairix.h"
#include <assert.h>
......@@ -124,12 +124,159 @@ static int match_string(char *ref, char *candidate)/*{{{*/
return !strncasecmp(ref, candidate, len);
}
/*}}}*/
static char equal_table[] = {/*{{{*/
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 00-0f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10-1f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 20-2f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, /* 30-3f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40-4f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 50-5f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60-6f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70-7f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80-8f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 90-9f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* a0-af */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* b0-bf */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* c0-cf */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* d0-df */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* e0-ef */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* f0-ff */
};
/*}}}*/
static int base64_table[] = {/*{{{*/
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 00-0f */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 10-1f */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 20-2f */
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, 0, -1, -1, /* 30-3f */
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 40-4f */
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 50-5f */
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 60-6f */
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, /* 70-7f */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 80-8f */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 90-9f */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* a0-af */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* b0-bf */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* c0-cf */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* d0-df */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* e0-ef */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* f0-ff */
};
/*}}}*/
static int hex_to_val(char x) {/*{{{*/
switch (x) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
return (x - '0');
break;
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
return 10 + (x - 'a');
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
return 10 + (x - 'A');
break;
default:
return 0;
}
}
/*}}}*/
static void decode_header_value(char *text){/*{{{*/
/* rfc2047 decode, written by Mikael Ylikoski */
char *s, *a, *b, *e, *p, *q;
for (p = q = s = text; (s = strstr(s, "=?")); s = e + 2) {
if (p == q)
p = q = s;
else
while (q != s)
*p++ = *q++;
s += 2;
a = strchr(s, '?');
if (!a) break;
a++;
b = strchr(a, '?');
if (!b) break;
b++;
e = strstr(b, "?=");
if (!e) break;
/* have found an encoded-word */
if (b - a != 2)
continue; /* unknown encoding */
if (*a == 'q' || *a == 'Q') {
int val;
q = b;
while (q < e) {
if (*q == '_') {
*p++ = 0x20;
q++;
} else if (*q == '=') {
q++;
val = hex_to_val(*q++) << 4;
val += hex_to_val(*q++);
*p++ = val;
} else
*p++ = *q++;
}
} else if (*a == 'b' || *a == 'B') {
int reg, nc, eq; /* register, #characters in reg, #equals */
int dc; /* decoded character */
eq = reg = nc = 0;
for (q = b; q < e; q++) {
unsigned char cq = *(unsigned char *)q;
dc = base64_table[cq];
eq += equal_table[cq];
if (dc >= 0) {
reg <<= 6;
reg += dc;
nc++;
if (nc == 4) {
*p++ = ((reg >> 16) & 0xff);
if (eq < 2) *p++ = ((reg >> 8) & 0xff);
if (eq < 1) *p++ = reg & 0xff;
nc = reg = 0;
if (eq) break;
}
}
}
} else {
continue; /* unknown encoding */
}
q = e + 2;
}
if (p == q) return;
while (*q != '\0')
*p++ = *q++;
*p = '\0';
}
/*}}}*/
static char *copy_header_value(char *text){/*{{{*/
char *p;
for (p = text; *p && (*p != ':'); p++) ;
if (!*p) return NULL;
p++;
return new_string(p);
p = new_string(p);
decode_header_value(p);
return p;
}
/*}}}*/
static enum encoding_type decode_encoding_type(char *e)/*{{{*/
......@@ -252,80 +399,7 @@ static char *looking_at_ws_then_newline(char *start)/*{{{*/
assert(0);
}
/*}}}*/
static int hex_to_val(char x) {/*{{{*/
switch (x) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
return (x - '0');
break;
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
return 10 + (x - 'a');
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
return 10 + (x - 'A');
break;
default:
return 0;
}
}
/*}}}*/
static char equal_table[] = {/*{{{*/
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 00-0f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 10-1f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, /* 20-2f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 30-3f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 40-4f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 50-5f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 60-6f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 70-7f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 80-8f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 90-9f */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* a0-af */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* b0-bf */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* c0-cf */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* d0-df */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* e0-ef */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* f0-ff */
};
/*}}}*/
static int base64_table[] = {/*{{{*/
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 00-0f */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 10-1f */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, /* 20-2f */
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, /* 30-3f */
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 40-4f */
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 50-5f */
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, /* 60-6f */
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, /* 70-7f */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 80-8f */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 90-9f */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* a0-af */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* b0-bf */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* c0-cf */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* d0-df */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* e0-ef */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* f0-ff */
};
/*}}}*/
static char *unencode_data(char *input, int input_len, char *enc, int *output_len)/*{{{*/
{
enum encoding_type encoding;
......@@ -527,6 +601,7 @@ static void do_body(char *body_start, int body_len, char *content_type, char *co
/* Add null termination on the end */
new_att->data.normal.bytes = new_array(char, decoded_body_len + 1);
memcpy(new_att->data.normal.bytes, decoded_body, decoded_body_len + 1);
free(decoded_body);
enqueue(atts, new_att);/*}}}*/
}
}
......@@ -786,7 +861,7 @@ struct rfc822 *make_rfc822(char *filename)/*{{{*/
data = (char *) mmap(0, len, PROT_READ, MAP_SHARED, fd, 0);
if (close(fd) < 0)
perror("close");
if ((int) data < 0) {
if ((int) data <= 0) {
perror("mmap");
return NULL;
}
......
/*
$Header: /cvs/src/mairix/search.c,v 1.5 2002/09/09 20:45:43 richard Exp $
$Header: /cvs/src/mairix/search.c,v 1.6 2002/09/11 21:21:09 richard Exp $
mairix - message index builder and finder for maildir folders.
......@@ -840,6 +840,52 @@ static void do_search(struct read_db *db, char **args, char *output_dir, int sho
}
/*}}}*/
static int directory_exists(char *name)/*{{{*/
{
struct stat sb;
if (stat(name, &sb) < 0) {
return 0;
}
if (S_ISDIR(sb.st_mode)) {
return 1;
} else {
return 0;
}
}
/*}}}*/
static void create_dir(char *path)/*{{{*/
{
if (mkdir(path, 0700) < 0) {
perror("mkdir");
exit(1);
}
fprintf(stderr, "Created directory %s\n", path);
return;
}
/*}}}*/
static void create_maildir(char *path)/*{{{*/
{
char *subdir, *tailpos;
int len;
create_dir(path);
len = strlen(path);
subdir = new_array(char, len + 5);
strcpy(subdir, path);
strcpy(subdir+len, "/");
tailpos = subdir + len + 1;
strcpy(tailpos,"cur");
create_dir(subdir);
strcpy(tailpos,"new");
create_dir(subdir);
strcpy(tailpos,"tmp");
create_dir(subdir);
return;
}
/*}}}*/
static void clear_maildir_subfolder(char *path, char *subdir)/*{{{*/
{
char *sdir;
......@@ -928,6 +974,19 @@ void search_top(int do_threads, int do_augment, char *database_path, char *folde
strcat(complete_vfolder, "/");
strcat(complete_vfolder, vfolder);
if (!directory_exists(complete_vfolder)) {
switch (ft) {
case FT_MAILDIR:
create_maildir(complete_vfolder);
break;
case FT_MH:
create_dir(complete_vfolder);
break;
default:
assert(0);
}
}
if (!do_augment) {
switch (ft) {
case FT_MAILDIR:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment