Apply after to hypermail-2.1.4 after applying: hypermail-2.1.4-gdbm_option_cleanup.patch hypermail-2.1.4-german_language_improvements.patch Bernhard Reiter (Jul 21 2002) - cleanung up option parsing in hypermail.c a tiny bit - reenabled the "lang" utility program in the src/Makefile.in - ability to write XML Hypermail Archive Overview Files (haof) v0.2 + hypermail.c: added -X + setup.c: setup.h: added set_writehaof + lang.h: added (en+de) MSG_OPTION_XML and MSG_WRITING_HAOF + print.c: new functions writehaof() printhaofitems() print_haof_indices() + file.c: refactored msg_href() using new function msg_relpath() + file.c: new function haofname() + proto.h: prototypes for new functions msg_href() haofname() diff -ur hypermail-2.1.4/patchlevel.h hypermail-2.1.4+/patchlevel.h --- hypermail-2.1.4/patchlevel.h Sun Jul 21 20:24:44 2002 +++ hypermail-2.1.4+/patchlevel.h Sun Jul 21 12:38:50 2002 @@ -1,2 +1,2 @@ -#define VERSION "2.1.4" +#define VERSION "2.1.4+" #define PATCHLEVEL "0" diff -ur hypermail-2.1.4/src/Makefile.in hypermail-2.1.4+/src/Makefile.in --- hypermail-2.1.4/src/Makefile.in Sun Jul 21 20:24:44 2002 +++ hypermail-2.1.4+/src/Makefile.in Sun Jul 21 18:32:34 2002 @@ -56,7 +56,7 @@ .c.o: $(CC) -c $(CFLAGS) $< -all: pcre/libpcre.a hypermail$(SUFFIX) mail$(SUFFIX) +all: pcre/libpcre.a hypermail$(SUFFIX) mail$(SUFFIX) lang$(SUFFIX) pcre/libpcre.a: @cd pcre; $(MAKE) libtool libpcre.a CC="$(CC)" CFLAGS="$(CFLAGS)" @@ -69,8 +69,8 @@ $(CC) -o $@ $(CFLAGS) $(MAILOBJS) $(NETLIBS) chmod 0755 $@ -lang$(SUFFIX): lang.c lang.h - $(CC) -DLANG_PROG $(CFLAGS) -o $@ lang.c +lang$(SUFFIX): trio.o strio.o trionan.o lang.c lang.h + $(CC) -DLANG_PROG $(CFLAGS) -o $@ trio.o strio.o trionan.o lang.c $(LDFLAGS) $(MISC_LIBS) ../libcgi/libcgi.a: @cd ../libcgi; $(MAKE) all CC="$(CC)" CFLAGS="$(CFLAGS)" diff -ur hypermail-2.1.4/src/file.c hypermail-2.1.4+/src/file.c --- hypermail-2.1.4/src/file.c Sun Jul 21 20:24:44 2002 +++ hypermail-2.1.4+/src/file.c Sun Jul 21 19:50:07 2002 @@ -475,16 +475,31 @@ */ char *msg_href(struct emailinfo *to_email, struct emailinfo *from_email) +/* note: you probably have to make a copy of + * the buffer returned before the next call to this function. + */ +{ + static char buffer[MAXFILELEN+11]; + trio_snprintf(buffer,MAXFILELEN+11, "", + msg_relpath(to_email, from_email)); + return buffer; +} + + +char *msg_relpath(struct emailinfo *to_email, struct emailinfo *from_email) +/* called by msg_href() : note: you probably have to make a copy of + * the buffer returned before the next call to this function. + */ { static char buffer[MAXFILELEN]; if (!from_email && to_email->subdir) - trio_snprintf(buffer, MAXFILELEN, "", + trio_snprintf(buffer, MAXFILELEN, "%s%.4d.%s", to_email->subdir->subdir, to_email->msgnum, set_htmlsuffix); else if(!to_email->subdir || to_email->subdir == from_email->subdir) - trio_snprintf(buffer, MAXFILELEN, "", + trio_snprintf(buffer, MAXFILELEN, "%.4d.%s", to_email->msgnum, set_htmlsuffix); else - trio_snprintf(buffer, MAXFILELEN, "", + trio_snprintf(buffer, MAXFILELEN, "%s%s%.4d.%s", to_email->subdir->rel_path_to_top, to_email->subdir->subdir, to_email->msgnum, set_htmlsuffix); return buffer; @@ -507,6 +522,17 @@ file, *suffix ? "." : "", suffix); return buf; } + +char *haofname(struct emailinfo *email) +{ + char *buf; + trio_asprintf(&buf,"%s%s", + email && email->subdir ? email->subdir->full_path : set_dir, + HAOF_NAME); + return buf; + +} + /* matches_existing returns 0 if it finds a file with the same msgnum as argument eptr but different contents. A return value of 1 does not diff -ur hypermail-2.1.4/src/hypermail.c hypermail-2.1.4+/src/hypermail.c --- hypermail-2.1.4/src/hypermail.c Sun Jul 21 20:25:10 2002 +++ hypermail-2.1.4+/src/hypermail.c Sun Jul 21 18:58:40 2002 @@ -149,6 +149,7 @@ printf(" -v : %s\n", lang[MSG_OPTION_VERBOSE]); printf(" -V : %s\n", lang[MSG_OPTION_VERSION]); printf(" -x : %s\n", lang[MSG_OPTION_X]); + printf(" -X : %s\n", lang[MSG_OPTION_XML]); printf(" -1 : %s\n", lang[MSG_OPTION_1]); printf(" -L lang : %s (", lang[MSG_OPTION_LANG]); @@ -193,10 +194,10 @@ opterr = 0; +#define GETOPT_OPTSTRING ("a:Ab:c:d:gil:L:m:n:o:ps:tTuvVxX0:1M?") + /* get pre config options here */ - while ((i = getopt(argc,argv, - "a:Ab:c:d:gil:L:m:n:o:ps:tTuvVx0:1M?" - )) != -1) { + while ((i = getopt(argc,argv, GETOPT_OPTSTRING )) != -1) { switch((char) i) { case 'c': configfile = strreplace(configfile, optarg); @@ -206,7 +207,8 @@ break; case 'V': version(); - /*NOTREACHED*/ case 'a': + /*NOTREACHED*/ + case 'a': case 'A': case 'b': case 'd': @@ -223,6 +225,7 @@ case 'T': case 'u': case 'x': + case 'X': case '0': case '1': case 'M': @@ -250,9 +253,7 @@ /* now get the post-config options! */ - while ((i = getopt(argc,argv, - "a:Ab:c:d:gil:L:m:n:o:ps:tTuvx0:1M?" - )) != -1) { + while ((i = getopt(argc,argv, GETOPT_OPTSTRING)) != -1) { switch((char) i) { case 'A': set_append = 1; @@ -311,6 +312,9 @@ case 'x': set_overwrite = TRUE; break; + case 'X': + set_writehaof=0; + break; case '0': set_delete_msgnum = add_list(set_delete_msgnum, optarg); break; @@ -365,8 +369,6 @@ lang = tlang; /* A good language, make it so. */ - - if (print_usage) /* Print the usage message and terminate */ usage(); @@ -617,6 +619,8 @@ if (set_attachmentsindex) { writeattachments(amount_new, NULL); } + if (set_writehaof) + writehaof(amount_new,NULL); if (set_folder_by_date || set_msgsperfolder) write_toplevel_indices(amount_new); if (set_monthly_index || set_yearly_index) diff -ur hypermail-2.1.4/src/hypermail.h hypermail-2.1.4+/src/hypermail.h --- hypermail-2.1.4/src/hypermail.h Sun Jul 21 20:25:10 2002 +++ hypermail-2.1.4+/src/hypermail.h Sun Jul 21 16:23:01 2002 @@ -105,6 +105,13 @@ #define GDBM_INDEX_NAME ".hm2index" +/* Name of the Hypertext Archive Overview File an XML file + * which contains pointers to the various index files + * and some header information about each mail + * to allow further processing + */ +#define HAOF_NAME "archive_overview.haof" + #define NUMSTRLEN 10 #define MAXLINE 1024 #define MAXFILELEN 256 diff -ur hypermail-2.1.4/src/lang.h hypermail-2.1.4+/src/lang.h --- hypermail-2.1.4/src/lang.h Sun Jul 21 20:25:15 2002 +++ hypermail-2.1.4+/src/lang.h Sun Jul 21 19:54:25 2002 @@ -175,6 +175,9 @@ #define MSG_FILTERED_OUT 118 #define MSG_FROM 119 +#define MSG_OPTION_XML 120 +#define MSG_WRITING_HAOF 121 + #ifdef MAIN_FILE /* @@ -317,8 +320,10 @@ "(gelöschte Nachricht)", /* MSG_DEL_SHORT -HTML */ "Ursprünglicher Text dieser Nachricht", /* MSG_TXT_VERSION -HTML */ "Diese Nachricht wurde herausgefiltert", /* MSG_FILTERED_OUT -HTML */ - "Autor", /* MSG_FROM -HTML*/ - NULL, /* End Of Message Table - NOWHERE*/ + "Autor", /* MSG_FROM -HTML*/ + "Erstelle haof XML Dateien", /* Write hoaf XML files -STDOUT */ + "Schreibe Hoaf in", /* Writing haof to -HTML*/ + NULL, /* End Of Message Table - NOWHERE*/ }; /* @@ -448,6 +453,8 @@ "Tekst tej zawarto¶ci", /* MSG_TXT_VERSION -HTML */ "Ta wiadomo¶æ zosta³a odfiltrowana", /* MSG_FILTERED_OUT -HTML */ "Autor", /* MSG_FROM -HTML*/ + "Write haof XML files", /* Write hoaf XML files -STDOUT */ + "Writing haof to", /* Writing haof to -HTML*/ NULL, /* End Of Message Table - NOWHERE*/ }; @@ -578,8 +585,10 @@ "(deleted message)", /* MSG_DEL_SHORT -HTML */ "Original text of this message", /* MSG_TXT_VERSION -HTML */ "This message has been filtered out", /* MSG_FILTERED_OUT -HTML */ - "From", /* MSG_FROM -HTML*/ - NULL, /* End Of Message Table - NOWHERE*/ + "From", /* MSG_FROM -HTML*/ + "Write haof XML files", /* Write hoaf XML files -STDOUT */ + "Writing haof to", /* Writing haof to -HTML*/ + NULL, /* End Of Message Table - NOWHERE*/ }; /* @@ -718,6 +727,8 @@ "Original text of this message", /* MSG_TXT_VERSION -HTML */ "This message has been filtered out", /* MSG_FILTERED_OUT -HTML */ "Autor", /* MSG_FROM - HTML*/ + "Write haof XML files", /* Write hoaf XML files -STDOUT */ + "Writing haof to", /* Writing haof to -HTML*/ NULL, /* End Of Message Table */ }; @@ -847,6 +858,8 @@ "Original text of this message", /* MSG_TXT_VERSION -HTML */ "This message has been filtered out", /* MSG_FILTERED_OUT -HTML */ "Kirjoittajan mukaan", /* MSG_FROM -HTML*/ + "Write haof XML files", /* Write hoaf XML files -STDOUT */ + "Writing haof to", /* Writing haof to -HTML*/ NULL, /* End Of Message Table - NOWHERE*/ }; @@ -978,6 +991,8 @@ "Texte original de ce message", /* MSG_TXT_VERSION -HTML */ "Ce message a été supprimé par filtrage", /* MSG_FILTERED_OUT -HTML */ "Auteur", /* MSG_FROM -HTML*/ + "Write haof XML files", /* Write hoaf XML files -STDOUT */ + "Writing haof to", /* Writing haof to -HTML*/ NULL, /* End Of Message Table - NOWHERE*/ }; @@ -1109,6 +1124,8 @@ "Original text of this message", /* MSG_TXT_VERSION -HTML */ "This message has been filtered out", /* MSG_FILTERED_OUT -HTML */ "Höfundur", /* MSG_FROM -HTML*/ + "Write haof XML files", /* Write hoaf XML files -STDOUT */ + "Writing haof to", /* Writing haof to -HTML*/ NULL, /* End Of Message Table - NOWHERE*/ }; @@ -1245,6 +1262,8 @@ "Ursprunglig brevtext", /* MSG_TXT_VERSION -HTML */ "This message has been filtered out", /* MSG_FILTERED_OUT -HTML */ "Författare", /* MSG_FROM -HTML*/ + "Write haof XML files", /* Write hoaf XML files -STDOUT */ + "Writing haof to", /* Writing haof to -HTML*/ NULL, /* End Of Message Table - NOWHERE*/ }; diff -ur hypermail-2.1.4/src/print.c hypermail-2.1.4+/src/print.c --- hypermail-2.1.4/src/print.c Sun Jul 21 21:15:03 2002 +++ hypermail-2.1.4+/src/print.c Sun Jul 21 21:13:20 2002 @@ -537,6 +537,37 @@ #endif } +/*----------------------------------------------------------------------------*/ + +void print_haof_indices(FILE *fp, struct emailsubdir *subdir) +{ + int dlev = (subdir != NULL); + + fprintf(fp, " \n"); + + if (show_index[dlev][DATE_INDEX]) + fprintf(fp," %s\n", + index_name[dlev][DATE_INDEX]); + + if (show_index[dlev][AUTHOR_INDEX]) + fprintf(fp," %s\n", + index_name[dlev][AUTHOR_INDEX]); + + if (show_index[dlev][THREAD_INDEX]) + fprintf(fp," %s\n", + index_name[dlev][THREAD_INDEX]); + + if (show_index[dlev][SUBJECT_INDEX]) + fprintf(fp," %s\n", + index_name[dlev][AUTHOR_INDEX]); + + if (show_index[dlev][ATTACHMENT_INDEX]) + fprintf(fp," %s\n", + index_name[dlev][ATTACHMENT_INDEX]); + + fprintf(fp, " \n\n"); +} + /* ** Prints a comment in the file. */ @@ -2352,6 +2383,106 @@ putchar('\n'); } +/* +** Pretty-prints the items for the haof +*/ +void printhaofitems(FILE *fp, struct header *hp, int year, int month, + struct emailinfo *subdir_email) +{ + char *subj, *from_name, *from_emailaddr; + + if (hp != NULL) { + struct emailinfo *em=hp->data; + printhaofitems(fp, hp->left, year, month, subdir_email); + if ((year == -1 || year_of_datenum(em->date) == year) + && (month == -1 || month_of_datenum(em->date) == month) + && !em->is_deleted + && (!subdir_email || subdir_email->subdir == em->subdir)) { + + subj = convchars(em->subject); + from_name = convchars(em->name); + from_emailaddr = convchars(em->emailaddr); + + fprintf(fp, + " \n" + " %s\n" + " %s\n" + " %s\n" + " %s\n" + " %s\n" + " \"%s\"\n" + " \n\n" + ,subj, getdatestr(em->date), from_name, from_emailaddr, em->msgid, + msg_relpath(em,subdir_email)); + + free(subj); + free(from_name); + free(from_emailaddr); + } + printhaofitems(fp, hp->right, year, month, subdir_email); + } +} + +/* +** Write the XML based hypermail archive overview file +*/ + +void writehaof(int amountmsgs, struct emailinfo *email) +{ + int newfile; + char *filename; + FILE *fp; + char *authname = index_name[email && email->subdir != NULL][AUTHOR_INDEX]; + + filename = haofname(email); + + if (isfile(filename)) + newfile = 0; + else + newfile = 1; + + if ((fp = fopen(filename, "w")) == NULL) { + sprintf(errmsg, "%s \"%s\".", lang[MSG_COULD_NOT_WRITE], filename); + progerr(errmsg); + } + + if (set_showprogress) + printf("%s \"%s\"...", lang[MSG_WRITING_HAOF], filename); + + fprintf(fp,"\n\n"); + fprintf(fp," \n\n" + ); + fprintf(fp," \n\n"); + fprintf(fp," \n\n"); + + print_haof_indices(fp, email ? email->subdir : NULL); + + + fprintf(fp," \n"); + printhaofitems(fp, datelist, -1, -1, email); + fprintf(fp," \n"); + + fprintf(fp," \n"); + + fclose(fp); + + if (newfile && chmod(filename, set_filemode) == -1) { + sprintf(errmsg, "%s \"%s\": %o.", + lang[MSG_CANNOT_CHMOD], filename, set_filemode); + progerr(errmsg); + } + free(filename); + + if (set_showprogress) + putchar('\n'); +} + + + + static int count_messages(struct header *hp, int year, int mo, long *first_date, long *last_date) { @@ -2611,6 +2742,8 @@ writeattachments(sd->count, sd->first_email); break; } + if (set_writehaof) + writehaof(sd->count, sd->first_email); if (!fp) continue; if (!sd->count) { diff -ur hypermail-2.1.4/src/proto.h hypermail-2.1.4+/src/proto.h --- hypermail-2.1.4/src/proto.h Sun Jul 21 20:24:44 2002 +++ hypermail-2.1.4+/src/proto.h Sun Jul 21 19:41:53 2002 @@ -43,8 +43,10 @@ void symlink_latest(void); struct emailsubdir *msg_subdir(int, time_t); char *msg_href(struct emailinfo *, struct emailinfo *); +char *msg_relpath(struct emailinfo *, struct emailinfo *); char *articlehtmlfilename(struct emailinfo *); char *htmlfilename(const char *, struct emailinfo *, const char *); +char *haofname(struct emailinfo *); int matches_existing(int); /* diff -ur hypermail-2.1.4/src/setup.c hypermail-2.1.4+/src/setup.c --- hypermail-2.1.4/src/setup.c Sun Jul 21 20:25:10 2002 +++ hypermail-2.1.4+/src/setup.c Sun Jul 21 18:59:14 2002 @@ -49,6 +49,7 @@ bool set_spamprotect; bool set_attachmentsindex; bool set_usegdbm; +bool set_writehaof; bool set_append; char *set_append_filename; bool set_warn_surpressions; @@ -306,6 +307,10 @@ #endif }, + {"writehaof", &set_writehaof, BFALSE, CFG_SWITCH, + "# Set this to On to let hypermail write an XML archive overview file\n" + "# in each directory. The filename is " HAOF_NAME ".\n"}, + {"append", &set_append, BFALSE, CFG_SWITCH, "# Set this to On to maintain a parallel mbox archive. The file\n" "#name defaults to mbox in the directory specified by -d or dir.\n"}, @@ -1033,6 +1038,7 @@ printf("set_locktime = %d\n",set_locktime); printf("set_ietf_mbox = %d\n",set_ietf_mbox); printf("set_usegdbm = %d\n",set_usegdbm); + printf("set_writehaof = %d\n",set_writehaof); printf("set_append = %d\n",set_append); printf("set_thrdlevels = %d\n",set_thrdlevels); printf("set_dirmode = %04o\n",set_dirmode); diff -ur hypermail-2.1.4/src/setup.h hypermail-2.1.4+/src/setup.h --- hypermail-2.1.4/src/setup.h Sun Jul 21 20:25:10 2002 +++ hypermail-2.1.4+/src/setup.h Sun Jul 21 17:58:02 2002 @@ -74,6 +74,7 @@ extern bool set_spamprotect; extern bool set_attachmentsindex; extern bool set_usegdbm; +extern bool set_writehaof; extern bool set_append; extern char *set_append_filename; extern bool set_warn_surpressions;