From 561766aa347a0f6673e7bbebf7e29a70e456e507 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 7 Sep 1999 01:42:45 +0000 Subject: [PATCH] * cmd_msg3() now uses serialize_message() for its output. All message commands will eventually exist as a "struct CtdlMessage" at some point so that we can install server-side handler hooks. --- citadel/ChangeLog | 6 ++++ citadel/citserver.c | 3 +- citadel/msgbase.c | 67 ++++++++++++++++++++++++------------- citadel/msgbase.h | 41 ++++++++++++++--------- citadel/techdoc/session.txt | 6 ++++ 5 files changed, 82 insertions(+), 41 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 20c4e3263..e67eccb47 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,9 @@ $Log$ +Revision 1.364 1999/09/07 01:42:42 ajc +* cmd_msg3() now uses serialize_message() for its output. All message + commands will eventually exist as a "struct CtdlMessage" at some point + so that we can install server-side handler hooks. + Revision 1.363 1999/09/07 00:04:13 ajc * netproc.c: put outgoing messages into the use table, too -- this prevents locally originated messages from showing up again if a remote system is @@ -1238,3 +1243,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citserver.c b/citadel/citserver.c index d0d5619fd..71b05c360 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -754,6 +754,7 @@ void cmd_ipgm(char *argbuf) } else { cprintf("%d Authentication failed.\n",ERROR); + lprintf(3, "Warning: ipgm authentication failed.\n"); } } @@ -763,7 +764,7 @@ void cmd_ipgm(char *argbuf) */ void cmd_down(void) { if (!CC->logged_in) { - cprintf("%d Not logged in.\n",ERROR+NOT_LOGGED_IN); + cprintf("%d Not logged in.\n", ERROR+NOT_LOGGED_IN); return; } diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 472a2b1dc..00bfd373e 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -898,7 +898,8 @@ void cmd_msg2(char *cmdbuf) void cmd_msg3(char *cmdbuf) { long msgnum; - struct cdbdata *dmsgtext; + struct CtdlMessage *msg; + struct sermsgret smr; if (CC->internal_pgm == 0) { cprintf("%d This command is for internal programs only.\n", @@ -907,15 +908,25 @@ void cmd_msg3(char *cmdbuf) } msgnum = extract_long(cmdbuf, 0); + msg = CtdlFetchMessage(msgnum); + if (msg == NULL) { + cprintf("%d Message %ld not found.\n", + ERROR, msgnum); + return; + } - dmsgtext = cdb_fetch(CDB_MSGMAIN, &msgnum, sizeof(long)); - if (dmsgtext == NULL) { - cprintf("%d Message %ld not found\n", ERROR, msgnum); + serialize_message(&smr, msg); + CtdlFreeMessage(msg); + + if (smr.len == 0) { + cprintf("%d Unable to serialize message\n", + ERROR+INTERNAL_ERROR); + return; } - cprintf("%d %ld\n", BINARY_FOLLOWS, dmsgtext->len); - client_write(dmsgtext->ptr, dmsgtext->len); - cdb_free(dmsgtext); + cprintf("%d %ld\n", BINARY_FOLLOWS, smr.len); + client_write(smr.ser, smr.len); + phree(smr.ser); } @@ -1024,13 +1035,16 @@ void copy_file(char *from, char *to) } - /* - * Serialize a struct CtdlMessage into the format used on disk and network + * Serialize a struct CtdlMessage into the format used on disk and network. + * + * This function returns a "struct sermsgret" (defined in msgbase.h) which + * contains the length of the serialized message and a pointer to the + * serialized message in memory. THE LATTER MUST BE FREED BY THE CALLER. */ -char *serialize_message(struct CtdlMessage *msg) { - char *ser; - size_t len = 0; +void serialize_message(struct sermsgret *ret, /* return values */ + struct CtdlMessage *msg) /* unserialized msg */ +{ size_t wlen; int i; static char *forder = FORDER; @@ -1039,31 +1053,36 @@ char *serialize_message(struct CtdlMessage *msg) { if ((msg->cm_magic) != CTDLMESSAGE_MAGIC) { lprintf(3, "serialize_message() -- self-check failed\n"); - return NULL; + return; } - len = 3; + ret->len = 3; for (i=0; i<26; ++i) if (msg->cm_fields[(int)forder[i]] != NULL) - len = len + strlen(msg->cm_fields[(int)forder[i]]) + 2; + ret->len = ret->len + + strlen(msg->cm_fields[(int)forder[i]]) + 2; lprintf(9, "calling malloc\n"); - ser = mallok(len); - if (ser == NULL) return NULL; + ret->ser = mallok(ret->len); + if (ret->ser == NULL) { + ret->len = 0; + return; + } - ser[0] = 0xFF; - ser[1] = msg->cm_anon_type; - ser[2] = msg->cm_format_type; + ret->ser[0] = 0xFF; + ret->ser[1] = msg->cm_anon_type; + ret->ser[2] = msg->cm_format_type; wlen = 3; lprintf(9, "stuff\n"); for (i=0; i<26; ++i) if (msg->cm_fields[(int)forder[i]] != NULL) { - ser[wlen++] = (char)forder[i]; - strcpy(&ser[wlen], msg->cm_fields[(int)forder[i]]); + ret->ser[wlen++] = (char)forder[i]; + strcpy(&ret->ser[wlen], msg->cm_fields[(int)forder[i]]); wlen = wlen + strlen(msg->cm_fields[(int)forder[i]]) + 1; } - if (len != wlen) lprintf(3, "ERROR: len=%d wlen=%d\n", len, wlen); + if (ret->len != wlen) lprintf(3, "ERROR: len=%d wlen=%d\n", + ret->len, wlen); - return ser; + return; } diff --git a/citadel/msgbase.h b/citadel/msgbase.h index 89aba0586..c54b4a419 100644 --- a/citadel/msgbase.h +++ b/citadel/msgbase.h @@ -1,4 +1,28 @@ /* $Id$ */ + + + +struct sermsgret { + size_t len; + char *ser; +}; + +#define MSGS_ALL 0 +#define MSGS_OLD 1 +#define MSGS_NEW 2 +#define MSGS_FIRST 3 +#define MSGS_LAST 4 +#define MSGS_GT 5 + +struct ma_info { + char prefix[256]; /* Prefix for a multipart/alternative */ + int is_ma; /* Set to 1 if we are using this stuff */ + int did_print; /* One alternative has been displayed */ +}; + + + + int alias (char *name); void get_mm (void); void cmd_msgs (char *cmdbuf); @@ -36,20 +60,5 @@ int CtdlDeleteMessages(char *, long, char *); void CtdlWriteObject(char *, char *, char *, int, int, int); struct CtdlMessage *CtdlFetchMessage(long msgnum); void CtdlFreeMessage(struct CtdlMessage *msg); -char *serialize_message(struct CtdlMessage *msg); - - - - -#define MSGS_ALL 0 -#define MSGS_OLD 1 -#define MSGS_NEW 2 -#define MSGS_FIRST 3 -#define MSGS_LAST 4 -#define MSGS_GT 5 +void serialize_message(struct sermsgret *, struct CtdlMessage *); -struct ma_info { - char prefix[256]; /* Prefix for a multipart/alternative */ - int is_ma; /* Set to 1 if we are using this stuff */ - int did_print; /* One alternative has been displayed */ -}; diff --git a/citadel/techdoc/session.txt b/citadel/techdoc/session.txt index 4daa83974..809ed3a39 100644 --- a/citadel/techdoc/session.txt +++ b/citadel/techdoc/session.txt @@ -1683,6 +1683,12 @@ an "*" in this position to signify the presence of waiting express messages. CICQ (Citadel ICQ metaclient setup) + ** WARNING ** + This command is most likely a temporary one. Citadel will eventually have +more robust functionality for abstract configuration screens, and when that +happens, this command will certainly be migrated there. If you're developing +a client, don't spend a lot of time working on ICQ screens. + If a Citadel server has the ICQ Metaclient installed, this command is used to configure it. It has several usages: -- 2.39.2