Loading src/client/incoming.c +0 −3 Original line number Diff line number Diff line Loading @@ -650,9 +650,6 @@ static void display_content(ipc_message_t *msg) asprintf(&excuse, "%s gives the reason \"%s\".", whom, reason); } force_text(msg, excuse, whom); } else { force_text(msg, "They didn't say why...\n", whom); printf("\n\nraw: %s\n\n", msg->body); } } else { printf("Unknown message type %4.4s", (char *)&msg->head.type); Loading src/client/talker.c +32 −54 Original line number Diff line number Diff line Loading @@ -1147,24 +1147,16 @@ void t_unignore(CommandList *cm, int argc, const char **argv, char *args) void t_zod(CommandList *cm, int argc, const char **argv, char *args) { char buff[MAXTEXTLENGTH]; snprintf(buff,MAXTEXTLENGTH-1,"z"); if (args != NULL) { char *tmp, *qtmp; tmp = remove_first_word(args); if (tmp!=NULL && !allspace(tmp)) { qtmp = quotetext(tmp); strncat(buff, "r", MAXTEXTLENGTH - 2); strncat(buff, qtmp, MAXTEXTLENGTH - strlen(buff) - 1); free(qtmp); } else strncat(buff, "-", MAXTEXTLENGTH - 2); SAFE_FREE(tmp); } else strncat(buff, "-", MAXTEXTLENGTH - 2); ipc_send_to_username(argv[1], IPC_KICK, buff); AUTOFREE_BUFFER excuse = remove_first_word(args); ipc_message_t * msg = ipcmsg_create(IPC_ACTION, userposn); json_t * j = json_init(NULL); json_addstring(j, "target", argv[1]); json_addstring(j, "type", "zod"); if (excuse!=NULL && !allspace(excuse)) json_addstring(j, "reason", excuse); ipcmsg_json_encode(msg, j); json_decref(j); ipcmsg_transmit(msg); } void t_mrod(CommandList *cm, int argc, const char **argv, char *args) Loading @@ -1183,46 +1175,32 @@ void t_mrod(CommandList *cm, int argc, const char **argv, char *args) void t_kick(CommandList *cm, int argc, const char **argv, char *args) { char buff[MAXTEXTLENGTH]; snprintf(buff,MAXTEXTLENGTH-1,"k"); if (args != NULL) { char *tmp, *qtmp; tmp = remove_first_word(args); if (tmp!=NULL && !allspace(tmp)) { qtmp = quotetext(tmp); strncat(buff, "r", MAXTEXTLENGTH - 2); strncat(buff, qtmp, MAXTEXTLENGTH - strlen(buff) - 1); free(qtmp); } else strncat(buff, "-", MAXTEXTLENGTH - 2); SAFE_FREE(tmp); } else strncat(buff, "-", MAXTEXTLENGTH - 2); ipc_send_to_username(argv[1], IPC_KICK, buff); AUTOFREE_BUFFER excuse = remove_first_word(args); ipc_message_t * msg = ipcmsg_create(IPC_ACTION, userposn); json_t * j = json_init(NULL); json_addstring(j, "target", argv[1]); json_addstring(j, "type", "zod"); json_addstring(j, "admin", "yes"); if (excuse!=NULL && !allspace(excuse)) json_addstring(j, "reason", excuse); ipcmsg_json_encode(msg, j); json_decref(j); ipcmsg_transmit(msg); } void t_remove(CommandList *cm, int argc, const char **argv, char *args) { char buff[MAXTEXTLENGTH]; snprintf(buff,MAXTEXTLENGTH-1,"r"); if (args != NULL) { char *tmp, *qtmp; tmp = remove_first_word(args); if (tmp!=NULL && !allspace(tmp)) { qtmp = quotetext(tmp); strncat(buff, "r", MAXTEXTLENGTH - 2); strncat(buff, qtmp, MAXTEXTLENGTH - strlen(buff) - 1); free(qtmp); } else strncat(buff, "-", MAXTEXTLENGTH - 2); SAFE_FREE(tmp); } else strncat(buff, "-", MAXTEXTLENGTH - 2); ipc_send_to_username(argv[1], IPC_KICK, buff); AUTOFREE_BUFFER excuse = remove_first_word(args); ipc_message_t * msg = ipcmsg_create(IPC_ACTION, userposn); json_t * j = json_init(NULL); json_addstring(j, "target", argv[1]); json_addstring(j, "type", "mrodod"); json_addstring(j, "admin", "yes"); if (excuse!=NULL && !allspace(excuse)) json_addstring(j, "reason", excuse); ipcmsg_json_encode(msg, j); json_decref(j); ipcmsg_transmit(msg); } void t_raw(CommandList *cm, int argc, const char **argv, char *args) Loading src/server/actions.c +7 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <rooms.h> #include <talker_privs.h> #include <ipc.h> #include <perms.h> #include "servsock.h" #include "replay.h" Loading @@ -39,6 +40,7 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg) const char *command = json_getstring(j, "type"); const char *victim_username = json_getstring(j, "target"); const char *reason = json_getstring(j, "reason"); const char *admin = json_getstring(j, "admin"); if (command == NULL || victim_username == NULL) { send_error(conn, msg, "Invalid server command syntax"); Loading Loading @@ -70,6 +72,11 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg) /* attacker was stronger, success */ if (prot_at >= prot_vi) success = 1; /* an admin can ask to ignore protection modes */ if (admin!=NULL && strcasecmp(admin, "yes")==0 && u_god(attacker.status)) { success = 1; } if (strcasecmp(command, "mrod")==0) { // tell the world ipc_message_t * event = ipcmsg_create(IPC_EVENT, msg->head.src); Loading @@ -88,10 +95,8 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg) if (reason != NULL) { asprintf(&buff,"mr%s", reason); json_addstring(ej, "reason", reason); printf("MROD set reason '%s'\n", reason); } else { asprintf(&buff,"m-"); printf("MROD with no reason\n"); } ipc_message_t *update = ipcmsg_create(IPC_KICK, msg->head.src); ipcmsg_destination(update, toid); Loading src/server/servsock.c +7 −1 Original line number Diff line number Diff line Loading @@ -431,6 +431,9 @@ void msg_attach_to_channel(ipc_message_t *msg, int channel, const char * exclude /* have we been told to exclude someone in this room */ if (exclude!=NULL && strcasecmp(exclude, user.name)==0) continue; /* person not on talker, just skip them */ if (!cm_flags(user.chatmode, CM_ONCHAT, CM_MODE_ALL)) continue; /* room matches, send them a copy */ if (user.room == msg->head.dst) { msg_attach_to_pid(msg, who.pid); Loading Loading @@ -487,6 +490,9 @@ void msg_attach_to_all(ipc_message_t *msg) lseek(users_fd, who.posn, SEEK_SET); if (read(users_fd, &user, sizeof(user)) <= 0) continue; /* person not on talker, just skip them */ if (!cm_flags(user.chatmode, CM_ONCHAT, CM_MODE_ALL)) continue; msg_attach_to_pid(msg, who.pid); printf("Broadcast to %s in %d\n", user.name, user.room); } Loading Loading @@ -561,7 +567,7 @@ void msg_attach(ipc_message_t *msg, ipc_connection_t *conn) **/ void msg_apply_gag(struct person * from, ipc_message_t * msg, const char * field) { char * newtext = NULL; AUTOFREE_BUFFER newtext = NULL; json_t * j = json_init(msg); const char * text = json_getstring(j, field); Loading Loading
src/client/incoming.c +0 −3 Original line number Diff line number Diff line Loading @@ -650,9 +650,6 @@ static void display_content(ipc_message_t *msg) asprintf(&excuse, "%s gives the reason \"%s\".", whom, reason); } force_text(msg, excuse, whom); } else { force_text(msg, "They didn't say why...\n", whom); printf("\n\nraw: %s\n\n", msg->body); } } else { printf("Unknown message type %4.4s", (char *)&msg->head.type); Loading
src/client/talker.c +32 −54 Original line number Diff line number Diff line Loading @@ -1147,24 +1147,16 @@ void t_unignore(CommandList *cm, int argc, const char **argv, char *args) void t_zod(CommandList *cm, int argc, const char **argv, char *args) { char buff[MAXTEXTLENGTH]; snprintf(buff,MAXTEXTLENGTH-1,"z"); if (args != NULL) { char *tmp, *qtmp; tmp = remove_first_word(args); if (tmp!=NULL && !allspace(tmp)) { qtmp = quotetext(tmp); strncat(buff, "r", MAXTEXTLENGTH - 2); strncat(buff, qtmp, MAXTEXTLENGTH - strlen(buff) - 1); free(qtmp); } else strncat(buff, "-", MAXTEXTLENGTH - 2); SAFE_FREE(tmp); } else strncat(buff, "-", MAXTEXTLENGTH - 2); ipc_send_to_username(argv[1], IPC_KICK, buff); AUTOFREE_BUFFER excuse = remove_first_word(args); ipc_message_t * msg = ipcmsg_create(IPC_ACTION, userposn); json_t * j = json_init(NULL); json_addstring(j, "target", argv[1]); json_addstring(j, "type", "zod"); if (excuse!=NULL && !allspace(excuse)) json_addstring(j, "reason", excuse); ipcmsg_json_encode(msg, j); json_decref(j); ipcmsg_transmit(msg); } void t_mrod(CommandList *cm, int argc, const char **argv, char *args) Loading @@ -1183,46 +1175,32 @@ void t_mrod(CommandList *cm, int argc, const char **argv, char *args) void t_kick(CommandList *cm, int argc, const char **argv, char *args) { char buff[MAXTEXTLENGTH]; snprintf(buff,MAXTEXTLENGTH-1,"k"); if (args != NULL) { char *tmp, *qtmp; tmp = remove_first_word(args); if (tmp!=NULL && !allspace(tmp)) { qtmp = quotetext(tmp); strncat(buff, "r", MAXTEXTLENGTH - 2); strncat(buff, qtmp, MAXTEXTLENGTH - strlen(buff) - 1); free(qtmp); } else strncat(buff, "-", MAXTEXTLENGTH - 2); SAFE_FREE(tmp); } else strncat(buff, "-", MAXTEXTLENGTH - 2); ipc_send_to_username(argv[1], IPC_KICK, buff); AUTOFREE_BUFFER excuse = remove_first_word(args); ipc_message_t * msg = ipcmsg_create(IPC_ACTION, userposn); json_t * j = json_init(NULL); json_addstring(j, "target", argv[1]); json_addstring(j, "type", "zod"); json_addstring(j, "admin", "yes"); if (excuse!=NULL && !allspace(excuse)) json_addstring(j, "reason", excuse); ipcmsg_json_encode(msg, j); json_decref(j); ipcmsg_transmit(msg); } void t_remove(CommandList *cm, int argc, const char **argv, char *args) { char buff[MAXTEXTLENGTH]; snprintf(buff,MAXTEXTLENGTH-1,"r"); if (args != NULL) { char *tmp, *qtmp; tmp = remove_first_word(args); if (tmp!=NULL && !allspace(tmp)) { qtmp = quotetext(tmp); strncat(buff, "r", MAXTEXTLENGTH - 2); strncat(buff, qtmp, MAXTEXTLENGTH - strlen(buff) - 1); free(qtmp); } else strncat(buff, "-", MAXTEXTLENGTH - 2); SAFE_FREE(tmp); } else strncat(buff, "-", MAXTEXTLENGTH - 2); ipc_send_to_username(argv[1], IPC_KICK, buff); AUTOFREE_BUFFER excuse = remove_first_word(args); ipc_message_t * msg = ipcmsg_create(IPC_ACTION, userposn); json_t * j = json_init(NULL); json_addstring(j, "target", argv[1]); json_addstring(j, "type", "mrodod"); json_addstring(j, "admin", "yes"); if (excuse!=NULL && !allspace(excuse)) json_addstring(j, "reason", excuse); ipcmsg_json_encode(msg, j); json_decref(j); ipcmsg_transmit(msg); } void t_raw(CommandList *cm, int argc, const char **argv, char *args) Loading
src/server/actions.c +7 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <rooms.h> #include <talker_privs.h> #include <ipc.h> #include <perms.h> #include "servsock.h" #include "replay.h" Loading @@ -39,6 +40,7 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg) const char *command = json_getstring(j, "type"); const char *victim_username = json_getstring(j, "target"); const char *reason = json_getstring(j, "reason"); const char *admin = json_getstring(j, "admin"); if (command == NULL || victim_username == NULL) { send_error(conn, msg, "Invalid server command syntax"); Loading Loading @@ -70,6 +72,11 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg) /* attacker was stronger, success */ if (prot_at >= prot_vi) success = 1; /* an admin can ask to ignore protection modes */ if (admin!=NULL && strcasecmp(admin, "yes")==0 && u_god(attacker.status)) { success = 1; } if (strcasecmp(command, "mrod")==0) { // tell the world ipc_message_t * event = ipcmsg_create(IPC_EVENT, msg->head.src); Loading @@ -88,10 +95,8 @@ void accept_action(ipc_connection_t *conn, ipc_message_t *msg) if (reason != NULL) { asprintf(&buff,"mr%s", reason); json_addstring(ej, "reason", reason); printf("MROD set reason '%s'\n", reason); } else { asprintf(&buff,"m-"); printf("MROD with no reason\n"); } ipc_message_t *update = ipcmsg_create(IPC_KICK, msg->head.src); ipcmsg_destination(update, toid); Loading
src/server/servsock.c +7 −1 Original line number Diff line number Diff line Loading @@ -431,6 +431,9 @@ void msg_attach_to_channel(ipc_message_t *msg, int channel, const char * exclude /* have we been told to exclude someone in this room */ if (exclude!=NULL && strcasecmp(exclude, user.name)==0) continue; /* person not on talker, just skip them */ if (!cm_flags(user.chatmode, CM_ONCHAT, CM_MODE_ALL)) continue; /* room matches, send them a copy */ if (user.room == msg->head.dst) { msg_attach_to_pid(msg, who.pid); Loading Loading @@ -487,6 +490,9 @@ void msg_attach_to_all(ipc_message_t *msg) lseek(users_fd, who.posn, SEEK_SET); if (read(users_fd, &user, sizeof(user)) <= 0) continue; /* person not on talker, just skip them */ if (!cm_flags(user.chatmode, CM_ONCHAT, CM_MODE_ALL)) continue; msg_attach_to_pid(msg, who.pid); printf("Broadcast to %s in %d\n", user.name, user.room); } Loading Loading @@ -561,7 +567,7 @@ void msg_attach(ipc_message_t *msg, ipc_connection_t *conn) **/ void msg_apply_gag(struct person * from, ipc_message_t * msg, const char * field) { char * newtext = NULL; AUTOFREE_BUFFER newtext = NULL; json_t * j = json_init(msg); const char * text = json_getstring(j, field); Loading