From 7856ed72cb525aa83809df2e5b7fa1fe2f00cbfb Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 5 Aug 2000 04:24:13 +0000 Subject: [PATCH] * Added [idle] to client wholist display for sessions idle >15 minutes * Added a generic "void *userdata" field to CtdlForEachMessage() * More prep for mailing list handling in the server --- citadel/ChangeLog | 6 ++ citadel/citadel.c | 35 +++++++---- citadel/msgbase.c | 18 +++--- citadel/msgbase.h | 5 +- citadel/serv_expire.c | 5 +- citadel/serv_inetcfg.c | 4 +- citadel/serv_moderate.c | 2 +- citadel/serv_network.c | 108 +++++++++++++++++++++++++++++++++ citadel/serv_network.h | 5 +- citadel/serv_pop3.c | 5 +- citadel/serv_smtp.c | 4 +- citadel/serv_vandelay.c | 4 +- citadel/serv_vcard.c | 4 +- citadel/techdoc/netconfigs.txt | 6 +- 14 files changed, 172 insertions(+), 39 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 8a9823efa..e40f73589 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,9 @@ $Log$ + Revision 572.22 2000/08/05 04:24:00 ajc + * Added [idle] to client wholist display for sessions idle >15 minutes + * Added a generic "void *userdata" field to CtdlForEachMessage() + * More prep for mailing list handling in the server + Revision 572.21 2000/07/30 04:36:12 ajc * Set up the SNET (Send NETwork config) and GNET (Get NETwork config) commands for the network overhaul. @@ -1972,3 +1977,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citadel.c b/citadel/citadel.c index e638835bd..79589cb56 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -736,15 +736,16 @@ void who_is_online(int longlist) time_t idletime, idlehours, idlemins, idlesecs; int last_session = (-1); - if (longlist) { - serv_puts("TIME"); - serv_gets(tbuf); - if (tbuf[0] == '2') { - timenow = extract_long(&tbuf[4], 0); - } else { - time(&timenow); - } - } else { + serv_puts("TIME"); + serv_gets(tbuf); + if (tbuf[0] == '2') { + timenow = extract_long(&tbuf[4], 0); + } + else { + time(&timenow); + } + + if (!longlist) { color(BRIGHT_WHITE); pprintf("FLG ### User Name Room From host\n"); color(DIM_WHITE); @@ -760,16 +761,24 @@ void who_is_online(int longlist) extract(clientsoft, buf, 4); extract(flags, buf, 7); + idletime = timenow - extract_long(buf, 5); + idlehours = idletime / 3600; + idlemins = (idletime - (idlehours * 3600)) / 60; + idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60)); + + if (idletime > 900) { + while (strlen(roomname) < 20) { + strcat(roomname, " "); + } + strcpy(&roomname[14], "[idle]"); + } + if (longlist) { extract(actual_user, buf, 8); extract(actual_room, buf, 9); extract(actual_host, buf, 10); - idletime = timenow - extract_long(buf, 5); - idlehours = idletime / 3600; - idlemins = (idletime - (idlehours * 3600)) / 60; - idlesecs = (idletime - (idlehours * 3600) - (idlemins * 60)); pprintf("\nFlags: %-3s Sess# %-3d Name: %-25s Room: %s\n", flags, extract_int(buf, 0), username, roomname); pprintf("from <%s> using <%s>, idle %ld:%02ld:%02ld\n", diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 086ca77e6..d5cae7084 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -240,7 +240,7 @@ void get_mm(void) -void simple_listing(long msgnum) +void simple_listing(long msgnum, void *userdata) { cprintf("%ld\n", msgnum); } @@ -286,7 +286,8 @@ int CtdlForEachMessage(int mode, long ref, int moderation_level, char *content_type, struct CtdlMessage *compare, - void (*CallBack) (long msgnum)) + void (*CallBack) (long, void *), + void *userdata) { int a; @@ -377,7 +378,7 @@ int CtdlForEachMessage(int mode, long ref, || ((mode == MSGS_EQ) && (thismsg == ref)) ) ) { - if (CallBack) CallBack(thismsg); + if (CallBack) CallBack(thismsg, userdata); ++num_processed; } } @@ -448,7 +449,7 @@ void cmd_msgs(char *cmdbuf) CtdlForEachMessage(mode, cm_ref, CC->usersupp.moderation_filter, - NULL, template, simple_listing); + NULL, template, simple_listing, NULL); if (template != NULL) CtdlFreeMessage(template); cprintf("000\n"); } @@ -1442,7 +1443,7 @@ void serialize_message(struct ser_ret *ret, /* return values */ /* * Back end for the ReplicationChecks() function */ -void check_repl(long msgnum) { +void check_repl(long msgnum, void *userdata) { struct CtdlMessage *msg; time_t timestamp = (-1L); @@ -1492,7 +1493,8 @@ int ReplicationChecks(struct CtdlMessage *msg) { memset(template, 0, sizeof(struct CtdlMessage)); template->cm_fields['E'] = strdoop(msg->cm_fields['E']); - CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, template, check_repl); + CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, template, + check_repl, NULL); /* If a newer message exists with the same Extended ID, abort * this save. @@ -2545,7 +2547,7 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ -void CtdlGetSysConfigBackend(long msgnum) { +void CtdlGetSysConfigBackend(long msgnum, void *userdata) { config_msgnum = msgnum; } @@ -2568,7 +2570,7 @@ char *CtdlGetSysConfig(char *sysconfname) { begin_critical_section(S_CONFIG); config_msgnum = (-1L); CtdlForEachMessage(MSGS_LAST, 1, (-127), sysconfname, NULL, - CtdlGetSysConfigBackend); + CtdlGetSysConfigBackend, NULL); msgnum = config_msgnum; end_critical_section(S_CONFIG); diff --git a/citadel/msgbase.h b/citadel/msgbase.h index 8daaaec72..a0a17eb27 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -69,13 +69,14 @@ void cmd_move (char *args); void GetSuppMsgInfo(struct SuppMsgInfo *, long); void PutSuppMsgInfo(struct SuppMsgInfo *); void AdjRefCount(long, int); -void simple_listing(long); +void simple_listing(long, void *); int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template); int CtdlForEachMessage(int mode, long ref, int moderation_level, char *content_type, struct CtdlMessage *compare, - void (*CallBack) (long msgnum) ); + void (*CallBack) (long, void *), + void *userdata); int CtdlDeleteMessages(char *, long, char *); void CtdlWriteObject(char *, char *, char *, struct usersupp *, int, int, unsigned int); diff --git a/citadel/serv_expire.c b/citadel/serv_expire.c index 1918ce958..6cf08d77c 100644 --- a/citadel/serv_expire.c +++ b/citadel/serv_expire.c @@ -533,7 +533,7 @@ void cmd_expi(char *argbuf) { /*****************************************************************************/ -void do_fsck_msg(long msgnum) { +void do_fsck_msg(long msgnum, void *userdata) { struct roomref *ptr; ptr = (struct roomref *)mallok(sizeof(struct roomref)); @@ -545,7 +545,8 @@ void do_fsck_msg(long msgnum) { void do_fsck_room(struct quickroom *qrbuf, void *data) { getroom(&CC->quickroom, qrbuf->QRname); - CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, NULL, do_fsck_msg); + CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, NULL, + do_fsck_msg, NULL); } /* diff --git a/citadel/serv_inetcfg.c b/citadel/serv_inetcfg.c index 101bad90e..bedcd965d 100644 --- a/citadel/serv_inetcfg.c +++ b/citadel/serv_inetcfg.c @@ -94,7 +94,7 @@ int inetcfg_aftersave(struct CtdlMessage *msg) { } -void inetcfg_init_backend(long msgnum) { +void inetcfg_init_backend(long msgnum, void *userdata) { struct CtdlMessage *msg; msg = CtdlFetchMessage(msgnum); @@ -108,7 +108,7 @@ void inetcfg_init_backend(long msgnum) { void inetcfg_init(void) { if (getroom(&CC->quickroom, SYSCONFIGROOM) != 0) return; CtdlForEachMessage(MSGS_LAST, 1, (-127), INTERNETCFG, NULL, - inetcfg_init_backend); + inetcfg_init_backend, NULL); } diff --git a/citadel/serv_moderate.c b/citadel/serv_moderate.c index 77c210798..867584a06 100644 --- a/citadel/serv_moderate.c +++ b/citadel/serv_moderate.c @@ -58,7 +58,7 @@ void cmd_mmod(char *argbuf) { } is_message_in_room = CtdlForEachMessage(MSGS_EQ, msgnum, (-127), - NULL, NULL, NULL); + NULL, NULL, NULL, NULL); if (!is_message_in_room) { cprintf("%d Message %ld is not in this room.\n", ERROR+ILLEGAL_VALUE, msgnum); diff --git a/citadel/serv_network.c b/citadel/serv_network.c index 8ed03aa6f..87bc6f1a3 100644 --- a/citadel/serv_network.c +++ b/citadel/serv_network.c @@ -7,6 +7,14 @@ * */ + +/* FIXME + +there's stuff in here that makes the assumption that /tmp is on the same +filesystem as Citadel, and makes calls to link() on that basis. fix this. + +*/ + #include "sysdep.h" #include #include @@ -93,9 +101,109 @@ void cmd_snet(char *argbuf) { } + + +/* + * Batch up and send all outbound traffic from the current room + */ +void network_spoolout_current_room(void) { + char filename[256]; + char buf[256]; + char instr[256]; + FILE *fp; + long lastsent = 0L; + struct namelist *listrecps = NULL; + /* struct namelist *digestrecps = NULL; */ + struct namelist *nptr; + + assoc_file_name(filename, &CC->quickroom, "netconfigs"); + + fp = fopen(filename, "r"); + if (fp == NULL) { + lprintf(7, "Outbound batch processing skipped for <%s>\n", + CC->quickroom.QRname); + return; + } + + lprintf(5, "Outbound batch processing started for <%s>\n", + CC->quickroom.QRname); + + while (fgets(buf, sizeof buf, fp) != NULL) { + buf[strlen(buf)-1] = 0; + + extract(instr, buf, 0); + if (!strcasecmp(instr, "lastsent")) { + lastsent = extract_long(buf, 1); + } + else if (!strcasecmp(instr, "listrecp")) { + nptr = (struct namelist *) + mallok(sizeof(struct namelist)); + nptr->next = listrecps; + extract(nptr->name, buf, 1); + listrecps = nptr; + } + + + } + fclose(fp); + + + /* Do something useful */ + + + + + + + + /* Now rewrite the config file */ + fp = fopen(filename, "w"); + if (fp == NULL) { + lprintf(1, "ERROR: cannot open %s: %s\n", + filename, strerror(errno)); + } + else { + fprintf(fp, "lastsent|%ld\n", lastsent); + + /* Write out the listrecps while freeing from memory at the + * same time. Am I clever or what? :) + */ + while (listrecps != NULL) { + fprintf(fp, "listrecp|%s\n", listrecps->name); + nptr = listrecps->next; + phree(listrecps); + listrecps = nptr; + } + + fclose(fp); + } + + lprintf(5, "Outbound batch processing finished for <%s>\n", + CC->quickroom.QRname); +} + + + +/* FIXME temporary server command for batch send */ +void cmd_batc(char *argbuf) { + if (CtdlAccessCheck(ac_aide)) return; + + network_spoolout_current_room(); + + cprintf("%d ok\n", OK); +} + + + char *Dynamic_Module_Init(void) { CtdlRegisterProtoHook(cmd_gnet, "GNET", "Get network config"); CtdlRegisterProtoHook(cmd_snet, "SNET", "Get network config"); + + /* FIXME + temporary server command for batch send + */ + CtdlRegisterProtoHook(cmd_batc, "BATC", "send out batch (temp)"); + return "$Id$"; } diff --git a/citadel/serv_network.h b/citadel/serv_network.h index b28b04f64..699e39b50 100644 --- a/citadel/serv_network.h +++ b/citadel/serv_network.h @@ -1,3 +1,6 @@ - +struct namelist { + struct namelist *next; + char name[256]; +}; diff --git a/citadel/serv_pop3.c b/citadel/serv_pop3.c index 2d88dbba3..2827c7cde 100644 --- a/citadel/serv_pop3.c +++ b/citadel/serv_pop3.c @@ -120,7 +120,7 @@ void pop3_user(char *argbuf) { /* * Back end for pop3_grab_mailbox() */ -void pop3_add_message(long msgnum) { +void pop3_add_message(long msgnum, void *userdata) { FILE *fp; lprintf(9, "in pop3_add_message()\n"); @@ -154,7 +154,8 @@ int pop3_grab_mailbox(void) { if (getroom(&CC->quickroom, MAILROOM) != 0) return(-1); /* Load up the messages */ - CtdlForEachMessage(MSGS_ALL, 0L, (-63), NULL, NULL, pop3_add_message); + CtdlForEachMessage(MSGS_ALL, 0L, (-63), NULL, NULL, + pop3_add_message, NULL); /* Figure out which are old and which are new */ CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom); diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 5d0cd0884..4c557a94b 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -1256,7 +1256,7 @@ int smtp_purge_completed_deliveries(char *instr) { * * Called by smtp_do_queue() to handle an individual message. */ -void smtp_do_procmsg(long msgnum) { +void smtp_do_procmsg(long msgnum, void *userdata) { struct CtdlMessage *msg; char *instr = NULL; char *results = NULL; @@ -1447,7 +1447,7 @@ void smtp_do_queue(void) { return; } CtdlForEachMessage(MSGS_ALL, 0L, (-127), - SPOOLMIME, NULL, smtp_do_procmsg); + SPOOLMIME, NULL, smtp_do_procmsg, NULL); lprintf(7, "SMTP: queue run completed\n"); doing_queue = 0; diff --git a/citadel/serv_vandelay.c b/citadel/serv_vandelay.c index 7c5dac0d2..29ee4ecd3 100644 --- a/citadel/serv_vandelay.c +++ b/citadel/serv_vandelay.c @@ -63,7 +63,7 @@ void artv_export_users(void) { } -void artv_export_room_msg(long msgnum) { +void artv_export_room_msg(long msgnum, void *userdata) { cprintf("%ld\n", msgnum); fprintf(artv_global_message_list, "%ld\n", msgnum); } @@ -91,7 +91,7 @@ void artv_export_rooms_backend(struct quickroom *qrbuf, void *data) { * one per line terminated by a 0. */ CtdlForEachMessage(MSGS_ALL, 0L, (-127), NULL, NULL, - artv_export_room_msg); + artv_export_room_msg, NULL); cprintf("0\n"); } diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index 4540de4d5..e7a8e61bd 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -188,7 +188,7 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) { /* * back end function used for callbacks */ -void vcard_gu_backend(long msgnum) { +void vcard_gu_backend(long msgnum, void *userdata) { VC->msgnum = msgnum; } @@ -214,7 +214,7 @@ struct vCard *vcard_get_user(struct usersupp *u) { /* We want the last (and probably only) vcard in this room */ VC->msgnum = (-1); CtdlForEachMessage(MSGS_LAST, 1, (-127), "text/x-vcard", - NULL, vcard_gu_backend); + NULL, vcard_gu_backend, NULL); getroom(&CC->quickroom, hold_rm); /* return to saved room */ if (VC->msgnum < 0L) return vcard_new(); diff --git a/citadel/techdoc/netconfigs.txt b/citadel/techdoc/netconfigs.txt index ba7c19866..16a5613b9 100644 --- a/citadel/techdoc/netconfigs.txt +++ b/citadel/techdoc/netconfigs.txt @@ -20,6 +20,8 @@ we have performed outbound network processing on. Any batch job which sends out messages should do stuff. - INSTRUCTION: foo - SYNTAX: lastsent|0000000 + INSTRUCTION: listrecp + SYNTAX: listrecp|friko@mumjiboolean.com DESCRIPTION: + Defines a recipient to whom all messages in this room should be sent. This +is used for "list serve" applications. -- 2.30.2