[Mixmaster-devel] r852 - in trunk/Mix: . Src win32
Brought to you by:
weaselp
|
From: <we...@so...> - 2004-05-13 13:59:34
|
Author: weasel
Date: 2004-05-13 15:59:28 +0200 (Thu, 13 May 2004)
New Revision: 852
Modified:
trunk/Mix/HISTORY
trunk/Mix/Src/Makefile.in
trunk/Mix/Src/config.h
trunk/Mix/Src/main.c
trunk/Mix/Src/menu.c
trunk/Mix/Src/menu.h
trunk/Mix/Src/menustats.c
trunk/Mix/Src/mix.c
trunk/Mix/Src/mix.h
trunk/Mix/Src/mix3.h
trunk/Mix/Src/pgpdb.c
trunk/Mix/TODO
trunk/Mix/mixmaster.1
trunk/Mix/win32/mixlib.vcproj
Log:
Merge stats stuff from branch into trunk
Modified: trunk/Mix/HISTORY
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/HISTORY 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/HISTORY 2004-05-13 13:59:28 UTC (rev 852)
@@ -474,3 +474,6 @@
Added stats downloading support. Currently=20
works under Win32 only (by goblin).
Fixed bug in buffers.c.
+
+2004-????? 3.0???
+ Prefer pubring.asc over secring.pgp.
Modified: trunk/Mix/Src/Makefile.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/Src/Makefile.in 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/Src/Makefile.in 2004-05-13 13:59:28 UTC (rev 852)
@@ -25,7 +25,7 @@
=20
OBJ =3D mix.o rem.o rem1.o rem2.o chain.o chain1.o chain2.o nym.o pgp.o =
pgpdb.o pgpdata.o pgpget.o pgpcreat.o pool.o mail.o rfc822.o mime.o keymg=
t.o compress.o stats.o crypto.o random.o util.o buffers.o maildir.o parse=
date.tab.o
=20
-MIXOBJ =3D rndseed.o menu.o menusend.o menunym.o menuutil.o
+MIXOBJ =3D rndseed.o menu.o menusend.o menunym.o menuutil.o menustats.o
NOMENUOBJ =3D rndseed.o dummy.o
WINOBJ =3D winmain.o winutil.o
=20
Modified: trunk/Mix/Src/config.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/Src/config.h 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/Src/config.h 2004-05-13 13:59:28 UTC (rev 852)
@@ -243,6 +243,10 @@
#define DEFAULT_NYMSECRING "nymsec.pgp"
#define DEFAULT_NYMDB "secrets.mix"
#define DEFAULT_STAREX "starex.txt"
+#define DEFAULT_ALLPINGERSURL "http://www.noreply.org/allpingers/allping=
ers.txt"
+#define DEFAULT_ALLPINGERSFILE "allpingers.txt"
+#define DEFAULT_WGET "wget"
+#define DEFAULT_STATSSRC "stats-src.txt"
=20
DLLIMPORT extern char MIXCONF[];
extern char DISCLAIMFILE[];
@@ -391,7 +395,12 @@
extern long TIMESKEW_FORWARD;
extern long TIMESKEW_BACK;
extern int TEMP_FAIL;
+extern char ALLPINGERSURL[];
+extern char ALLPINGERSFILE[];
=20
+extern char WGET[];
+extern char STATSSRC[];
+
DLLIMPORT extern char ENTEREDPASSPHRASE[LINELEN];
=20
#endif
Modified: trunk/Mix/Src/main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/Src/main.c 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/Src/main.c 2004-05-13 13:59:28 UTC (rev 852)
@@ -40,9 +40,10 @@
#endif /* WIN32SERVICE */
{
int error =3D 0, deflt =3D 1, help =3D 0, readmail =3D 0, send =3D -1,=
sendpool =3D 0,
- header =3D 1, maint =3D 0, keygen =3D 0, verbose =3D 2, sign =3D 0, en=
crypt =3D 0,
+ header =3D 1, maint =3D 0, keygen =3D 0, verbose =3D 0, sign =3D 0, en=
crypt =3D 0,
redirect_mail =3D 0, about=3D0, version=3D0;
int daemon =3D 0, type_list =3D 0, nodetach =3D 0;
+ int update_stats =3D 0, update_pingerlist =3D 0;
=20
#ifdef USE_SOCK
int pop3 =3D 0;
@@ -54,10 +55,11 @@
char *p, *q;
char chain[1024] =3D "";
char nym[LINELEN] =3D "";
- BUFFER *nymopt, *pseudonym, *attachments;
+ BUFFER *nymopt, *pseudonym, *attachments, *statssrc;
int numcopies =3D 0; /* default value set in mix.cfg */
BUFFER *msg, *chainlist, *field, *content;
FILE *f;
+ char pingpath[PATHMAX];
=20
/* Check if parse_yearmonthday works */
assert(parse_yearmonthday("2003-04-01") =3D=3D 1049155200);
@@ -71,6 +73,7 @@
attachments =3D buf_new();
field =3D buf_new();
content =3D buf_new();
+ statssrc =3D buf_new();
=20
#ifdef USE_NCURSES
if (argc =3D=3D 1) {
@@ -82,8 +85,7 @@
}
#endif /* USE_NCURSES */
if (argc > 1 && strleft(argv[1], "-f")) {
- menu_folder(strlen(argv[1]) > 2 ? argv[1][2] : 0,
- argc < 3 ? NULL : argv[2]);
+ menu_folder(strlen(argv[1]) > 2 ? argv[1][2] : 0, argc < 3 ? NULL : =
argv[2]);
goto clientpool;
}
for (i =3D 1; i < argc; i++) {
@@ -93,10 +95,10 @@
p +=3D 2;
if (strieq(p, "help"))
help =3D 1, deflt =3D 0;
- else if (streq(p, "version"))
- version =3D 1, deflt =3D 0;
- else if (streq(p, "about"))
- about =3D 1, deflt =3D 0;
+ else if (streq(p, "version"))
+ version =3D 1, deflt =3D 0;
+ else if (streq(p, "about"))
+ about =3D 1, deflt =3D 0;
else if (streq(p, "verbose"))
verbose =3D 1;
else if (streq(p, "type-list"))
@@ -133,7 +135,30 @@
sign =3D 1;
else if (streq(p, "encrypt"))
encrypt =3D 1;
- else if ((q =3D largopt(p, "to", argv[0], &error)) !=3D NULL) {
+ else if (streq(p, "update-pinger-list"))
+ update_pingerlist =3D 1;
+ else if (streq(p, "update-stats")) {
+ buf_clear(statssrc);
+ f =3D mix_openfile(STATSSRC, "r");
+ if (f !=3D NULL) {
+ buf_read(statssrc, f);
+ fclose(f);
+ }
+ if (statssrc->length > 0) {
+ update_stats =3D 1;
+ } else {
+ deflt =3D 0;
+ fprintf(stderr, "%s: No current stats source --%s\n", argv[0], p);
+ }
+ } else if (strleft(p, "update-stats") && p[strlen("update-stats")] =3D=3D=
'=3D') {
+ buf_clear(statssrc);
+ buf_appendf(statssrc, "%s", (p + strlen("update-stats") + 1));
+ if (statssrc->length > 0) {
+ update_stats =3D 1;
+ } else {
+ fprintf(stderr, "%s: No stats source specified --%s\n", argv[0], p)=
;
+ }
+ } else if ((q =3D largopt(p, "to", argv[0], &error)) !=3D NULL) {
header =3D 0;
buf_appendf(msg, "To: %s\n", q);
} else if ((q =3D largopt(p, "post-to", argv[0], &error)) !=3D NULL) {
@@ -219,9 +244,9 @@
case 'T':
type_list =3D 1;
break;
- case 'V':
- version =3D 1, deflt =3D 0;
- break;
+ case 'V':
+ version =3D 1, deflt =3D 0;
+ break;
case 't':
if (*(p + 1) =3D=3D 'o')
p++;
@@ -229,8 +254,7 @@
if (i < argc - 1)
buf_appendf(msg, "To: %s\n", argv[++i]);
else {
- fprintf(stderr, "%s: Missing argument for option -to\n",
- argv[0]);
+ fprintf(stderr, "%s: Missing argument for option -to\n", argv[0])=
;
error =3D 1;
}
break;
@@ -339,9 +363,45 @@
}
if (version) {
printf("Mixmaster %s\n", VERSION);
- ret =3D 0; =20
+ ret =3D 0;
goto end;
}
+ if (update_pingerlist) {
+ mixfile(pingpath, ALLPINGERSFILE);
+ if (verbose) printf ("downloading %s...\n", ALLPINGERSURL);
+ if (url_download(ALLPINGERSURL, pingpath) < 0) {
+ printf(" Download failed... Try again later.\n");
+ errlog(ERRORMSG, "All Pingers File Download failed.\n");
+ } else {
+ if (verbose) printf(" Done.\n");
+ errlog(LOG, "All Pingers File Downloaded OK.\n");
+ }
+ ret =3D 0;
+ goto end;
+ }
+ if (update_stats) {
+ BUFFER *inifile;
+ inifile =3D buf_new();
+ read_allpingers(inifile);
+ if (good_stats_source(inifile, statssrc->data) =3D=3D 1) {
+ if (stats_download(inifile, statssrc->data, 0) =3D=3D 0) {
+ f =3D mix_openfile(STATSSRC, "w+");
+ if (f !=3D NULL) {
+ fprintf(f, "%s", statssrc->data);
+ fclose(f);
+ } else {
+ fprintf(stderr, "Could not open stats source file for writing\n");
+ errlog(ERRORMSG, "Could not open stats source file for writing.\n");
+ }
+ }
+ } else {
+ fprintf(stderr, "Stats source does not include all required files.=
\n");
+ errlog(ERRORMSG, "Stats source does not include all required files=
.\n");
+ }
+ ret =3D 0;
+ buf_free(inifile);
+ goto end;
+ }
if (help ||about ||(isatty(fileno(stdin)) && isatty(fileno(stdout))))
fprintf(stderr, "Mixmaster %s\n", VERSION);
if (help ||about)
@@ -357,7 +417,7 @@
printf("\nand others. For full information on copyright and license =
issues,\n");
printf("read the bundled file COPYRIGHT.\n\n");
ret =3D 0;
- goto end; =20
+ goto end;
}
if (help) {
printf("Usage: %s [options] [user@host] [filename]\n\n", argv[0]);
@@ -393,7 +453,10 @@
#endif /* NYMSUPPORT */
#endif /* USE_PGP */
"-v, --verbose output informational messages\n\
--f [file] read a mail folder\n"
+-f [file] read a mail folder\n\
+ --update-pinger-list Download an updated all pingers list f=
ile\n\
+ --update-stats[=3Dsource] Download updated stats\n"
+
#ifndef USE_NCURSES
"\n-fr, -ff, -fg [file] send reply/followup/group reply=
to a message\n"
#endif /* USE_NCURSES */
@@ -568,12 +631,12 @@
if (mix_encrypt(MSG_NULL, NULL, chain, numcopies, chainlist) =3D=3D =
-1) {
ret =3D 2;
if (chainlist->length)
- fprintf(stderr, "%s\n", chainlist->data);
+ printf("%s\n", chainlist->data);
else
fprintf(stderr, "Failed!\n");
} else if (verbose) {
- fprintf(stderr, "Chain: ");
- buf_write(chainlist, stderr);
+ printf("Chain: ");
+ buf_write(chainlist, stdout);
}
}
#ifdef USE_PGP
@@ -640,6 +703,7 @@
buf_free(nymopt);
buf_free(pseudonym);
buf_free(attachments);
+ buf_free(statssrc);
=20
if (daemon) {
check_get_pass(1);
@@ -679,7 +743,7 @@
#endif /* UNIX */
mix_daemon();
#ifdef UNIX
-/* ifdef this one to, so that we do not need to export it from windows d=
ll */
+/* ifdef this one too, so that we do not need to export it from windows =
dll */
clear_pidfile(PIDFILE);
#endif /* UNIX */
}
Modified: trunk/Mix/Src/menu.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/Src/menu.c 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/Src/menu.c 2004-05-13 13:59:28 UTC (rev 852)
@@ -509,9 +509,7 @@
mvprintw(y++, x, "d)ummy message");
mvprintw(y++, x, "s)end messages from pool");
mvprintw(y++, x, "e)dit configuration file");
-#ifdef WIN32
mvprintw(y++, x, "u)pdate stats");
-#endif /* WIN32 */
mvprintw(y++, x, "q)uit");
=20
pool =3D pool_read(NULL);
@@ -587,11 +585,9 @@
mix_config();
} while (0);
break;
-#ifdef WIN32
case 'u':
update_stats();
break;
-#endif /* WIN32 */
case 'q':
case 'Q':
goto quit;
Modified: trunk/Mix/Src/menu.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/Src/menu.h 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/Src/menu.h 2004-05-13 13:59:28 UTC (rev 852)
@@ -39,9 +39,7 @@
void savemsg(BUFFER *message);
int menu_replychain(int *d, int *l, char *mdest, char *pdest, char *psub=
,
char *r);
-#ifdef WIN32
void update_stats(void);
-#endif /* WIN32 */
=20
#endif /* USE_NCURSES */
=20
Modified: trunk/Mix/Src/menustats.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/Src/menustats.c 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/Src/menustats.c 2004-05-13 13:59:28 UTC (rev 852)
@@ -1,117 +1,325 @@
-#ifdef _WIN32
+/* Mixmaster version 3.0 -- (C) 1999 - 2004 Anonymizer Inc. and others=
.
+
+ Mixmaster may be redistributed and modified under certain conditions.
+ This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ ANY KIND, either express or implied. See the file COPYRIGHT for
+ details.
+
+ Menu-based user interface
+ $Id$ */
+
+
+#if 0
+void errlog(int type, char *format, ...) { };
+char MIXDIR[512];
+#include "util.c"
+#include "buffers.c"
+int menu_getuserpass(BUFFER *p, int mode) { return 0; };
+#define ALLPINGERSFILE "allpingers.txt"
+#endif
+
+#include <string.h>
+#include <assert.h>
+#include <stdlib.h>
+
#include "menu.h"
+#ifdef WIN32
#include <urlmon.h>
-#define ALLPINGERS "allpingers.txt"
-#define URL "http://www.noreply.org/allpingers/allpingers.txt"
#pragma comment(lib,"urlmon.lib")
+#else
+#include <sys/wait.h>
+#endif /* WIN32 */
=20
-static const char *files[]=3D{"mlist","rlist","mixring","pgpring","type2=
list"};
+
+int url_download(char *url, char *dest) {
+ int err;
+#ifdef WIN32
+ err =3D URLDownloadToFile(NULL, url, dest, BINDF_GETNEWESTVERSION, NULL=
);
+
+ if (err !=3D S_OK)
+ return -1;
+ else
+ return 0;
+#else
+ char s[PATHMAX];
+ snprintf(s, PATHMAX, "%s -q %s -O %s", WGET, url, dest);
+ err =3D system(s);
+
+ if (err !=3D -1) {
+ if (WIFEXITED(err) =3D=3D 0)
+ return -1; /* abnormal child exit */
+ else
+ return 0;
+ }
+ else
+ return -1;
+#endif /* WIN32 */
+}
+
+/** read the allpingers file into the buffer */
+void read_allpingers(BUFFER *allpingers) {
+ FILE *f;
+
+ f =3D mix_openfile(ALLPINGERSFILE, "r");
+ if (f !=3D NULL) {
+ buf_clear(allpingers);
+ buf_read(allpingers, f);
+ fclose(f);
+ }
+}
+
+/* Get all sections from inifile.
+ *
+ * They are put into the sections buffer, separated by newlines
+ */
+void get_sections(BUFFER *inifile, BUFFER *sections) {
+ BUFFER *line;
+ int err;
+
+ line =3D buf_new();
+
+ buf_rewind(inifile);
+ buf_reset(sections);
+
+ while ((err =3D buf_getline(inifile, line)) !=3D -1) {
+ if (bufileft (line, "[") &&
+ bufiright(line, "]")) {
+ line->data[line->length-1] =3D '\0';
+ buf_appends(sections, line->data+1);
+ buf_nl(sections);
+ };
+ }
+ buf_free (line);
+}
+
+/* Get value of an attribute
+ *
+ * returns -1 if it isn't found.
+ */
+int get_attribute(BUFFER *inifile, char *section, char *attribute, BUFFE=
R *value) {
+ BUFFER *line;
+ int err =3D -1;
+ int insection =3D 0;
+
+ line =3D buf_new();
+
+ buf_rewind(inifile);
+ buf_reset(value);
+
+ while (buf_getline(inifile, line) !=3D -1) {
+ if (bufileft (line, "[") &&
+ bufiright(line, "]")) {
+ if (insection)
+ break;
+
+ line->data[line->length-1] =3D '\0';
+ if (strcasecmp(section, line->data+1) =3D=3D 0) {
+ insection =3D 1;
+ }
+ } else if (insection && bufileft(line, attribute)) {
+ /* we are in the right section and this attribute name
+ * at least starts with what we want */
+ char *ptr =3D line->data + strlen(attribute);
+ /* eat up whitespace */
+ while ((*ptr =3D=3D ' ') || (*ptr =3D=3D '\t'))
+ ptr++;
+ if (*ptr !=3D '=3D')
+ continue;
+ ptr++;
+ while ((*ptr =3D=3D ' ') || (*ptr =3D=3D '\t'))
+ ptr++;
+ buf_appends(value, ptr);
+ err =3D 0;
+ break;
+ }
+ }
+ buf_free (line);
+ return (err);
+}
+
+
+
+
+
+static char *files[] =3D { "mlist", "rlist", "mixring", "pgpring", "type=
2list"};
#define NUMFILES sizeof(files)/sizeof(*files)
=20
/* Download all the needed files from the specified source */
-static BOOL download(char *source, char *allpingers) {
- const char *localfiles[]=3D{"mlist.txt","rlist.txt","pubring.mix","pgpr=
ing.asc","type2.list"};
- char buffer[1024],path[PATHMAX];
- int i,ret =3D TRUE;
+/* returns -1 on error */
+int stats_download(BUFFER *allpingers, char *sourcename, int curses) {
+ char *localfiles[] =3D { TYPE2REL, TYPE1LIST, PUBRING, PGPREMPUBASC, TY=
PE2LIST };
+ char path[PATHMAX];
+ BUFFER *value;
+ int ret =3D 0;
+ int err;
+ int i;
+
+ value =3D buf_new();
+
+ if (curses) {
+ clear();
+ }
+
+ err =3D get_attribute(allpingers, sourcename, "base", value);
+ if (err =3D=3D 0) {
+ if (curses) {
+ standout();
+ printw("%s", value->data);
+ standend();
+ }
+ else
+ printf("%s\n\r", value->data);
+ }
=09
- clear();
- standout();
- GetPrivateProfileString(source,"base","",buffer,sizeof(buffer),allpinge=
rs);
- if (buffer[0]!=3D'\0')
- printw("%s",buffer);
- standend();
-=09
- for (i =3D 0;i < NUMFILES;i++) {
- GetPrivateProfileString(source,files[i],"",buffer,sizeof(buffer),allpi=
ngers);
- if (buffer[0]=3D=3D'\0')
+ for (i=3D0; i<NUMFILES; i++) {
+ err =3D get_attribute(allpingers, sourcename, files[i], value);
+ if (err < 0) {
+ /* the attribute vanished under us */
+ ret =3D -1;
break;
+ }
mixfile(path, localfiles[i]);
- mvprintw(i+3,0,"downloading %s...",localfiles[i]);
- refresh();
- if (URLDownloadToFile(NULL,buffer,path,BINDF_GETNEWESTVERSION,NULL) !=3D=
S_OK) {
- printw("failed to download.\n\rTry using another stats source.");
- ret =3D FALSE;
+ if (curses) {
+ mvprintw(i+3, 0, "downloading %s from %s...", localfiles[i], value->d=
ata);
+ refresh();
+ }
+ else
+ printf("downloading %s from %s...", localfiles[i], value->data);
+ err =3D url_download(value->data, path);
+ if (err < 0) {
+ if (curses)
+ printw("failed to download.\n\rTry using another stats source.");
+ else
+ printf("failed to download.\n\rTry using another stats source.\n\r")=
;
+ ret =3D -1;
break;
}
- printw("done");
+ if (curses)
+ printw("done");
+ else
+ printf("done\n\r");
}
-=09
- printw("\n\n\rPress any key to continue");
- getch();
- clear();
+
+ if (curses) {=09
+ printw("\n\n\n\n\rPress any key to continue");
+ getch();
+ clear();
+ }
+ buf_free(value);
return ret;
}
-/* Checks whether the stats source has all the required files */
-static BOOL good_source(char *source,char *allpingers) {
- char buffer[1024],*ptr;
+/* Checks whether the stats source has all the required files.
+ *
+ * 1 if it has,
+ * 0 otherwise
+ */
+int good_stats_source (BUFFER *allpingers, char *sourcename) {
+ BUFFER *value;
int i;
-=09
- GetPrivateProfileString(source,NULL,"",buffer,sizeof(buffer),allpingers=
);
-=09
- for (i =3D 0;i < NUMFILES;i++) {
- ptr =3D buffer;
- while (*ptr !=3D '\0') {
- if (!strcmp(ptr,files[i]))
- break;
- ptr+=3Dstrlen(ptr)+1;
+ int res =3D 1;
+ int err;
+
+ value =3D buf_new();
+
+ for (i =3D 0; i < NUMFILES; i++) {
+ err =3D get_attribute(allpingers, sourcename, files[i], value);
+ if (err < 0) {
+ res =3D 0;
+ break;
}
- if (*ptr =3D=3D '\0')
- return FALSE;
}
-=09
- return TRUE;
+
+ buf_free (value);
+ return (res);
}
/* Download allpingers.txt */
-static BOOL download_list(char *allpingers) {
+/* -1 on error */
+static int download_list() {
+ char path[PATHMAX];
+
+ mixfile(path, ALLPINGERSFILE);
+
clear();
standout();
- printw(URL);
+ printw(ALLPINGERSURL);
standend();
=09
- mvprintw(3,0,"downloading %s...", ALLPINGERS);
+ mvprintw(3,0,"downloading %s...", ALLPINGERSURL);
refresh();
- if (URLDownloadToFile(NULL,URL,allpingers,BINDF_GETNEWESTVERSION,NULL) =
!=3D S_OK) {
+ if (url_download(ALLPINGERSURL, path) < 0) {
printw("failed to download.\n\rTry again later.");
printw("\n\n\rPress any key to continue");
getch();
- return FALSE;
+ return -1;
}
- return TRUE;
+ return 0;
}
+
/* Displays the choice of stats sources */
-void update_stats(void) {
- char buffer[1024],*ptr,*stats[MAXREM];
- int i=3D0,x,y,num=3D0;
- char path[PATHMAX],c;
- mixfile(path, ALLPINGERS);
-=09
+#define MAXPING (26 * 2)
+void update_stats() {
+ char c;
+ BUFFER *inifile;
+ BUFFER *pingernames;
+ BUFFER *goodpingers;
+ BUFFER *line;
+ BUFFER *statssrc;
+ FILE *f;
+ int num;
+ int err;
+ int x, y;
+ int i;
+
+ inifile =3D buf_new();
+ pingernames =3D buf_new();
+ goodpingers =3D buf_new();
+ line =3D buf_new();
+ statssrc =3D buf_new();
+
while (1) {
- x =3D 0;
clear();
standout();
- printw("Select stats source:\n\n");
+ buf_clear(statssrc);
+ f =3D mix_openfile(STATSSRC, "r");
+ if (f !=3D NULL) {
+ buf_read(statssrc, f);
+ fclose(f);
+ }
+ printw("Select stats source:");
standend();
- if (num =3D=3D 0) {
- GetPrivateProfileSectionNames(buffer,sizeof(buffer),path);
- ptr =3D buffer;
- while ((*ptr !=3D '\0') && (num < MAXREM)) {
- if (good_source(ptr,path) =3D=3D TRUE)
- stats[num++] =3D ptr;
- ptr+=3Dstrlen(ptr)+1;
+ if (statssrc->length > 0)
+ printw(" Current: %s (Enter to download)", statssrc->data);
+ printw("\n\n");
+
+ read_allpingers(inifile);
+ get_sections (inifile, pingernames);
+
+ num =3D 0;
+ buf_reset(goodpingers);
+ buf_rewind(pingernames);
+ while ((buf_getline(pingernames, line) !=3D -1) && num < MAXPING) {
+ if (good_stats_source (inifile, line->data)) {
+ buf_cat(goodpingers, line);
+ buf_nl(goodpingers);
+ num++;
}
}
- =09
- for (i =3D 0;i < num;i++) {
+
+ x =3D 0;
+ buf_rewind(goodpingers);
+ for (i=3D0; i<num; i++) {
+ err =3D buf_getline(goodpingers, line);
+ assert (err !=3D -1);
y =3D i;
if (y >=3D LINES - 6)
y -=3D LINES - 6, x =3D 40;
mvprintw(y + 2, x, "%c", i < 26 ? i + 'a' : i - 26 + 'A');
- mvprintw(y + 2, x + 2, "%s", stats[i]);
+ mvprintw(y + 2, x + 2, "%s", line->data);
}
y =3D i + 3;
if (y > LINES - 4)
y =3D LINES - 4;
- mvprintw(y, 0, "* update list of pingers");
+ mvprintw(y, 0, "* update list of pingers from web =3D edit list =
<space> to exit");
c =3D getch();
if ((c >=3D 'a' && c <=3D 'z') || (c >=3D 'A' && c <=3D 'Z')) {
if (c >=3D 'a')
@@ -119,16 +327,70 @@
else
c =3D c - 'A' + 26;
if (c < num) {
- if (download(stats[c],path) =3D=3D TRUE)
+ buf_rewind(goodpingers);
+ while (c >=3D 0) {
+ err =3D buf_getline(goodpingers, line);
+ assert (err !=3D -1);
+ c--;
+ }
+ if (stats_download(inifile, line->data, 1) =3D=3D 0) {
+ f =3D mix_openfile(STATSSRC, "w+");
+ if (f !=3D NULL) {
+ fprintf(f, "%s", line->data);
+ fclose(f);
+ } else
+ fprintf(stderr, "Could not open stats source file for writing\n")=
;
break;
+ }
}
}
else if (c =3D=3D '*') {
- download_list(path);
+ download_list();
}
- else break;
+ else if (c =3D=3D '=3D') {
+ char path[PATHMAX];
+ mixfile(path, ALLPINGERSFILE);
+ menu_spawn_editor(path, 0);
+ }
+ else if ((c =3D=3D '\r') && statssrc->length) {
+ stats_download(inifile, statssrc->data, 1);
+ break;
+ }
+ else if (c =3D=3D ' ') {
+ break;
+ }
}
clear();
+
+ buf_free(statssrc);
+ buf_free(inifile);
+ buf_free(line);
+ buf_free(pingernames);
+ buf_free(goodpingers);
}
=20
-#endif /* _WIN32 */
+#if 0
+int main() {
+ strcpy(MIXDIR,"./");
+
+ BUFFER *allpingers;
+ BUFFER *pingernames;
+ BUFFER *value;
+
+ allpingers =3D buf_new();
+ pingernames =3D buf_new();
+ value =3D buf_new();
+
+ read_allpingers (allpingers);
+ get_sections (allpingers, pingernames);
+
+ printf("%s", pingernames->data);
+
+ get_attribute (allpingers, "noreply", "rlist", value);
+ printf("%s\n", value->data);
+
+
+ exit(0);
+}
+
+#endif
Property changes on: trunk/Mix/Src/menustats.c
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/Mix/Src/mix.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/Src/mix.c 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/Src/mix.c 2004-05-13 13:59:28 UTC (rev 852)
@@ -113,6 +113,10 @@
#endif /* USE_SOCK */
=20
char SHORTNAME[LINELEN];
+char ALLPINGERSURL[BUFSIZE];
+char ALLPINGERSFILE[PATHMAX];
+char WGET[PATHMAX];
+char STATSSRC[PATHMAX];
=20
/* remailer configuration */
int REMAIL;
@@ -411,6 +415,10 @@
strnncpy(NYMSECRING , DEFAULT_NYMSECRING);
strnncpy(NYMDB , DEFAULT_NYMDB);
strnncpy(STAREX , DEFAULT_STAREX);
+ strnncpy(ALLPINGERSURL, DEFAULT_ALLPINGERSURL);
+ strnncpy(ALLPINGERSFILE, DEFAULT_ALLPINGERSFILE);
+ strnncpy(WGET , DEFAULT_WGET);
+ strnncpy(STATSSRC , DEFAULT_STATSSRC);
=20
strnncpy(MIXDIR , "");
strnncpy(POOLDIR , "");
@@ -590,13 +598,15 @@
read_conf(PGPMAXCOUNT) ||
read_conf(DESTALLOW) || read_conf(DESTALLOW2) ||
read_conf(SOURCEBLOCK) ||
- read_conf(STAREX) ||
+ read_conf(STAREX) || read_conf(ALLPINGERSURL) ||
+ read_conf(ALLPINGERSFILE) ||
read_conf(HDRFILTER) || read_conf(REGULAR) ||
read_conf(POOL) || read_conf(TYPE1LIST) ||
read_conf(TYPE2REL) || read_conf(TYPE2LIST) ||
read_conf(PGPREMPUBRING) || read_conf(PGPREMPUBASC) ||
read_conf(PGPREMSECRING) || read_conf(NYMSECRING) ||
read_conf(NYMDB) || read_conf(PIDFILE) ||
+ read_conf(WGET) || read_conf(STATSSRC) ||
=20
read_conf_i(CLIENTAUTOFLUSH) ||
read_conf_i(MAXRECIPIENTS) ||
Modified: trunk/Mix/Src/mix.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/Src/mix.h 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/Src/mix.h 2004-05-13 13:59:28 UTC (rev 852)
@@ -908,7 +908,8 @@
=20
#ifdef WIN32
=20
-#define sleep(x) Sleep(x*1000)
+#define sleep(x) Sleep((x)*1000)
+#define strcasecmp stricmp
=20
#endif /* WIN32 */
=20
Modified: trunk/Mix/Src/mix3.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/Src/mix3.h 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/Src/mix3.h 2004-05-13 13:59:28 UTC (rev 852)
@@ -126,6 +126,10 @@
int clear_pidfile(char *pidfile);
time_t parse_yearmonthday(char* str);
=20
+int url_download(char* url, char* dest);
+void read_allpingers(BUFFER *allpingers);
+int good_stats_source (BUFFER *allpingers, char *sourcename);
+int stats_download(BUFFER *allpingers, char *sourcename, int curses);
=20
typedef struct {
char *name;
Modified: trunk/Mix/Src/pgpdb.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/Src/pgpdb.c 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/Src/pgpdb.c 2004-05-13 13:59:28 UTC (rev 852)
@@ -259,10 +259,10 @@
break;
case PK_ENCRYPT:
case PK_VERIFY:
- r =3D pgpdb_open(PGPREMPUBRING, NULL, 0, PGP_TYPE_PUBLIC);
+ r =3D pgpdb_open(PGPREMPUBASC, NULL, 0, PGP_TYPE_PUBLIC);
if (r !=3D NULL && r->filetype =3D=3D -1) {
pgpdb_close(r);
- r =3D pgpdb_open(PGPREMPUBASC, NULL, 0, PGP_TYPE_PUBLIC);
+ r =3D pgpdb_open(PGPREMPUBRING, NULL, 0, PGP_TYPE_PUBLIC);
}
break;
default:
@@ -536,8 +536,8 @@
p =3D buf_new();
for (i =3D 1; i < n; i++)
pgpkey[i] =3D 0;
- if (pgp_readkeyring(keyring, PGPREMPUBRING) =3D=3D -1)
- pgp_readkeyring(keyring, PGPREMPUBASC);
+ if (pgp_readkeyring(keyring, PGPREMPUBASC) =3D=3D -1)
+ pgp_readkeyring(keyring, PGPREMPUBRING);
while ((type =3D pgp_getpacket(keyring, p)) !=3D -1)
if (type =3D=3D PGP_USERID)
for (i =3D 1; i < n; i++)
Modified: trunk/Mix/TODO
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/TODO 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/TODO 2004-05-13 13:59:28 UTC (rev 852)
@@ -1,3 +1,10 @@
+stats stuff:
+ - move things out of main into their own functions
+ - let it use the logging functions
+ - allow the daemon to update stats at regular intervals
+ - let wget download to temporary files, and only move them over the exi=
sting
+ stats when all downloads succeeded (and perhaps passed basic sanity c=
hecks)
+
Items that need to be completed before the next MAIN release:
=20
- Full functionality / regression testing around chain operations
@@ -7,10 +14,6 @@
- rename pop3.cfg to pop3.cfg.txt
- different editor handling? if so, provide suggestions.
- Sane randomness handling
-- stats stuff:
- - port it to unix
- - use proper configured filenames
- - make the allpingers filename and url configureable
- Add equivalent features to -V and --about to mpgp and document in mpgp=
.1
- Remove OpenSSL version checks. Maybe print a message stating the=20
supported versions, and leave it up to the user?
Modified: trunk/Mix/mixmaster.1
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/mixmaster.1 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/mixmaster.1 2004-05-13 13:59:28 UTC (rev 852)
@@ -114,6 +114,12 @@
.TP
.B "\-fg\fR [\fIfile\fR]"
Send a group reply to a message.
+.TP
+.B "\-\-update-pinger-list"
+Download an updated all pingers list file.
+.TP
+.B "\-\-update-stats\fI[=3Dsource\fR]"
+Download updated stats.
.SS Remailer options:
.TP
.B "\-\-config=3D\fIfilename"
@@ -294,6 +300,16 @@
is used instead.)
Default:
.IR ANONADDR .
+.TP
+.B ALLPINGERSURL
+URL from which to download the=20
+.IR ALLPINGERSFILE .
+Default:
+.BR http://www.noreply.org/allpingers/allpingers.txt .
+.TP
+.B WGET
+Define the http protocol download tool. Default:
+.BR wget .
.SS Remailer configuration:
.TP
.B NEWS
@@ -997,6 +1013,9 @@
would allow user-defined names in the
.B From:
line, while replacing any given address with the remailer address.
+.TP
+.B allpingers.txt
+Information on all known pingers (\fBALLPINGERSFILE\fP).
.SS
Mixmaster uses the following files internally:
.TP
@@ -1021,6 +1040,9 @@
.B stats.log
Log file for remailer statistics (\fBSTATS\fP).
.TP
+.B stats-src.txt
+File for name of most recent statistics source (\fBSTATSSRC\fP).
+.TP
.B pgpmaxcount.log
Log file for PGP Max-Count statistics (\fBPGPMAXCOUNT\fP).
.TP
Modified: trunk/Mix/win32/mixlib.vcproj
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/Mix/win32/mixlib.vcproj 2004-05-13 13:44:32 UTC (rev 851)
+++ trunk/Mix/win32/mixlib.vcproj 2004-05-13 13:59:28 UTC (rev 852)
@@ -227,6 +227,9 @@
</FileConfiguration>
</File>
<File
+ RelativePath=3D"..\Src\menustats.c">
+ </File>
+ <File
RelativePath=3D"..\Src\menuutil.c">
<FileConfiguration
Name=3D"Release|Win32">
|