]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_chat.c
mk_module_init.sh now tests to see if echo supports -e and -E
[citadel.git] / citadel / serv_chat.c
index b323dab7a5590a46f2a9efb93afc0fe6bcc11373..a34f7efc390ce2f2032ccc15918657942a8a7307 100644 (file)
@@ -31,9 +31,7 @@
 #include <limits.h>
 #include "citadel.h"
 #include "server.h"
-#include "serv_extensions.h"
 #include "serv_chat.h"
-#include "sysdep_decls.h"
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
 #include "snprintf.h"
 #endif
 
+
+#include "ctdl_module.h"
+
+
+
 struct ChatLine *ChatQueue = NULL;
 int ChatLastMsg = 0;
 
@@ -456,7 +459,7 @@ void cmd_pexp(char *argbuf)
                        cprintf("Message ");
                cprintf("from %s:\n", ptr->sender);
                if (ptr->text != NULL)
-                       memfmout(80, ptr->text, 0, "\n");
+                       memfmout(ptr->text, 0, "\n");
 
                holdptr = ptr->next;
                if (ptr->text != NULL) free(ptr->text);
@@ -486,15 +489,18 @@ void cmd_gexp(char *argbuf) {
        cprintf("%d %d|%ld|%d|%s|%s\n",
                LISTING_FOLLOWS,
                ((ptr->next != NULL) ? 1 : 0),          /* more msgs? */
-               (long)ptr->timestamp,                           /* time sent */
+               (long)ptr->timestamp,                   /* time sent */
                ptr->flags,                             /* flags */
                ptr->sender,                            /* sender of msg */
-               config.c_nodename);                     /* static for now */
+               config.c_nodename                       /* static for now */
+       );
+
        if (ptr->text != NULL) {
-               memfmout(80, ptr->text, 0, "\n");
+               memfmout(ptr->text, 0, "\n");
                if (ptr->text[strlen(ptr->text)-1] != '\n') cprintf("\n");
                free(ptr->text);
-               }
+       }
+
        cprintf("000\n");
        free(ptr);
 }
@@ -554,7 +560,6 @@ void add_xmsg_to_context(struct CitContext *ccptr,
 int send_instant_message(char *lun, char *x_user, char *x_msg)
 {
        int message_sent = 0;           /* number of successful sends */
-
        struct CitContext *ccptr;
        struct ExpressMessage *newmsg;
        char *un;
@@ -564,22 +569,24 @@ int send_instant_message(char *lun, char *x_user, char *x_msg)
                                         */
        struct savelist *sl = NULL;     /* list of rooms to save this page */
        struct savelist *sptr;
-       struct CtdlMessage *logmsg;
+       struct CtdlMessage *logmsg = NULL;
        long msgnum;
 
        if (strlen(x_msg) > 0) {
                msglen = strlen(x_msg) + 4;
                do_send = 1;
-               }
+       }
 
        /* find the target user's context and append the message */
        begin_critical_section(S_SESSION_TABLE);
        for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
 
-               if (ccptr->fake_username[0])    /* <bc> */
+               if (ccptr->fake_username[0]) {
                        un = ccptr->fake_username;
-               else
+               }
+               else {
                        un = ccptr->user.fullname;
+               }
 
                if ( ((!strcasecmp(un, x_user))
                    || (!strcasecmp(x_user, "broadcast")))
@@ -639,7 +646,7 @@ int send_instant_message(char *lun, char *x_user, char *x_msg)
                /* Now save a copy in the global log room, if configured */
                if (strlen(config.c_logpages) > 0) {
                        create_room(config.c_logpages, 3, "", 0, 1, 1, VIEW_BBS);
-                       CtdlSaveMsgPointerInRoom(config.c_logpages, msgnum, 0);
+                       CtdlSaveMsgPointerInRoom(config.c_logpages, msgnum, 0, NULL);
                }
 
                /* Save a copy in each recipient's log room, creating those
@@ -649,7 +656,7 @@ int send_instant_message(char *lun, char *x_user, char *x_msg)
                 */
                while (sl != NULL) {
                        create_room(sl->roomname, 5, "", 0, 1, 1, VIEW_BBS);
-                       CtdlSaveMsgPointerInRoom(sl->roomname, msgnum, 0);
+                       CtdlSaveMsgPointerInRoom(sl->roomname, msgnum, 0, NULL);
                        sptr = sl->next;
                        free(sl);
                        sl = sptr;
@@ -662,14 +669,14 @@ int send_instant_message(char *lun, char *x_user, char *x_msg)
 }
 
 /*
- * send instant messages  <bc>
+ * send instant messages
  */
 void cmd_sexp(char *argbuf)
 {
        int message_sent = 0;
        char x_user[USERNAME_SIZE];
        char x_msg[1024];
-       char *lun;              /* <bc> */
+       char *lun;
        char *x_big_msgbuf = NULL;
 
        if ((!(CC->logged_in)) && (!(CC->internal_pgm))) {
@@ -806,7 +813,7 @@ void cmd_reqt(char *argbuf) {
 
 
 
-char *serv_chat_init(void)
+CTDL_MODULE_INIT(chat)
 {
        CtdlRegisterProtoHook(cmd_chat, "CHAT", "Begin real-time chat");
        CtdlRegisterProtoHook(cmd_pexp, "PEXP", "Poll for instant messages");
@@ -817,6 +824,8 @@ char *serv_chat_init(void)
        CtdlRegisterSessionHook(cmd_gexp_async, EVT_ASYNC);
        CtdlRegisterSessionHook(delete_instant_messages, EVT_STOP);
        CtdlRegisterXmsgHook(send_instant_message, XMSG_PRI_LOCAL);
+
+       /* return our Subversion id for the Log */
        return "$Id$";
 }