Added maximum news articles limit

This commit is contained in:
Michiel Broek 2002-01-14 19:19:17 +00:00
parent ef2522796a
commit 1b9fa1f09b
4 changed files with 108 additions and 42 deletions

View File

@ -249,7 +249,7 @@ int do_one_group(List **art, char *grpname, char *ftntag)
{ {
List *tmp; List *tmp;
char temp[128], *resp; char temp[128], *resp;
int retval; int retval, fetched = 0;
long total, start, end; long total, start, end;
Syslog('N', "do_one_group(%s, %s)", grpname, ftntag); Syslog('N', "do_one_group(%s, %s)", grpname, ftntag);
@ -269,6 +269,10 @@ int do_one_group(List **art, char *grpname, char *ftntag)
total = atol(strtok(NULL, " ")); total = atol(strtok(NULL, " "));
start = atol(strtok(NULL, " ")); start = atol(strtok(NULL, " "));
end = atol(strtok(NULL, " '\0'")); end = atol(strtok(NULL, " '\0'"));
if ((msgs.MaxArticles) && (total > msgs.MaxArticles)) {
start = end - msgs.MaxArticles;
total = msgs.MaxArticles;
}
Syslog('n', "GROUP total %d, start %d, end %d", total, start, end); Syslog('n', "GROUP total %d, start %d, end %d", total, start, end);
if (!total) { if (!total) {
Syslog('N', "No articles"); Syslog('N', "No articles");
@ -290,11 +294,16 @@ int do_one_group(List **art, char *grpname, char *ftntag)
most_debug = TRUE; most_debug = TRUE;
get_article(tmp->msgid, ftntag); get_article(tmp->msgid, ftntag);
most_debug = FALSE; most_debug = FALSE;
fetched++;
} }
} }
} }
tidy_artlist(art); tidy_artlist(art);
if ((msgs.MaxArticles) && (fetched == msgs.MaxArticles))
Syslog('!', "Warning: the maximum articles value for this group might be to low");
return RETVAL_OK; return RETVAL_OK;
} }

View File

