Commit 547add5f authored by Richard Curnow's avatar Richard Curnow

Corresponds to CVS V0.2

Original rev  : rc@rc0.org.uk--historical/mairix--history--0--patch-2
parent 6f299530
NEW IN VERSION 0.2
==================
* Substrings of message paths can be used as search expressions (p:substring
option)
* = now used instead of / as the delimiter for number of errors in an
approximate match (to help with path search)
* Bug fix when using -t mode for search with unpurged dead messages still in
the database.
/*
$Header: /cvs/src/mairix/db.c,v 1.1 2002/07/03 22:15:58 richard Exp $
$Header: /cvs/src/mairix/db.c,v 1.2 2002/07/24 22:52:35 richard Exp $
mairix - message index builder and finder for maildir folders.
......@@ -236,6 +236,11 @@ struct database *new_database_from_file(char *db_filename)/*{{{*/
result = new_database();
input = open_db(db_filename);
if (!input) {
/* Nothing to initialise */
if (verbose) printf("Database file was empty, creating a new database\n");
return result;
}
/* Build pathname information */
n = result->n_paths = input->n_paths;
......@@ -641,7 +646,9 @@ static void recode_toktable(struct toktable *tbl, int *new_idx)/*{{{*/
* the natural one and the one where they are now are all occupied, to
* prevent their lookups failing. */
#if 0
fprintf(stderr, "Token <%s> (bucket %d) no longer has files containing it, deleting\n", tok->text, i);
#endif
free(tok->text);
free(new_enc);
free(tok);
......@@ -676,7 +683,9 @@ static void recode_toktable(struct toktable *tbl, int *new_idx)/*{{{*/
while (j != i) {
if (!tbl->tokens[j]) {
/* put it here */
#if 0
fprintf(stderr, "Moved <%s> from bucket %d to %d (natural bucket %d)\n", tbl->tokens[i]->text, i, j, nat_bucket_i);
#endif
tbl->tokens[j] = tbl->tokens[i];
tbl->tokens[i] = NULL;
any_moved = 1;
......
Summary: A maildir indexer and searcher
Name: mairix
Version: 0.1
Release: 2
Version: 0.2
Release: 1
Copyright: GPL
Group: Application/Internet
Packager: Richard P. Curnow
......@@ -13,11 +13,11 @@ and performing fast searches on the resulting index. The output is a new
maildir folder containing symbolic links to the matched messages.
%prep
rm -rf $RPM_BUILD_DIR/mairix-0.1
tar xzvf $RPM_SOURCE_DIR/mairix-0.1.tar.gz
rm -rf $RPM_BUILD_DIR/mairix-0.2
tar xzvf $RPM_SOURCE_DIR/mairix-0.2.tar.gz
%build
cd mairix-0.1
cd mairix-0.2
make CC=gcc CFLAGS=-O2 prefix=/usr
make mairix.txt prefix=/usr
make mairix.info prefix=/usr
......@@ -26,11 +26,11 @@ make mairix.pdf prefix=/usr
%install
rm -rf $RPM_BUILD_ROOT
cd $RPM_BUILD_DIR/mairix-0.1
cd $RPM_BUILD_DIR/mairix-0.2
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 ..
cp README mairix.txt mairix.html mairix.pdf dotmairixrc.eg ..
%files
/usr/bin/mairix
......@@ -39,3 +39,4 @@ cp README mairix.txt mairix.html mairix.pdf ..
%doc mairix.txt
%doc mairix.html
%doc mairix.pdf
%doc dotmairixrc.eg
......@@ -181,8 +181,10 @@ It's also worth pointing out that there is no 'locality' information stored, so
you can't search for messages that have one words 'close' to some other word.
For every message and every word, there is a simple yes/no condition stored -
whether the message contains the word in a particular header or in the body.
So far this has proved to be adequate. mairix has a similar feel to using an
Internet search engine.
There are two further searching criteria that are supported (besides word
There are three further searching criteria that are supported (besides word
searching):
@itemize @bullet
......@@ -190,6 +192,9 @@ searching):
@item Searching for messages whose size is in a particular range. (I see this
being used mainly for finding 'huge' messages, as you're most likely to want to
cull these to recover disc space.)
@item Searching for messages with a particular substring in their paths. You
can use this feature to limit the search to particular folders in your mail
hierarchy, for example.
@end itemize
@node mairixrc
......@@ -349,11 +354,11 @@ Multiple fields may be specified, e.g. @t{sb:pointer} to match in the
@item A negated word, e.g. @samp{s:~pointer}. This matches all messages that
don't have the word @samp{pointer} in the subject line.
@item A substring match, e.g. @samp{s:point/}. This matches all messages
@item A substring match, e.g. @samp{s:point=}. This matches all messages
containing a word in their subject line where the word has @samp{point} as a
substring, e.g. @samp{pointer}, @samp{disappoint}.
@item An approximate match, e.g. @samp{s:point/1}. This matches all messages
@item An approximate match, e.g. @samp{s:point=1}. This matches all messages
containing a word in their subject line where the word has @samp{point} as a
substring with at most one error, e.g. @samp{jointed} contains @samp{joint}
which can be got from @samp{point} with one letter changed. An error can be a
......@@ -364,10 +369,33 @@ messages with one or both of the words @samp{pointer} and @samp{dereference} in
their subject lines.
@item Each disjunction may be a conjunction, e.g.
@samp{s:null+pointer,dereference/2} matches all messages whose subject lines
@samp{s:null+pointer,dereference=2} matches all messages whose subject lines
either contain both the words @samp{null} and @samp{pointer}, or contain the
word @samp{dereference} with up to 2 errors (or both).
@item A path expression. This matches all messages with a particular substring
in their path. The syntax is very similar to that for words within the message
(above), and all the rules for @samp{+}, @samp{,}, approximate matching etc are
the same. The word prefix used for a path expression is @samp{p:}. Examples:
@example
mairix p:/archive/
@end example
matches all messages with @samp{/archive/} in their path, and
@example
mairix p:wibble=1 s:wibble=1
@end example
matches all messages with @samp{wibble} in their path and in their subject
line, allowing up to 1 error in each case (the errors may be different for a
particular message.)
Path expressions always use substring matches and never exact matches (it's
very unlikely you want to type in the whole of a message path as a search
expression!) There is a limit of 32 characters on the match expression.
@end itemize
The binding order of the constructions is:
......@@ -405,7 +433,7 @@ range, and I suspect that some messages I replied to might have had the subject
keyword spelt wrongly (let's allow up to 2 errors):
@example
mairix d:6m- f:richard s:chrony/2
mairix d:6m- f:richard s:chrony=2
@end example
@bye
......
/*
$Header: /cvs/src/mairix/reader.c,v 1.1 2002/07/03 22:15:59 richard Exp $
$Header: /cvs/src/mairix/reader.c,v 1.2 2002/07/24 22:50:13 richard Exp $
mairix - message index builder and finder for maildir folders.
......@@ -95,10 +95,19 @@ struct read_db *open_db(char *filename)/*{{{*/
len = sb.st_size;
data = (char *) mmap(0, len, PROT_READ, MAP_SHARED, fd, 0);
if (!data) {
if ((int)data < 0) {
perror("mmap");
exit(1);
}
if (!data) {
/* Empty file opened => database corrupt for sure */
if (close(fd) < 0) {
perror("close");
exit(1);
}
return NULL;
}
if (close(fd) < 0) {
perror("close");
......
/*
$Header: /cvs/src/mairix/rfc822.c,v 1.1 2002/07/03 22:15:59 richard Exp $
$Header: /cvs/src/mairix/rfc822.c,v 1.2 2002/07/24 22:50:13 richard Exp $
mairix - message index builder and finder for maildir folders.
......@@ -757,7 +757,12 @@ struct rfc822 *make_rfc822(char *filename)/*{{{*/
data = (char *) mmap(0, len, PROT_READ, MAP_SHARED, fd, 0);
close(fd);
if ((int) data < 0) {
perror("mmap");
return NULL;
}
/* Don't process empty files */
if (!data) return NULL;
/* Now process the data */
......
This diff is collapsed.
/*
$Header: /cvs/src/mairix/writer.c,v 1.1 2002/07/03 22:16:00 richard Exp $
$Header: /cvs/src/mairix/writer.c,v 1.2 2002/07/24 22:50:40 richard Exp $
mairix - message index builder and finder for maildir folders.
......@@ -109,7 +109,7 @@ static char *create_file_mapping(char *filename, size_t len)/*{{{*/
}
data = mmap(0, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (!data) {
if ((int)data <= 0) {
perror("mmap");
exit(1);
}
......@@ -258,6 +258,11 @@ static char *write_filenames(struct database *db, struct write_map *map, unsigne
/* File dead */
uidata[map->path_offset + i] = 0; /* Can't ever happen for real */
uidata[map->mtime_offset + i] = 0; /* For cleanliness */
uidata[map->size_offset + i] = 0; /* For cleanliness */
/* The following line is necessary, otherwise 'random' tid
* information is written to the database, which can crash the search
* functions. */
uidata[map->tid_offset + i] = db->paths[i].tid;
}
}
if (verbose) {
......
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