Upgraded ASCII OLR download to discussed ideas

This commit is contained in:
Michiel Broek 2006-03-05 16:10:03 +00:00
parent d6675ff4b4
commit c3af95b799
2 changed files with 127 additions and 45 deletions

View File

@ -21,6 +21,11 @@ v0.83.14 23-Feb-2006
mbsebbs: mbsebbs:
Added Change archiver menu. Added Change archiver menu.
Added crontrol-U0 to display current archiver. Added crontrol-U0 to display current archiver.
Changes to OLR ASCII download:
- area files are named after area tag if possible, dots are
replaced by underscores and extension is .text.
- If available each message now has a msgid in the header.
- Added a .info file with control information.
mbsetup: mbsetup:
Added archiver selection for nodes in node setup. Added archiver selection for nodes in node setup.

View File

@ -68,6 +68,7 @@ char *newtear = NULL;
typedef struct _msg_high { typedef struct _msg_high {
struct _msg_high *next; struct _msg_high *next;
unsigned int Area; unsigned int Area;
char Tag[60];
unsigned int LastMsg; unsigned int LastMsg;
unsigned int Personal; unsigned int Personal;
} msg_high; } msg_high;
@ -79,7 +80,7 @@ typedef struct _msg_high {
*/ */
void AddArc(char *, char *); void AddArc(char *, char *);
void tidy_high(msg_high **); void tidy_high(msg_high **);
void fill_high(msg_high **, unsigned int, unsigned int, unsigned int); void fill_high(msg_high **, unsigned int, char *, unsigned int, unsigned int);
void UpdateLR(msg_high *, FILE *); void UpdateLR(msg_high *, FILE *);
void Add_Kludges(fidoaddr, int, char *); void Add_Kludges(fidoaddr, int, char *);
int OLR_Prescan(void); int OLR_Prescan(void);
@ -91,7 +92,7 @@ void QWK_Fetch(void);
float IEEToMSBIN(float); float IEEToMSBIN(float);
float MSBINToIEE(float); float MSBINToIEE(float);
char *StripSpaces(char *, int); char *StripSpaces(char *, int);
unsigned int ASCII_PackArea(unsigned int, int); unsigned int ASCII_PackArea(unsigned int, int, char *);
@ -126,13 +127,14 @@ void tidy_high(msg_high **hdp)
/* /*
* Add an area to the array * Add an area to the array
*/ */
void fill_high(msg_high **hdp, unsigned int Area, unsigned int Last, unsigned int Pers) void fill_high(msg_high **hdp, unsigned int Area, char *tag, unsigned int Last, unsigned int Pers)
{ {
msg_high *tmp; msg_high *tmp;
tmp = (msg_high *)malloc(sizeof(msg_high)); tmp = (msg_high *)malloc(sizeof(msg_high));
tmp->next = *hdp; tmp->next = *hdp;
tmp->Area = Area; tmp->Area = Area;
snprintf(tmp->Tag, 51, "%s", tag);
tmp->LastMsg = Last; tmp->LastMsg = Last;
tmp->Personal = Pers; tmp->Personal = Pers;
*hdp = tmp; *hdp = tmp;
@ -1338,7 +1340,7 @@ void OLR_DownBW()
if (Start < Msg_Highest()) { if (Start < Msg_Highest()) {
Syslog('m', "First %lu, Last %lu, Start %lu", Msg_Lowest(), Msg_Highest(), Start); Syslog('m', "First %lu, Last %lu, Start %lu", Msg_Lowest(), Msg_Highest(), Start);
High = BlueWave_PackArea(Start, Area); High = BlueWave_PackArea(Start, Area);
fill_high(&mhl, Area, High, Personal); fill_high(&mhl, Area, msgs.Tag, High, Personal);
} }
} }
Syslog('+', "Area %-20s %5ld (%ld personal)", msgs.QWKname, Current, Personal); Syslog('+', "Area %-20s %5ld (%ld personal)", msgs.QWKname, Current, Personal);
@ -2005,7 +2007,7 @@ void OLR_DownQWK(void)
if (Start < Msg_Highest()) { if (Start < Msg_Highest()) {
Syslog('m', "First %lu, Last %lu, Start %lu", Msg_Lowest(), Msg_Highest(), Start); Syslog('m', "First %lu, Last %lu, Start %lu", Msg_Lowest(), Msg_Highest(), Start);
High = QWK_PackArea(Start, Area); High = QWK_PackArea(Start, Area);
fill_high(&mhl, Area, High, Personal); fill_high(&mhl, Area, msgs.Tag, High, Personal);
} }
} }
Syslog('+', "Area %-20s %5ld (%ld personal)", msgs.QWKname, Current, Personal); Syslog('+', "Area %-20s %5ld (%ld personal)", msgs.QWKname, Current, Personal);
@ -2640,10 +2642,9 @@ void OLR_DownASCII(void)
{ {
struct tm *tp; struct tm *tp;
time_t Now; time_t Now;
char Pktname[32], *Work, *Temp, *cwd = NULL; char Pktname[32], *Work, *Temp, *cwd = NULL, Atag[60], Kinds[12];
int Area = 0; int Area = 0, i, rc = 0;
int rc = 0; FILE *fp = NULL, *tf, *mf, *af, *inf;
FILE *fp = NULL, *tf, *mf, *af;
unsigned int Start, High; unsigned int Start, High;
msg_high *tmp, *mhl = NULL; msg_high *tmp, *mhl = NULL;
@ -2689,15 +2690,62 @@ void OLR_DownASCII(void)
return; return;
} }
snprintf(Atag, 9, CFG.bbsid);
tl(Atag);
snprintf(Temp, PATH_MAX, "%s/%s/tmp/%s.info", CFG.bbs_usersdir, exitinfo.Name, Atag);
if ((inf = fopen(Temp, "a+")) == NULL) {
WriteError("$Can't create %s", Temp);
fclose(tf);
fclose(fp);
fclose(mf);
return;
}
Area = 0; Area = 0;
DrawBar(Pktname); DrawBar(Pktname);
fseek(mf, sizeof(msgshdr), SEEK_SET); fseek(mf, sizeof(msgshdr), SEEK_SET);
fseek(tf, 0, SEEK_SET); fseek(tf, 0, SEEK_SET);
while (fread(&msgs, msgshdr.recsize, 1, mf) == 1) { while (fread(&msgs, msgshdr.recsize, 1, mf) == 1) {
fseek(mf, msgshdr.syssize, SEEK_CUR); fseek(mf, msgshdr.syssize, SEEK_CUR);
fread(&olrtagrec, sizeof(olrtagrec), 1, tf); fread(&olrtagrec, sizeof(olrtagrec), 1, tf);
Area++; Area++;
if (msgs.Active && Access(exitinfo.Security, msgs.RDSec)) {
if (strlen(msgs.Tag))
snprintf(Atag, 51, msgs.Tag);
else
snprintf(Atag, 51, "%d", Area);
switch (msgs.Type) {
case LOCALMAIL: snprintf(Temp, 81, "Local");
break;
case NETMAIL: snprintf(Temp, 81, "Net");
break;
case ECHOMAIL: snprintf(Temp, 81, "Echo");
break;
case NEWS: snprintf(Temp, 81, "News");
break;
case LIST: snprintf(Temp, 81, "List");
break;
}
switch (msgs.MsgKinds) {
case BOTH: snprintf(Kinds, 12, "PvtPub");
break;
case PRIVATE: snprintf(Kinds, 12, "Pvt");
break;
case PUBLIC: snprintf(Kinds, 12, "Pub");
break;
case RONLY: snprintf(Kinds, 12, "RO");
break;
case FTNMOD: snprintf(Kinds, 12, "FtnMod");
break;
case USEMOD: snprintf(Kinds, 12, "UseMod");
break;
}
fprintf(inf, "Area %s,%s,%s,%s,%s\n", Atag, Temp, Kinds, olrtagrec.Tagged ?"S":"U", msgs.Name);
}
if (olrtagrec.Tagged) { if (olrtagrec.Tagged) {
if (Msg_Open(msgs.Base)) { if (Msg_Open(msgs.Base)) {
Current = Personal = 0; Current = Personal = 0;
@ -2711,8 +2759,17 @@ void OLR_DownASCII(void)
if (Start > Msg_Highest()) if (Start > Msg_Highest())
Start = Msg_Highest(); Start = Msg_Highest();
if (Start < Msg_Highest()) { if (Start < Msg_Highest()) {
High = ASCII_PackArea(Start, Area); if (strlen(msgs.Tag))
fill_high(&mhl, Area, High, Personal); snprintf(Atag, 60, "%s_%s", CFG.bbsid, msgs.Tag);
else
snprintf(Atag, 60, "%s_%d", CFG.bbsid, Area);
for (i = 0; i < strlen(Atag); i++) {
if (Atag[i] == '.')
Atag[i] = '_';
Atag[i] = tolower(Atag[i]);
}
High = ASCII_PackArea(Start, Area, Atag);
fill_high(&mhl, Area, Atag, High, Personal);
} }
} }
Syslog('+', "Area %-20s %5ld (%ld personal)", msgs.QWKname, Current, Personal); Syslog('+', "Area %-20s %5ld (%ld personal)", msgs.QWKname, Current, Personal);
@ -2720,8 +2777,12 @@ void OLR_DownASCII(void)
} }
} }
} }
fclose(inf);
if (Total) { /*
* In ASCII mode we allways download, even if there are no messages
* packed. However we do have a .info file for the user.
*/
Enter(1); Enter(1);
/* Packing with */ /* Packing with */
PUTSTR((char *)Language(446)); PUTSTR((char *)Language(446));
@ -2738,8 +2799,12 @@ void OLR_DownASCII(void)
chdir(Work); chdir(Work);
alarm_on(); alarm_on();
snprintf(Temp, PATH_MAX, "%s.info", CFG.bbsid);
tl(Temp);
AddArc(Temp, Pktname);
for (tmp = mhl; tmp; tmp = tmp->next) { for (tmp = mhl; tmp; tmp = tmp->next) {
snprintf(Temp, PATH_MAX, "%03d.TXT", tmp->Area); snprintf(Temp, PATH_MAX, "%s.text", tmp->Tag);
AddArc(Temp, Pktname); AddArc(Temp, Pktname);
} }
chdir(cwd); chdir(cwd);
@ -2752,7 +2817,6 @@ void OLR_DownASCII(void)
} }
fclose(af); fclose(af);
} }
}
if (rc) { if (rc) {
Syslog('+', "ASCII download failed"); Syslog('+', "ASCII download failed");
@ -2780,7 +2844,7 @@ void OLR_DownASCII(void)
/* /*
* Pack messages in one mail area * Pack messages in one mail area
*/ */
unsigned int ASCII_PackArea(unsigned int ulLast, int Area) unsigned int ASCII_PackArea(unsigned int ulLast, int Area, char *Atag)
{ {
FILE *fp; FILE *fp;
char *Work, *Temp, *Text, msg[81]; char *Work, *Temp, *Text, msg[81];
@ -2795,7 +2859,7 @@ unsigned int ASCII_PackArea(unsigned int ulLast, int Area)
Work = calloc(PATH_MAX, sizeof(char)); Work = calloc(PATH_MAX, sizeof(char));
snprintf(Work, PATH_MAX, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name); snprintf(Work, PATH_MAX, "%s/%s/tmp", CFG.bbs_usersdir, exitinfo.Name);
snprintf(Temp, PATH_MAX, "%s/%03d.TXT", Work, Area); snprintf(Temp, PATH_MAX, "%s/%s.text", Work, Atag);
if ((fp = fopen(Temp, "a+")) != NULL) { if ((fp = fopen(Temp, "a+")) != NULL) {
if (Msg_Next(&Number)) { if (Msg_Next(&Number)) {
do { do {
@ -2815,7 +2879,8 @@ unsigned int ASCII_PackArea(unsigned int ulLast, int Area)
} }
if (Pack) { if (Pack) {
fprintf (fp, "\n==============================================\n Msg. #%d of %d (%s)\n", fprintf (fp, "===============================================================================\n");
fprintf (fp, " Msg: #%d of %d (%s)\n",
Number, Msg_Number(), msgs.Name); Number, Msg_Number(), msgs.Name);
tp = localtime(&Msg.Written); tp = localtime(&Msg.Written);
fprintf (fp, " Date: %d %s %d %2d:%02d\n", tp->tm_mday, fprintf (fp, " Date: %d %s %d %2d:%02d\n", tp->tm_mday,
@ -2823,7 +2888,19 @@ unsigned int ASCII_PackArea(unsigned int ulLast, int Area)
fprintf (fp, " From: %s\n", Msg.From); fprintf (fp, " From: %s\n", Msg.From);
if (Msg.To[0]) if (Msg.To[0])
fprintf (fp, " To: %s\n", Msg.To); fprintf (fp, " To: %s\n", Msg.To);
fprintf (fp, "Subject: %s\n----------------------------------------------\n", Msg.Subject); fprintf (fp, " Subj: %s\n", Msg.Subject);
/*
* If present, add the msgid
*/
if ((Text = (char *)MsgText_First()) != NULL) {
do {
if (strncmp(Text, "\001MSGID: ", 8) == 0) {
fprintf (fp, "Msgid: %s\n", Text+8);
break;
}
} while ((Text = (char *)MsgText_Next()) != NULL);
}
fprintf (fp, "-------------------------------------------------------------------------------\n");
Current++; Current++;
Total++; Total++;