@ -946,11 +946,12 @@ void s_intmailcfg(void)
mvprintw(16, 1, "10. UUCP aka"); mvprintw(16, 1, "10. UUCP aka");
mvprintw(17, 1, "11. Emailmode"); mvprintw(17, 1, "11. Emailmode");
mvprintw(13,42, "12. News mode"); mvprintw(12,42, "12. Articles");
mvprintw(14,42, "13. Split at"); mvprintw(13,42, "13. News mode");
mvprintw(15,42, "14. Force at"); mvprintw(14,42, "14. Split at");
mvprintw(16,42, "15. Control ok"); mvprintw(15,42, "15. Force at");
mvprintw(17,42, "16. No regate"); mvprintw(16,42, "16. Control ok");
mvprintw(17,42, "17. No regate");
set_color(WHITE, BLACK); set_color(WHITE, BLACK);
show_str( 7,16,64, CFG.popnode); show_str( 7,16,64, CFG.popnode);
@ -966,6 +967,7 @@ void s_intmailcfg(void)
show_aka(16,16, CFG.UUCPgate); show_aka(16,16, CFG.UUCPgate);
show_emailmode(17,16, CFG.EmailMode); show_emailmode(17,16, CFG.EmailMode);
show_int( 12,57, CFG.maxarticles);
show_newsmode(13,57, CFG.newsfeed); show_newsmode(13,57, CFG.newsfeed);
show_int( 14,57, CFG.new_split); show_int( 14,57, CFG.new_split);
show_int( 15,57, CFG.new_force); show_int( 15,57, CFG.new_force);
@ -1020,7 +1022,7 @@ void e_intmailcfg(void)
s_intmailcfg(); s_intmailcfg();
for (;;) { for (;;) {
switch(select_menu(16)) { switch(select_menu(17)) {
case 0: return; case 0: return;
case 1: E_STR( 7,16,64, CFG.popnode, "The ^FQDN^ of the node where the ^POP3^ server runs.") case 1: E_STR( 7,16,64, CFG.popnode, "The ^FQDN^ of the node where the ^POP3^ server runs.")
case 2: E_STR( 8,16,64, CFG.smtpnode, "The ^FQDN^ of the node where the ^SMTP^ server runs.") case 2: E_STR( 8,16,64, CFG.smtpnode, "The ^FQDN^ of the node where the ^SMTP^ server runs.")
@ -1050,13 +1052,14 @@ void e_intmailcfg(void)
s_intmailcfg(); s_intmailcfg();
break; break;
case 12:CFG.newsfeed = edit_newsmode(13,57, CFG.newsfeed); case 12:E_INT( 12,57, CFG.maxarticles, "Default maximum ^news articles^ to fetch")
case 13:CFG.newsfeed = edit_newsmode(13,57, CFG.newsfeed);
s_intmailcfg(); s_intmailcfg();
break; break;
case 13:E_INT( 14,57, CFG.new_split, "Gently ^split^ messages after n kilobytes (12..60).") case 14:E_INT( 14,57, CFG.new_split, "Gently ^split^ messages after n kilobytes (12..60).")
case 14:E_INT( 15,57, CFG.new_force, "Force ^split^ of messages after n kilobytes (16..64).") case 15:E_INT( 15,57, CFG.new_force, "Force ^split^ of messages after n kilobytes (16..64).")
case 15:E_BOOL(16,57, CFG.allowcontrol, "^Allow control^ messages for news to be gated.") case 16:E_BOOL(16,57, CFG.allowcontrol, "^Allow control^ messages for news to be gated.")
case 16:E_BOOL(17,57, CFG.dontregate, "Don't ^regate^ already gated messages.") case 17:E_BOOL(17,57, CFG.dontregate, "Don't ^regate^ already gated messages.")
} }
}; };
} }
@ -1914,6 +1917,7 @@ int global_doc(FILE *fp, FILE *toc, int page)
fprintf(fp, " Path to rnews %s\n", CFG.rnewspath); fprintf(fp, " Path to rnews %s\n", CFG.rnewspath);
break; break;
} }
fprintf(fp, " Max articles fetch %d\n", CFG.maxarticles);
fprintf(fp, " Allow control msgs %s\n", getboolean(CFG.allowcontrol)); fprintf(fp, " Allow control msgs %s\n", getboolean(CFG.allowcontrol));
fprintf(fp, " Don't regate msgs %s\n", getboolean(CFG.dontregate)); fprintf(fp, " Don't regate msgs %s\n", getboolean(CFG.dontregate));

View File

