[mw-devel] MW3 r1397 - in trunk/src: . client server

arthur at sucs.org arthur at sucs.org
Fri Oct 2 12:35:45 BST 2015


Author: arthur
Date: 2015-10-02 12:35:44 +0100 (Fri, 02 Oct 2015)
New Revision: 1397

Modified:
   trunk/src/client/talker.c
   trunk/src/ipc.c
   trunk/src/ipc.h
   trunk/src/server/servsock.c
   trunk/src/socket.c
Log:
One message type done (mrod/zod), too many more more to go...


Modified: trunk/src/client/talker.c
===================================================================
--- trunk/src/client/talker.c	2015-09-29 15:28:37 UTC (rev 1396)
+++ trunk/src/client/talker.c	2015-10-02 11:35:44 UTC (rev 1397)
@@ -1178,29 +1178,13 @@
 
 void t_mrod(CommandList *cm, int argc, const char **argv, char *args)
 {
-	char buff[MAXTEXTLENGTH];
-	snprintf(buff,MAXTEXTLENGTH-1,"m");
-	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", "mrod");
+	if (excuse!=NULL && !allspace(excuse))
+		json_addstring(j, "reason", excuse);
 	ipcmsg_json_encode(msg, j);
 	json_decref(j);
 	ipcmsg_transmit(msg);

Modified: trunk/src/ipc.c
===================================================================
--- trunk/src/ipc.c	2015-09-29 15:28:37 UTC (rev 1396)
+++ trunk/src/ipc.c	2015-10-02 11:35:44 UTC (rev 1397)
@@ -156,3 +156,44 @@
 	ipc_check();
 	ipcmsg_send(msg, ipcsock);
 }
+
+const char * ipc_nametype(enum ipc_types msgtype)
+{
+	switch (msgtype) {
+		case IPC_NOOP: return "IPC_NOOP"; break;
+		case IPC_NEWMAIL: return "IPC_NEWMAIL"; break;
+		case IPC_STATUS: return "IPC_STATUS"; break;
+		case IPC_GROUPS: return "IPC_GROUPS"; break;
+		case IPC_REALNAME: return "IPC_REALNAME"; break;
+		case IPC_CONTACT: return "IPC_CONTACT"; break;
+		case IPC_LASTREAD: return "IPC_LASTREAD"; break;
+		case IPC_SPECIAL: return "IPC_SPECIAL"; break;
+		case IPC_TIMEOUT: return "IPC_TIMEOUT"; break;
+		case IPC_USERNAME: return "IPC_USERNAME"; break;
+		case IPC_TEXT: return "IPC_TEXT"; break;
+		case IPC_CHATPRIVS: return "IPC_CHATPRIVS"; break;
+		case IPC_CHATMODE: return "IPC_CHATMODE"; break;
+		case IPC_KICK: return "IPC_KICK"; break;
+		case IPC_PASSWD: return "IPC_PASSWD"; break;
+		case IPC_CHANNEL: return "IPC_CHANNEL"; break;
+		case IPC_WIZ: return "IPC_WIZ"; break;
+		case IPC_GAG: return "IPC_GAG"; break;
+		case IPC_CLEARIGN: return "IPC_CLEARIGN"; break;
+		case IPC_SCRIPTIPC: return "IPC_SCRIPTIPC"; break;
+		case IPC_SCRIPTRPC: return "IPC_SCRIPTRPC"; break;
+		case IPC_CHECKONOFF: return "IPC_CHECKONOFF"; break;
+		case IPC_PROTLEVEL: return "IPC_PROTLEVEL"; break;
+		case IPC_PROTPOWER: return "IPC_PROTPOWER"; break;
+		case IPC_DOING: return "IPC_DOING"; break;
+		case IPC_HELLO: return "IPC_HELLO"; break;
+		case IPC_UPTIME: return "IPC_UPTIME"; break;
+		case IPC_SAYTOROOM: return "IPC_SAYTOROOM"; break;
+		case IPC_SAYTOUSER: return "IPC_SAYTOUSER"; break;
+		case IPC_SAYTOALL: return "IPC_SAYTOALL"; break;
+		case IPC_TALKERROR: return "IPC_TALKERROR"; break;
+		case IPC_REPLAY: return "IPC_REPLAY"; break;
+		case IPC_EVENT: return "IPC_EVENT"; break;
+		case IPC_ACTION: return "IPC_ACTION"; break;
+	}
+	return "IPC_Unknown";
+}

Modified: trunk/src/ipc.h
===================================================================
--- trunk/src/ipc.h	2015-09-29 15:28:37 UTC (rev 1396)
+++ trunk/src/ipc.h	2015-10-02 11:35:44 UTC (rev 1397)
@@ -70,5 +70,6 @@
 unsigned int ipc_send_to_all(enum ipc_types msgtype, const char * data);
 void ipcmsg_transmit(ipc_message_t * msg);
 int msg_queue(ipc_message_t *msg, ipc_connection_t *conn);
+const char * ipc_nametype(enum ipc_types msgtype);
 
 #endif

Modified: trunk/src/server/servsock.c
===================================================================
--- trunk/src/server/servsock.c	2015-09-29 15:28:37 UTC (rev 1396)
+++ trunk/src/server/servsock.c	2015-10-02 11:35:44 UTC (rev 1397)
@@ -355,7 +355,7 @@
 	}
 
 	/* send message to everyone (unless this room is soundproof) */
-	if (msg->head.type == IPC_SAYTOALL ) {
+	if (msg->head.type == IPC_SAYTOALL) {
 		/* the sender */
 		int users_fd = userdb_open(O_RDONLY);
 		struct person from;
@@ -395,12 +395,13 @@
 
 	/* it was a broadcast message */
 	if (msg->head.dst == SYSTEM_USER) {
-		printf("Broadcast message to system user\n");
+		printf("Broadcast message to system user %s\n", ipc_nametype(msg->head.type));
 		msg_attach_to_all(msg);
 		return;
 	}
 
 	/* otherwise redistribute this message to intended target */
+	printf("Unhandled direct-to-user command %s\n", ipc_nametype(msg->head.type));
 	msg_attach_to_userid(msg, msg->head.dst);
 	ipcmsg_destroy(msg);
 }

Modified: trunk/src/socket.c
===================================================================
--- trunk/src/socket.c	2015-09-29 15:28:37 UTC (rev 1396)
+++ trunk/src/socket.c	2015-10-02 11:35:44 UTC (rev 1397)
@@ -9,6 +9,7 @@
 
 #include "socket.h"
 #include "util.h"
+#include "ipc.h"
 
 /* create an empty message */
 ipc_message_t * ipcmsg_create(uint32_t type, uint32_t src)
@@ -35,7 +36,7 @@
 {
 	if (intro != NULL) printf("%s: ", intro);
 	if (msg->head.type < 255)
-		printf("src: %X, dst: %X, Type: %4d, len=%d\n", msg->head.src, msg->head.dst, msg->head.type, msg->head.len);
+		printf("src: %X, dst: %X, Type: %s, len=%d\n", msg->head.src, msg->head.dst, ipc_nametype(msg->head.type), msg->head.len);
 	else
 		printf("src: %X, dst: %X, Type: '%4.4s', len=%d\n", msg->head.src, msg->head.dst, (char *)&msg->head.type, msg->head.len);
 }




More information about the mw-devel mailing list