]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
IRC: move functions around
authorJānis Rūcis <parasti@gmail.com>
Tue, 30 Mar 2010 20:42:35 +0000 (23:42 +0300)
committerJānis Rūcis <parasti@gmail.com>
Sun, 27 Jun 2010 12:23:20 +0000 (15:23 +0300)
irc.c

diff --git a/irc.c b/irc.c
index 37f9f0cbe2e61badd74ad8a69ca4373fb111304c..ceed28f9d1bcd812070a6e10edb5b73003040c48 100644 (file)
--- a/irc.c
+++ b/irc.c
@@ -3,11 +3,23 @@
 #include "console.h"
 
 static lhnetsocket_t *irc_socket;
+
 static char irc_incoming[1024];
 static char irc_outgoing[1024];
 static int irc_incoming_len;
 static int irc_outgoing_len;
 
+#define IRC_MAX_ARGS 15
+
+typedef struct ircmessage_s
+{
+       char *prefix;
+       char *command;
+       char *args[IRC_MAX_ARGS];
+       int args_num;
+}
+ircmessage_t;
+
 static void IRC_Disconnect(void)
 {
        if (irc_socket)
@@ -64,68 +76,6 @@ static void IRC_AddMessage(const char *message)
        Con_Printf("[IRC] %d bytes waiting to be written\n", irc_outgoing_len);
 }
 
-static const char *IRC_NickFromPlayerName(void)
-{
-       const char prefix[] = "[DP]";
-       const int prefix_len = sizeof (prefix) - 1;
-       char *nick;
-
-       nick = Z_Malloc(prefix_len + strlen(cl_name.string) + 1);
-       memcpy(nick, prefix, prefix_len + 1);
-       SanitizeString(cl_name.string, nick + prefix_len);
-
-       return nick;
-}
-
-static void IRC_Connect_f(void)
-{
-       if (Cmd_Argc() != 2)
-       {
-               Con_Print("ircconnect <address> : connect to an IRC server\n");
-               return;
-       }
-
-       if (IRC_Connect(Cmd_Argv(1)))
-       {
-               const char *nick = IRC_NickFromPlayerName();
-
-               IRC_AddMessage(va("NICK %s", nick));
-               IRC_AddMessage(va("USER %s %s %s :%s", nick, nick, Cmd_Argv(1), nick));
-
-               Z_Free((void *) nick);
-       }
-}
-
-static void IRC_Disconnect_f(void)
-{
-       IRC_Disconnect();
-}
-
-static void IRC_IRC_f(void)
-{
-       if (Cmd_Argc() < 2)
-       {
-               Con_Print("irc <raw IRC message>\n");
-               return;
-       }
-
-       if (irc_socket)
-               IRC_AddMessage(Cmd_Args());
-       else
-               Con_Print("[IRC] Not connected to a server.\n");
-}
-
-#define IRC_MAX_ARGS 15
-
-typedef struct ircmessage_s
-{
-       char *prefix;
-       char *command;
-       char *args[IRC_MAX_ARGS];
-       int args_num;
-}
-ircmessage_t;
-
 static ircmessage_t *IRC_AllocMessage(void)
 {
        ircmessage_t *msg;
@@ -354,6 +304,57 @@ void IRC_Frame(void)
        }
 }
 
+static const char *IRC_NickFromPlayerName(void)
+{
+       const char prefix[] = "[DP]";
+       const int prefix_len = sizeof (prefix) - 1;
+       char *nick;
+
+       nick = Z_Malloc(prefix_len + strlen(cl_name.string) + 1);
+       memcpy(nick, prefix, prefix_len + 1);
+       SanitizeString(cl_name.string, nick + prefix_len);
+
+       return nick;
+}
+
+static void IRC_Connect_f(void)
+{
+       if (Cmd_Argc() != 2)
+       {
+               Con_Print("ircconnect <address> : connect to an IRC server\n");
+               return;
+       }
+
+       if (IRC_Connect(Cmd_Argv(1)))
+       {
+               const char *nick = IRC_NickFromPlayerName();
+
+               IRC_AddMessage(va("NICK %s", nick));
+               IRC_AddMessage(va("USER %s %s %s :%s", nick, nick, Cmd_Argv(1), nick));
+
+               Z_Free((void *) nick);
+       }
+}
+
+static void IRC_Disconnect_f(void)
+{
+       IRC_Disconnect();
+}
+
+static void IRC_IRC_f(void)
+{
+       if (Cmd_Argc() < 2)
+       {
+               Con_Print("irc <raw IRC message>\n");
+               return;
+       }
+
+       if (irc_socket)
+               IRC_AddMessage(Cmd_Args());
+       else
+               Con_Print("[IRC] Not connected to a server.\n");
+}
+
 void IRC_Init(void)
 {
        Cmd_AddCommand("ircconnect", IRC_Connect_f, "connect to an IRC server");