Update of /cvsroot/meshdb/src/mailt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv626 Modified Files: Tag: leonard-dev Makefile.am configure.ac datetime.c datetime.h index.c index.h mail.inc mime.c mkill.c msgid.c open.c size.c t.c update.c util.c view.c Log Message: work towards portable index table Index: Makefile.am =================================================================== RCS file: /cvsroot/meshdb/src/mailt/Attic/Makefile.am,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -d -r1.1.2.2 -r1.1.2.3 --- Makefile.am 7 Nov 2004 12:34:39 -0000 1.1.2.2 +++ Makefile.am 8 Nov 2004 12:55:31 -0000 1.1.2.3 @@ -4,7 +4,8 @@ cgibindir = @cgibindir@ htmlmaildir = @htmlmaildir@ -bin_PROGRAMS = update t mkill size msgid +bin_PROGRAMS = update mkill msgid +noinst_PROGRAMS = size t noinst_LIBRARIES = libmail.a libmail_a_SOURCES = index.c datetime.c open.c util.c mime.c @@ -16,4 +17,4 @@ cgibin_PROGRAMS = view view_LDADD = libmail.a -htmlmail_DATA = subjects.html mail.inc +htmlmail_DATA = subjects.php mail.inc Index: configure.ac =================================================================== RCS file: /cvsroot/meshdb/src/mailt/Attic/configure.ac,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -d -r1.1.2.2 -r1.1.2.3 --- configure.ac 7 Nov 2004 12:34:21 -0000 1.1.2.2 +++ configure.ac 8 Nov 2004 12:55:31 -0000 1.1.2.3 @@ -24,7 +24,16 @@ AC_PROG_CC AC_PROG_RANLIB +AC_C_BIGENDIAN + AC_HEADER_STDC -AC_CHECK_HEADERS(err.h inttypes.h) +AC_CHECK_HEADERS(fcntl.h,, + [AC_MSG_ERROR([could not find fcntl.h])]) +AC_CHECK_HEADERS(sys/mman.h) + +AC_FUNC_MMAP +AC_FUNC_STAT +AC_CHECK_FUNCS(open,, + [AC_MSG_ERROR([could not find open syscall])]) AC_OUTPUT Index: datetime.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/datetime.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -d -r1.3 -r1.3.2.1 --- datetime.c 12 Mar 2004 11:33:38 -0000 1.3 +++ datetime.c 8 Nov 2004 12:55:31 -0000 1.3.2.1 @@ -1,10 +1,15 @@ /* Parse dates in a much more releaxed manner than RFC2822... */ -#include <ctype.h> -#include <string.h> -#include <stdlib.h> -#include <time.h> +#if defined(HAVE_CONFIG_H) +# include "config.h" +#endif +#if defined(STDC_HEADERS) +# include <ctype.h> +# include <string.h> +# include <stdlib.h> +#endif + #include "datetime.h" /* skip over white space and comments in parentheses */ Index: datetime.h =================================================================== RCS file: /cvsroot/meshdb/src/mailt/datetime.h,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -d -r1.1.1.1 -r1.1.1.1.2.1 --- datetime.h 10 Aug 2002 03:45:14 -0000 1.1.1.1 +++ datetime.h 8 Nov 2004 12:55:34 -0000 1.1.1.1.2.1 @@ -1,2 +1,14 @@ /* $Id$ */ + +#if TIME_WITH_SYS_TIME +# include <sys/time.h> +# include <time.h> +#else +# if HAVE_SYS_TIME_H +# include <sys/time.h> +# else +# include <time.h> +# endif +#endif + void parse_datetime(const char *, const char *, struct tm *); Index: index.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/index.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -d -r1.3 -r1.3.2.1 --- index.c 24 Nov 2003 05:57:18 -0000 1.3 +++ index.c 8 Nov 2004 12:55:34 -0000 1.3.2.1 @@ -1,11 +1,24 @@ /* $Id$ */ /* Operations to open and map an mailbox index aux file */ -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/mman.h> +#if defined(HAVE_CONFIG_H) +# include "config.h" +#endif +#if defined(STDC_HEADERS) +# include <stdio.h> +# include <string.h> +#endif +#if defined(HAVE_UNISTD_H) +# include <sys/types.h> +# include <unistd.h> +#endif +#if defined(HAVE_SYS_MMAN_H) +# include <sys/mman.h> +#endif + +#if !defined(HAVE_MMAP) +# error "no mmap on this system, and no support for not having it" +#endif #include "index.h" Index: index.h =================================================================== RCS file: /cvsroot/meshdb/src/mailt/index.h,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -d -r1.1.1.1 -r1.1.1.1.2.1 --- index.h 10 Aug 2002 03:45:14 -0000 1.1.1.1 +++ index.h 8 Nov 2004 12:55:34 -0000 1.1.1.1.2.1 @@ -5,35 +5,39 @@ * The first record (mail0) is treated specially. */ -typedef unsigned long msgid_t; +#if defined(HAVE_INTTYPES_H) +#include <inttypes.h> +#endif + +typedef uint32_t msgid_t; typedef const char *cstring_t; typedef char *string_t; struct mail { - size_t hdrlen; /* incl. last blank line */ - size_t bodylen; - off_t pos; /* start of headers in file */ - time_t date; + uint32_t hdrlen; /* incl. last blank line */ + uint32_t bodylen; + uint64_t pos; /* start of headers in file */ + int32_t date; char from[40]; /* Sender's name */ char subject[60]; /* Subject text */ msgid_t parent, child, sibling; /* Thread tree */ - int flags; + uint16_t flags; #define FLAGS_KILLED 0x0001 /* Message has been killed */ }; /* First entry */ struct mail0 { - size_t size; /* size of each entry */ - size_t version; /* version check */ + uint32_t size; /* size of each entry */ + uint32_t version; /* version check */ #define MAIL0_VERSION 1 - off_t end; /* total size of mbox */ - time_t date; /* index update time */ + uint64_t end; /* total size of mbox */ + int32_t date; /* index update time */ char ign4[40]; char ign5[60]; msgid_t msgs; /* number of messages */ msgid_t child; /* first unparented child */ msgid_t ign8; - int flags; + uint16_t flags; }; int index_create(int fd); @@ -42,7 +46,7 @@ struct mail *index_loadn(int fd, int msgs, int readonly); void index_unloadn(struct mail *mail, int msgs); int index_resize(int fd, int msgs); -cstring_t mbox_map(struct mail0 *m0, int mboxfd); +cstring_t mbox_map(struct mail0 *m0, int mboxfd); void mbox_unmap(struct mail0 *m0, cstring_t base); #define READONLY 1 Index: mail.inc =================================================================== RCS file: /cvsroot/meshdb/src/mailt/mail.inc,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -d -r1.1.1.1 -r1.1.1.1.2.1 --- mail.inc 10 Aug 2002 03:45:14 -0000 1.1.1.1 +++ mail.inc 8 Nov 2004 12:55:34 -0000 1.1.1.1.2.1 @@ -3,6 +3,11 @@ /* Utility functions to access mail indices */ + /* + * The following lines should be replaced by what the 'size' + * program reports, ideally when it is run on the same host + * as the web server. + */ $FMT = "Lhdrlen/Lbodylen/Lpos/Ldate/a40from" ."/a60subject/Lparent/Lchild/Lsibling/Lflags"; $FMT0 = "Lsize/Lversion/Lend/Ldate/a40ign4" Index: mime.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/mime.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -d -r1.1.1.1 -r1.1.1.1.2.1 --- mime.c 10 Aug 2002 03:45:14 -0000 1.1.1.1 +++ mime.c 8 Nov 2004 12:55:34 -0000 1.1.1.1.2.1 @@ -1,8 +1,14 @@ /* $Id$ */ -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> -#include <sys/types.h> + +#if defined(HAVE_CONFIG_H) +# include "config.h" +#endif +#if defined(STDC_HEADERS) +# include <stdio.h> +# include <stdlib.h> +# include <ctype.h> +# include <sys/types.h> +#endif #include "index.h" #include "mime.h" Index: mkill.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/mkill.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- mkill.c 24 Nov 2003 06:23:01 -0000 1.2 +++ mkill.c 8 Nov 2004 12:55:34 -0000 1.2.2.1 @@ -5,11 +5,28 @@ * and removes the message from the reply-tree * - or list the messages that are currently killed */ -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> + +#if defined(HAVE_CONFIG_H) +# include "config.h" +#endif +#if defined(STDC_HEADERS) +# include <stdio.h> +# include <unistd.h> +# include <stdlib.h> +# include <string.h> +#endif + +#if TIME_WITH_SYS_TIME +# include <sys/time.h> +# include <time.h> +#else +# if HAVE_SYS_TIME_H +# include <sys/time.h> +# else +# include <time.h> +# endif +#endif + #include "index.h" #include "open.h" #include "util.h" Index: msgid.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/msgid.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- msgid.c 24 Nov 2003 06:27:28 -0000 1.2 +++ msgid.c 8 Nov 2004 12:55:34 -0000 1.2.2.1 @@ -4,11 +4,26 @@ * This program searches for an (unkilled) message with the given * message id. */ -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#if defined(HAVE_CONFIG_H) +# include "config.h" +#endif +#if defined(STDC_HEADERS) +# include <stdio.h> +# include <unistd.h> +# include <stdlib.h> +# include <string.h> +#endif +#if TIME_WITH_SYS_TIME +# include <sys/time.h> +# include <time.h> +#else +# if HAVE_SYS_TIME_H +# include <sys/time.h> +# else +# include <time.h> +# endif +#endif + #include "index.h" #include "open.h" #include "util.h" Index: open.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/open.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -d -r1.3 -r1.3.2.1 --- open.c 12 Mar 2004 11:33:38 -0000 1.3 +++ open.c 8 Nov 2004 12:55:34 -0000 1.3.2.1 @@ -1,15 +1,22 @@ /* $Id$ */ /* Operations to open a mailbox and its index file */ +#if defined(HAVE_CONFIG_H) +# include "config.h" +#endif #include <stdio.h> -#include <stdlib.h> -#include <unistd.h> +#if defined(HAVE_STDLIB_H) +# include <stdlib.h> +#endif +#if defined(HAVE_UNISTD_H) +# include <unistd.h> +#endif #include <fcntl.h> #include "index.h" #include "open.h" -#ifndef __FreeBSD__ +#ifndef O_EXLOCK #define O_EXLOCK 0 #endif Index: size.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/size.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- size.c 24 Nov 2003 06:19:54 -0000 1.2 +++ size.c 8 Nov 2004 12:55:34 -0000 1.2.2.1 @@ -1,7 +1,28 @@ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <time.h> +/* + * Dump the format of the index structure for use in accessing the + * file structure from PHP. + */ + +#if defined(HAVE_CONFIG_H) +# include "config.h" +#endif +#if defined(STDC_HEADERS) +# include <stdio.h> +# include <stdlib.h> +# include <unistd.h> +#endif + +#if TIME_WITH_SYS_TIME +# include <sys/time.h> +# include <time.h> +#else +# if HAVE_SYS_TIME_H +# include <sys/time.h> +# else +# include <time.h> +# endif +#endif + #include "index.h" #define P(t,n) switch(sizeof ((struct t *)0)->n) { \ Index: t.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/t.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- t.c 24 Nov 2003 06:23:53 -0000 1.2 +++ t.c 8 Nov 2004 12:55:34 -0000 1.2.2.1 @@ -1,8 +1,28 @@ /* $Id$ */ -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <time.h> + +/* Dumps the message tree index file for debugging */ + + +#if defined(HAVE_CONFIG_H) +# include "config.h" +#endif +#if defined(STDC_HEADERS) +# include <stdio.h> +# include <stdlib.h> +# include <unistd.h> +#endif + +#if TIME_WITH_SYS_TIME +# include <sys/time.h> +# include <time.h> +#else +# if HAVE_SYS_TIME_H +# include <sys/time.h> +# else +# include <time.h> +# endif +#endif + #include "index.h" #include "open.h" Index: update.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/update.c,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -d -r1.3 -r1.3.2.1 --- update.c 24 Nov 2003 06:26:01 -0000 1.3 +++ update.c 8 Nov 2004 12:55:34 -0000 1.3.2.1 @@ -6,12 +6,19 @@ * - extracts dates, subject and from lines * - constructs or augments an 'In-reply-to' tree. */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <ctype.h> + +#if defined(HAVE_CONFIG_H) +# include "config.h" +#endif +#if defined(STDC_HEADERS) +# include <stdio.h> +# include <stdlib.h> +# include <string.h> +# include <unistd.h> +# include <ctype.h> +#endif #include <sys/stat.h> + #include "index.h" #include "datetime.h" #include "open.h" Index: util.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/util.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -d -r1.1.1.1 -r1.1.1.1.2.1 --- util.c 10 Aug 2002 03:45:14 -0000 1.1.1.1 +++ util.c 8 Nov 2004 12:55:34 -0000 1.1.1.1.2.1 @@ -1,8 +1,14 @@ /* $Id$ */ -#include <stdio.h> -#include <stdlib.h> -#include <ctype.h> -#include <sys/types.h> + +#if defined(HAVE_CONFIG_H) +# include "config.h" +#endif +#if defined(STDC_HEADERS) +# include <stdio.h> +# include <stdlib.h> +# include <ctype.h> +# include <sys/types.h> +#endif #include "index.h" #include "util.h" Index: view.c =================================================================== RCS file: /cvsroot/meshdb/src/mailt/view.c,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -d -r1.4 -r1.4.2.1 --- view.c 22 Oct 2003 06:24:34 -0000 1.4 +++ view.c 8 Nov 2004 12:55:34 -0000 1.4.2.1 @@ -1,9 +1,25 @@ /* $Id$ */ -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> +#if defined(HAVE_CONFIG_H) +# include "config.h" +#endif +#if defined(STDC_HEADERS) +# include <stdio.h> +# include <unistd.h> +# include <stdlib.h> +# include <string.h> +#endif + +#if TIME_WITH_SYS_TIME +# include <sys/time.h> +# include <time.h> +#else +# if HAVE_SYS_TIME_H +# include <sys/time.h> +# else +# include <time.h> +# endif +#endif + #include "index.h" #include "open.h" #include "util.h" |