]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_chat.c
* added a comment infront of the svn modifieable returns. Now it will be me listed...
[citadel.git] / citadel / serv_chat.c
index 89d715faa6d50103990329fa564e45e4a788d5eb..765d486d9a51d347d71f142a4b3f5d5f0034afac 100644 (file)
@@ -249,6 +249,7 @@ void cmd_chat(char *argbuf)
        CC->cs_flags = CC->cs_flags | CS_CHAT;
        cprintf("%d Entering chat mode (type '/help' for available commands)\n",
                START_CHAT_MODE);
+       unbuffer_output();
 
        MyLastMsg = ChatLastMsg;
 
@@ -318,7 +319,7 @@ void cmd_chat(char *argbuf)
                                        if (is_room_aide()) {
                                                cprintf(":|/kick   (kick another user out of this room) \n");
                                        }
-                                       cprintf(":|/quit   (return to the BBS) \n");
+                                       cprintf(":|/quit   (exit from this chat) \n");
                                        cprintf(":|\n");
                                        ok_cmd = 1;
                                }
@@ -455,7 +456,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);
@@ -485,15 +486,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);
 }
@@ -553,7 +557,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;
@@ -563,22 +566,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")))
@@ -632,13 +637,13 @@ int send_instant_message(char *lun, char *x_user, char *x_msg)
                /* Save a copy of the message in the sender's log room,
                 * creating the room if necessary.
                 */
-               create_room(PAGELOGROOM, 4, "", 0, 1, 0);
+               create_room(PAGELOGROOM, 4, "", 0, 1, 0, VIEW_BBS);
                msgnum = CtdlSubmitMsg(logmsg, NULL, PAGELOGROOM);
 
                /* 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);
-                       CtdlSaveMsgPointerInRoom(config.c_logpages, msgnum, 0);
+                       create_room(config.c_logpages, 3, "", 0, 1, 1, VIEW_BBS);
+                       CtdlSaveMsgPointerInRoom(config.c_logpages, msgnum, 0, NULL);
                }
 
                /* Save a copy in each recipient's log room, creating those
@@ -647,8 +652,8 @@ int send_instant_message(char *lun, char *x_user, char *x_msg)
                 * but we've already supplied the namespace prefix.
                 */
                while (sl != NULL) {
-                       create_room(sl->roomname, 5, "", 0, 1, 1);
-                       CtdlSaveMsgPointerInRoom(sl->roomname, msgnum, 0);
+                       create_room(sl->roomname, 5, "", 0, 1, 1, VIEW_BBS);
+                       CtdlSaveMsgPointerInRoom(sl->roomname, msgnum, 0, NULL);
                        sptr = sl->next;
                        free(sl);
                        sl = sptr;
@@ -661,14 +666,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[SIZ];
-       char x_msg[SIZ];
-       char *lun;              /* <bc> */
+       char x_user[USERNAME_SIZE];
+       char x_msg[1024];
+       char *lun;
        char *x_big_msgbuf = NULL;
 
        if ((!(CC->logged_in)) && (!(CC->internal_pgm))) {
@@ -680,9 +685,8 @@ void cmd_sexp(char *argbuf)
        else
                lun = CC->user.fullname;
 
-       extract(x_user, argbuf, 0);
-
-       extract(x_msg, argbuf, 1);
+       extract_token(x_user, argbuf, 0, '|', sizeof x_user);
+       extract_token(x_msg, argbuf, 1, '|', sizeof x_msg);
 
        if (!x_user[0]) {
                cprintf("%d You were not previously paged.\n", ERROR + NO_SUCH_USER);
@@ -706,11 +710,13 @@ void cmd_sexp(char *argbuf)
                                                ERROR + RESOURCE_NOT_OPEN, x_user);
                        return;
                }
+               unbuffer_output();
                cprintf("%d Transmit message (will deliver to %d users)\n",
                        SEND_LISTING, message_sent);
                x_big_msgbuf = malloc(SIZ);
                memset(x_big_msgbuf, 0, SIZ);
-               while (client_gets(x_msg), strcmp(x_msg, "000")) {
+               while (client_getln(x_msg, sizeof x_msg),
+                     strcmp(x_msg, "000")) {
                        x_big_msgbuf = realloc(x_big_msgbuf,
                               strlen(x_big_msgbuf) + strlen(x_msg) + 4);
                        if (strlen(x_big_msgbuf) > 0)
@@ -815,6 +821,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$";
 }