@ -297,6 +297,7 @@ void InitMsgRec(void)
msgs.UsrDelete = TRUE; msgs.UsrDelete = TRUE;
msgs.Rfccode = CHRS_DEFAULT_RFC; msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN; msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.MaxArticles = CFG.maxarticles;
strcpy(msgs.Origin, CFG.origin); strcpy(msgs.Origin, CFG.origin);
} }
@ -430,7 +431,9 @@ int EditConnections(FILE *fil)
if (System.aka.zone) { if (System.aka.zone) {
set_color(CYAN,BLACK); set_color(CYAN,BLACK);
sprintf(temp, "%3d. %s %d:%d/%d.%d@%s", o+i, status, System.aka.zone, System.aka.net, System.aka.node, System.aka.point, System.aka.domain); sprintf(temp, "%3d. %s %d:%d/%d.%d@%s", o+i, status,
System.aka.zone, System.aka.net, System.aka.node,
System.aka.point, System.aka.domain);
} else { } else {
set_color(LIGHTBLUE, BLACK); set_color(LIGHTBLUE, BLACK);
sprintf(temp, "%3d.", o+i); sprintf(temp, "%3d.", o+i);
@ -490,7 +493,14 @@ void SetScreen()
mvprintw(13,36, "15. Days Old"); mvprintw(13,36, "15. Days Old");
mvprintw(14,36, "16. Max. Msgs"); mvprintw(14,36, "16. Max. Msgs");
mvprintw(15,36, "17. Netreply"); switch (msgs.Type) {
case ECHOMAIL: mvprintw(15,36, "17. Netreply");
break;
case NEWS: mvprintw(15,36, "17. Articles");
break;
default: mvprintw(15,36, "17. N/A");
break;
}
mvprintw(16,36, "18. Active"); mvprintw(16,36, "18. Active");
mvprintw(17,36, "19. Read Sec."); mvprintw(17,36, "19. Read Sec.");
mvprintw(18,36, "20. Write Sec."); mvprintw(18,36, "20. Write Sec.");
@ -503,7 +513,12 @@ void SetScreen()
mvprintw(16,60, "26. UnSecure"); mvprintw(16,60, "26. UnSecure");
mvprintw(17,60, "27. OLR Default"); mvprintw(17,60, "27. OLR Default");
mvprintw(18,60, "28. OLR Forced"); mvprintw(18,60, "28. OLR Forced");
mvprintw(19,60, "29. Connections"); switch (msgs.Type) {
case ECHOMAIL:
case NEWS:
case LIST: mvprintw(19,60, "29. Connections");
break;
}
} }
@ -626,7 +641,7 @@ void MsgGlobal(void)
FILE *fil; FILE *fil;
fidoaddr a1, a2; fidoaddr a1, a2;
int menu = 0, marea, Areas, akan = 0, Found; int menu = 0, marea, Areas, akan = 0, Found;
int Total, Done, netbrd, daysold, maxmsgs; int Total, Done, netbrd, daysold, maxmsgs, maxarticles;
long offset; long offset;
securityrec rs, ws, ss; securityrec rs, ws, ss;
sysconnect S, Sc; sysconnect S, Sc;
@ -660,6 +675,7 @@ void MsgGlobal(void)
sprintf(mfile, "%s", CFG.origin); sprintf(mfile, "%s", CFG.origin);
daysold = CFG.defdays; daysold = CFG.defdays;
maxmsgs = CFG.defmsgs; maxmsgs = CFG.defmsgs;
maxarticles = CFG.maxarticles;
netbrd = 1; netbrd = 1;
for (;;) { for (;;) {
@ -673,16 +689,17 @@ void MsgGlobal(void)
mvprintw(10, 6, "4. Change connection status"); mvprintw(10, 6, "4. Change connection status");
mvprintw(11, 6, "5. Change days old"); mvprintw(11, 6, "5. Change days old");
mvprintw(12, 6, "6. Change max. messages"); mvprintw(12, 6, "6. Change max. messages");
mvprintw(13, 6, "7. Change security"); mvprintw(13, 6, "7. Change max. articles");
mvprintw(14, 6, "8. Change aka to use"); mvprintw(14, 6, "8. Change security");
mvprintw(15, 6, "9. Change origin line"); mvprintw(15, 6, "9. Change aka to use");
mvprintw(16, 6, "10. Change netmail reply"); mvprintw(16, 6, "10. Change origin line");
mvprintw(17, 6, "11. Delete message area"); mvprintw(17, 6, "11. Change netmail reply");
mvprintw(18, 6, "12. Delete message area");
memset(&a1, 0, sizeof(fidoaddr)); memset(&a1, 0, sizeof(fidoaddr));
memset(&a2, 0, sizeof(fidoaddr)); memset(&a2, 0, sizeof(fidoaddr));
menu = select_menu(11); menu = select_menu(12);
switch (menu) { switch (menu) {
case 0: return; case 0: return;
case 1: a1 = PullUplink((char *)"AKA TO DELETE"); case 1: a1 = PullUplink((char *)"AKA TO DELETE");
@ -703,14 +720,16 @@ void MsgGlobal(void)
E_INT(LINES -3, 14, daysold, (char *)"Enter new number of ^days old^") E_INT(LINES -3, 14, daysold, (char *)"Enter new number of ^days old^")
case 6: mvprintw(LINES -3, 5, "Max. messages"); case 6: mvprintw(LINES -3, 5, "Max. messages");
E_INT(LINES -3, 19, maxmsgs, (char *)"Enter ^maximum messages^") E_INT(LINES -3, 19, maxmsgs, (char *)"Enter ^maximum messages^")
case 7: rs = edit_sec(6, 5, rs, (char *)"9.2.7 READ SECURITY"); case 7: mvprintw(LINES -3, 6, "Max. articles");
E_INT(LINES -3, 19, maxarticles, (char *)"Enter ^maximum news articles^ to fetch")
case 8: rs = edit_sec(6, 5, rs, (char *)"9.2.7 READ SECURITY");
ws = edit_sec(7, 5, ws, (char *)"9.2.7 WRITE SECURITY"); ws = edit_sec(7, 5, ws, (char *)"9.2.7 WRITE SECURITY");
ss = edit_sec(8, 5, ss, (char *)"9.2.7 SYSOP SECURITY"); ss = edit_sec(8, 5, ss, (char *)"9.2.7 SYSOP SECURITY");
break; break;
case 8: akan = PickAka((char *)"9.2.8", TRUE); case 9: akan = PickAka((char *)"9.2.8", TRUE);
break; break;
case 9: E_STR(LINES -3, 5, 64, mfile, "Enter new ^origin^ line"); case 10:E_STR(LINES -3, 5, 64, mfile, "Enter new ^origin^ line");
case 10:mvprintw(LINES -3, 5, "Netmail reply board"); case 11:mvprintw(LINES -3, 5, "Netmail reply board");
E_INT(LINES -3, 25, netbrd, (char *)"The ^netmail reply^ board number") E_INT(LINES -3, 25, netbrd, (char *)"The ^netmail reply^ board number")
} }
@ -735,7 +754,9 @@ void MsgGlobal(void)
break; break;
case 6: mvprintw(7, 6, "Change maximum messages to %d", maxmsgs); case 6: mvprintw(7, 6, "Change maximum messages to %d", maxmsgs);
break; break;
case 7: set_color(CYAN, BLACK); case 7: mvprintw(7, 6, "Change maximum news articles to fetch to %d", maxarticles);
break;
case 8: set_color(CYAN, BLACK);
mvprintw(7, 6, "Read security"); mvprintw(7, 6, "Read security");
mvprintw(8, 6, "Write security"); mvprintw(8, 6, "Write security");
mvprintw(9, 6, "Sysop security"); mvprintw(9, 6, "Sysop security");
@ -744,14 +765,14 @@ void MsgGlobal(void)
show_sec(8, 21, ws); show_sec(8, 21, ws);
show_sec(9, 21, ss); show_sec(9, 21, ss);
break; break;
case 8: if (akan != -1) case 9: if (akan != -1)
mvprintw( 7, 6, "Set %s as new aka to use", aka2str(CFG.aka[akan])); mvprintw( 7, 6, "Set %s as new aka to use", aka2str(CFG.aka[akan]));
break; break;
case 9: mvprintw(7, 6, "Origin: %s", mfile); case 10:mvprintw(7, 6, "Origin: %s", mfile);
break; break;
case 10:mvprintw(7, 6, "New netmail reply board %d", netbrd); case 11:mvprintw(7, 6, "New netmail reply board %d", netbrd);
break; break;
case 11:mvprintw(7, 6, "Delete message areas"); case 12:mvprintw(7, 6, "Delete message areas");
break; break;
} }
@ -876,7 +897,15 @@ void MsgGlobal(void)
} }
} }
break; break;
case 7: if ((msgs.RDSec.level != rs.level) || case 7: if (maxarticles != msgs.MaxArticles) {
msgs.MaxArticles = maxarticles;
if (SaveMsgRec(marea, FALSE) == 0) {
Done++;
Syslog('+', "Changed max news articles to fetch to %d in area %s", maxarticles, msgs.Tag);
}
}
break;
case 8: if ((msgs.RDSec.level != rs.level) ||
(msgs.RDSec.flags != rs.flags) || (msgs.RDSec.flags != rs.flags) ||
(msgs.RDSec.notflags != rs.notflags) || (msgs.RDSec.notflags != rs.notflags) ||
(msgs.WRSec.level != ws.level) || (msgs.WRSec.level != ws.level) ||
@ -894,7 +923,7 @@ void MsgGlobal(void)
} }
} }
break; break;
case 8: if (akan != -1) { case 9: if (akan != -1) {
if ((msgs.Aka.zone != CFG.aka[akan].zone) || if ((msgs.Aka.zone != CFG.aka[akan].zone) ||
(msgs.Aka.net != CFG.aka[akan].net) || (msgs.Aka.net != CFG.aka[akan].net) ||
(msgs.Aka.node != CFG.aka[akan].node) || (msgs.Aka.node != CFG.aka[akan].node) ||
@ -911,7 +940,7 @@ void MsgGlobal(void)
} }
} }
break; break;
case 9: if (strcmp(msgs.Origin, mfile)) { case 10:if (strcmp(msgs.Origin, mfile)) {
sprintf(msgs.Origin, "%s", mfile); sprintf(msgs.Origin, "%s", mfile);
if (SaveMsgRec(marea, FALSE) == 0) { if (SaveMsgRec(marea, FALSE) == 0) {
Done++; Done++;
@ -919,7 +948,7 @@ void MsgGlobal(void)
} }
} }
break; break;
case 10:if (netbrd != msgs.NetReply) { case 11:if (netbrd != msgs.NetReply) {
msgs.NetReply = netbrd; msgs.NetReply = netbrd;
if (SaveMsgRec(marea, FALSE) == 0) { if (SaveMsgRec(marea, FALSE) == 0) {
Done++; Done++;
@ -927,7 +956,7 @@ void MsgGlobal(void)
} }
} }
break; break;
case 11:if (msgs.Active) { case 12:if (msgs.Active) {
msgs.Active = FALSE; msgs.Active = FALSE;
memset(&msgs.Name, 0, sizeof(msgs.Name)); memset(&msgs.Name, 0, sizeof(msgs.Name));
if (SaveMsgRec(marea, FALSE) == 0) { if (SaveMsgRec(marea, FALSE) == 0) {
@ -994,7 +1023,12 @@ int EditMsgRec(int Area)
show_int( 13,52, msgs.DaysOld); show_int( 13,52, msgs.DaysOld);
show_int( 14,52, msgs.MaxMsgs); show_int( 14,52, msgs.MaxMsgs);
show_int( 15,52, msgs.NetReply); switch (msgs.Type) {
case ECHOMAIL: show_int( 15,52, msgs.NetReply);
break;
case NEWS: show_int( 15,52, msgs.MaxArticles);
break;
}
show_bool(16,52, msgs.Active); show_bool(16,52, msgs.Active);
show_int( 17,52, msgs.RDSec.level); show_int( 17,52, msgs.RDSec.level);
show_int( 18,52, msgs.WRSec.level); show_int( 18,52, msgs.WRSec.level);
@ -1068,12 +1102,22 @@ int EditMsgRec(int Area)
SetScreen(); SetScreen();
break; break;
case 10:E_STR( 15,16,16,msgs.Distribution, "The ^Distribution^ name if this is a newsgroup") case 10:E_STR( 15,16,16,msgs.Distribution, "The ^Distribution^ name if this is a newsgroup")
case 11:msgs.Type = edit_msgtype(16,16, msgs.Type); break; case 11:msgs.Type = edit_msgtype(16,16, msgs.Type);
SetScreen();
break;
case 12:msgs.MsgKinds = edit_msgkinds(17,16, msgs.MsgKinds); break; case 12:msgs.MsgKinds = edit_msgkinds(17,16, msgs.MsgKinds); break;
case 15:E_INT( 13,52, msgs.DaysOld, "Maximum ^days^ to keep mail in this area") case 15:E_INT( 13,52, msgs.DaysOld, "Maximum ^days^ to keep mail in this area")
case 16:E_INT( 14,52, msgs.MaxMsgs, "The ^maximum^ amount of messages in this area") case 16:E_INT( 14,52, msgs.MaxMsgs, "The ^maximum^ amount of messages in this area")
case 17:E_INT( 15,52, msgs.NetReply, "The ^Area Number^ for netmail replies") case 17:switch (msgs.Type) {
case ECHOMAIL: msgs.NetReply = edit_int(15,52,msgs.NetReply,
(char *)"The ^Area Number^ for netmail replies");
break;
case NEWS: msgs.MaxArticles = edit_int(15,52,msgs.MaxArticles,
(char *)"The ^maximum news articles^ to fetch");
break;
}
break;
case 18:E_BOOL(16,52, msgs.Active, "Is this area ^Active^") case 18:E_BOOL(16,52, msgs.Active, "Is this area ^Active^")
case 19:E_SEC( 17,52, msgs.RDSec, "9.2 EDIT READ SECURITY", SetScreen) case 19:E_SEC( 17,52, msgs.RDSec, "9.2 EDIT READ SECURITY", SetScreen)
case 20:E_SEC( 18,52, msgs.WRSec, "9.2 EDIT WRITE SECURITY", SetScreen) case 20:E_SEC( 18,52, msgs.WRSec, "9.2 EDIT WRITE SECURITY", SetScreen)
@ -1086,9 +1130,15 @@ int EditMsgRec(int Area)
case 26:E_BOOL(16,76, msgs.UnSecure, "Toss messages ^UnSecure^, ie: no originating check") case 26:E_BOOL(16,76, msgs.UnSecure, "Toss messages ^UnSecure^, ie: no originating check")
case 27:E_BOOL(17,76, msgs.OLR_Default, "Area is ^default^ for ^offline^ users.") case 27:E_BOOL(17,76, msgs.OLR_Default, "Area is ^default^ for ^offline^ users.")
case 28:E_BOOL(18,76, msgs.OLR_Forced, "Area is ^always on^ for ^offline^ users.") case 28:E_BOOL(18,76, msgs.OLR_Forced, "Area is ^always on^ for ^offline^ users.")
case 29:if (EditConnections(tfil)) case 29:switch (msgs.Type) {
case ECHOMAIL:
case NEWS:
case LIST: if (EditConnections(tfil))
changed = TRUE; changed = TRUE;
SetScreen(); break; SetScreen();
break;
}
break;
} }
} }
} }
@ -1506,6 +1556,7 @@ int mail_area_doc(FILE *fp, FILE *toc, int page)
fprintf(fp, " RFC charset %s\n", printable(getchrs(msgs.Rfccode), 0)); fprintf(fp, " RFC charset %s\n", printable(getchrs(msgs.Rfccode), 0));
fprintf(fp, " Days old msgs. %d\n", msgs.DaysOld); fprintf(fp, " Days old msgs. %d\n", msgs.DaysOld);
fprintf(fp, " Maximum msgs. %d\n", msgs.MaxMsgs); fprintf(fp, " Maximum msgs. %d\n", msgs.MaxMsgs);
fprintf(fp, " Max articles %d\n", msgs.MaxArticles);
fprintf(fp, " Users delete %s\n", getboolean(msgs.UsrDelete)); fprintf(fp, " Users delete %s\n", getboolean(msgs.UsrDelete));
fprintf(fp, " Read security %s\n", get_secstr(msgs.RDSec)); fprintf(fp, " Read security %s\n", get_secstr(msgs.RDSec));
fprintf(fp, " Write security %s\n", get_secstr(msgs.WRSec)); fprintf(fp, " Write security %s\n", get_secstr(msgs.WRSec));

View File

@ -402,6 +402,8 @@ void load_maincfg(void)
sprintf(CFG.www_name_next, "Next page"); sprintf(CFG.www_name_next, "Next page");
CFG.www_files_page = 10; CFG.www_files_page = 10;
CFG.maxarticles = 500;
if ((fp = fopen(cfgfn, "a+")) == NULL) { if ((fp = fopen(cfgfn, "a+")) == NULL) {
perror(""); perror("");
fprintf(stderr, "Can't create %s\n", cfgfn); fprintf(stderr, "Can't create %s\n", cfgfn);