Back to index

citadel  8.12
Functions
serv_instmsg.h File Reference
#include "ctdl_module.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void ChatUnloadingTest (void)
void allwrite (char *cmdbuf, int flag, char *username)
CitContextfind_context (char **unstr)
void cmd_pexp (char *argbuf)
void cmd_sexp (char *argbuf)
void delete_instant_messages (void)
void cmd_gexp (char *)
int send_instant_message (char *, char *, char *, char *)

Function Documentation

void allwrite ( char *  cmdbuf,
int  flag,
char *  username 
)
void ChatUnloadingTest ( void  )
void cmd_gexp ( char *  )

Definition at line 173 of file serv_instmsg.c.

                            {
       struct ExpressMessage *ptr;

       if (CC->FirstExpressMessage == NULL) {
              cprintf("%d No instant messages waiting.\n", ERROR + MESSAGE_NOT_FOUND);
              return;
       }

       begin_critical_section(S_SESSION_TABLE);
       ptr = CC->FirstExpressMessage;
       CC->FirstExpressMessage = CC->FirstExpressMessage->next;
       end_critical_section(S_SESSION_TABLE);

       cprintf("%d %d|%ld|%d|%s|%s|%s\n",
              LISTING_FOLLOWS,
              ((ptr->next != NULL) ? 1 : 0),            /* more msgs? */
              (long)ptr->timestamp,                     /* time sent */
              ptr->flags,                        /* flags */
              ptr->sender,                       /* sender of msg */
              config.c_nodename,                 /* static for now (and possibly deprecated) */
              ptr->sender_email                  /* email or jid of sender */
       );

       if (ptr->text != NULL) {
              memfmout(ptr->text, "\n");
              free(ptr->text);
       }

       cprintf("000\n");
       free(ptr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cmd_pexp ( char *  argbuf)
void cmd_sexp ( char *  argbuf)

Definition at line 309 of file serv_instmsg.c.

{
       int message_sent = 0;
       char x_user[USERNAME_SIZE];
       char x_msg[1024];
       char *lun;
       char *lem;
       char *x_big_msgbuf = NULL;

       if ((!(CC->logged_in)) && (!(CC->internal_pgm))) {
              cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
              return;
       }
       if (CC->fake_username[0])
              lun = CC->fake_username;
       else
              lun = CC->user.fullname;

       lem = CC->cs_inet_email;

       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);
              return;
       }
       if ((!strcasecmp(x_user, "broadcast")) && (CC->user.axlevel < AxAideU)) {
              cprintf("%d Higher access required to send a broadcast.\n",
                     ERROR + HIGHER_ACCESS_REQUIRED);
              return;
       }
       /* This loop handles text-transfer pages */
       if (!strcmp(x_msg, "-")) {
              message_sent = PerformXmsgHooks(lun, lem, x_user, "");
              if (message_sent == 0) {
                     if (CtdlGetUser(NULL, x_user))
                            cprintf("%d '%s' does not exist.\n",
                                          ERROR + NO_SUCH_USER, x_user);
                     else
                            cprintf("%d '%s' is not logged in "
                                          "or is not accepting pages.\n",
                                          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_getln(x_msg, sizeof x_msg) >= 0 && strcmp(x_msg, "000")) {
                     x_big_msgbuf = realloc(x_big_msgbuf,
                            strlen(x_big_msgbuf) + strlen(x_msg) + 4);
                     if (!IsEmptyStr(x_big_msgbuf))
                        if (x_big_msgbuf[strlen(x_big_msgbuf)] != '\n')
                            strcat(x_big_msgbuf, "\n");
                     strcat(x_big_msgbuf, x_msg);
              }
              PerformXmsgHooks(lun, lem, x_user, x_big_msgbuf);
              free(x_big_msgbuf);

              /* This loop handles inline pages */
       } else {
              message_sent = PerformXmsgHooks(lun, lem, x_user, x_msg);

              if (message_sent > 0) {
                     if (!IsEmptyStr(x_msg))
                            cprintf("%d Message sent", CIT_OK);
                     else
                            cprintf("%d Ok to send message", CIT_OK);
                     if (message_sent > 1)
                            cprintf(" to %d users", message_sent);
                     cprintf(".\n");
              } else {
                     if (CtdlGetUser(NULL, x_user))
                            cprintf("%d '%s' does not exist.\n",
                                          ERROR + NO_SUCH_USER, x_user);
                     else
                            cprintf("%d '%s' is not logged in "
                                          "or is not accepting pages.\n",
                                          ERROR + RESOURCE_NOT_OPEN, x_user);
              }


       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void delete_instant_messages ( void  )

Definition at line 154 of file serv_instmsg.c.

                                   {
       struct ExpressMessage *ptr;

       begin_critical_section(S_SESSION_TABLE);
       while (CC->FirstExpressMessage != NULL) {
              ptr = CC->FirstExpressMessage->next;
              if (CC->FirstExpressMessage->text != NULL)
                     free(CC->FirstExpressMessage->text);
              free(CC->FirstExpressMessage);
              CC->FirstExpressMessage = ptr;
       }
       end_critical_section(S_SESSION_TABLE);
}

Here is the call graph for this function:

Here is the caller graph for this function:

CitContext* find_context ( char **  unstr)
int send_instant_message ( char *  ,
char *  ,
char *  ,
char *   
)

Definition at line 251 of file serv_instmsg.c.

{
       int message_sent = 0;              /* number of successful sends */
       struct CitContext *ccptr;
       struct ExpressMessage *newmsg = NULL;
       char *un;
       int do_send = 0;            /* 1 = send message; 0 = only check for valid recipient */
       static int serial_number = 0;      /* this keeps messages from getting logged twice */

       if (strlen(x_msg) > 0) {
              do_send = 1;
       }

       /* find the target user's context and append the message */
       begin_critical_section(S_SESSION_TABLE);
       ++serial_number;
       for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {

              if (ccptr->fake_username[0]) {
                     un = ccptr->fake_username;
              }
              else {
                     un = ccptr->user.fullname;
              }

              if ( ((!strcasecmp(un, x_user))
                  || (!strcasecmp(x_user, "broadcast")))
                  && (ccptr->can_receive_im)
                  && ((ccptr->disable_exp == 0)
                  || (CC->user.axlevel >= AxAideU)) ) {
                     if (do_send) {
                            newmsg = (struct ExpressMessage *) malloc(sizeof (struct ExpressMessage));
                            memset(newmsg, 0, sizeof (struct ExpressMessage));
                            time(&(newmsg->timestamp));
                            safestrncpy(newmsg->sender, lun, sizeof newmsg->sender);
                            safestrncpy(newmsg->sender_email, lem, sizeof newmsg->sender_email);
                            if (!strcasecmp(x_user, "broadcast")) {
                                   newmsg->flags |= EM_BROADCAST;
                            }
                            newmsg->text = strdup(x_msg);

                            add_xmsg_to_context(ccptr, newmsg);

                            /* and log it ... */
                            if (ccptr != CC) {
                                   log_instant_message(CC, ccptr, newmsg->text, serial_number);
                            }
                     }
                     ++message_sent;
              }
       }
       end_critical_section(S_SESSION_TABLE);
       return (message_sent);
}

Here is the call graph for this function:

Here is the caller graph for this function: