$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.
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
+
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);
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",
-void simple_listing(long msgnum)
+void simple_listing(long msgnum, void *userdata)
{
cprintf("%ld\n", msgnum);
}
int moderation_level,
char *content_type,
struct CtdlMessage *compare,
- void (*CallBack) (long msgnum))
+ void (*CallBack) (long, void *),
+ void *userdata)
{
int a;
|| ((mode == MSGS_EQ) && (thismsg == ref))
)
) {
- if (CallBack) CallBack(thismsg);
+ if (CallBack) CallBack(thismsg, userdata);
++num_processed;
}
}
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");
}
/*
* 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);
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.
-void CtdlGetSysConfigBackend(long msgnum) {
+void CtdlGetSysConfigBackend(long msgnum, void *userdata) {
config_msgnum = msgnum;
}
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);
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);
/*****************************************************************************/
-void do_fsck_msg(long msgnum) {
+void do_fsck_msg(long msgnum, void *userdata) {
struct roomref *ptr;
ptr = (struct roomref *)mallok(sizeof(struct roomref));
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);
}
/*
}
-void inetcfg_init_backend(long msgnum) {
+void inetcfg_init_backend(long msgnum, void *userdata) {
struct CtdlMessage *msg;
msg = CtdlFetchMessage(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);
}
}
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);
*
*/
+
+/* 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 <stdlib.h>
#include <unistd.h>
}
+
+
+/*
+ * 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$";
}
-
+struct namelist {
+ struct namelist *next;
+ char name[256];
+};
/*
* 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");
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);
*
* 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;
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;
}
-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);
}
* 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");
}
/*
* back end function used for callbacks
*/
-void vcard_gu_backend(long msgnum) {
+void vcard_gu_backend(long msgnum, void *userdata) {
VC->msgnum = msgnum;
}
/* 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();
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.