Usermode/irc - Fixing some niggling issues
authorJohn Hodge <[email protected]>
Sat, 12 May 2012 12:34:30 +0000 (20:34 +0800)
committerJohn Hodge <[email protected]>
Sat, 12 May 2012 12:34:30 +0000 (20:34 +0800)
Usermode/Applications/irc_src/main.c

index 3f46d15..901e8ac 100644 (file)
@@ -113,10 +113,12 @@ int main(int argc, const char *argv[], const char *envp[])
        \r
        // HACK: Static server entry\r
        // UCC (University [of Western Australia] Computer Club) IRC Server\r
-//     gWindow_Status.Server = Server_Connect( "UCC", "130.95.13.18", 6667 );\r
-       gWindow_Status.Server = Server_Connect( "Freenode", "89.16.176.16", 6667 );\r
+       gWindow_Status.Server = Server_Connect( "UCC", "130.95.13.18", 6667 );\r
+       // Freenode (#osdev)\r
+//     gWindow_Status.Server = Server_Connect( "Freenode", "89.16.176.16", 6667 );\r
 //     gWindow_Status.Server = Server_Connect( "Host", "10.0.2.2", 6667 );\r
-//     gWindow_Status.Server = Server_Connect( "BitlBee", "192.168.1.34", 6667 );\r
+       // Local server\r
+//     gWindow_Status.Server = Server_Connect( "BitlBee", "192.168.1.39", 6667 );\r
        \r
        if( !gWindow_Status.Server )\r
                return -1;\r
@@ -205,6 +207,9 @@ int ParseArguments(int argc, const char *argv[])
        return 0;\r
 }\r
 \r
+/**\r
+ * \brief Handle a line from the prompt\r
+ */\r
 int ParseUserCommand(char *String)\r
 {\r
        if( String[0] == '/' )\r
@@ -519,11 +524,12 @@ void ParseServerLine(tServer *Server, char *Line)
         int    pos = 0;\r
        char    *ident, *cmd;\r
 \r
-       _SysDebug("Server %s: Line = %s", Server->Name, Line);  \r
+       _SysDebug("[%s] %s", Server->Name, Line);       \r
        \r
        // Message?\r
        if( *Line == ':' )\r
        {\r
+               pos ++;\r
                ident = GetValue(Line, &pos);   // Ident (user or server)\r
                cmd = GetValue(Line, &pos);\r
                \r
@@ -547,18 +553,29 @@ void ParseServerLine(tServer *Server, char *Line)
                        \r
                        switch(num)\r
                        {\r
+                       case 332:       // Topic\r
+                               user = message; // Channel\r
+                               message = Line + pos + 1;       // Topic\r
+                               Message_AppendF(Server, MSG_TYPE_SERVER, user, user, "Topic: %s", message);\r
+                               break;\r
+                       case 333:       // Topic set by\r
+                               user = message; // Channel\r
+                               message = GetValue(Line, &pos); // User\r
+                               GetValue(Line, &pos);   // Timestamp\r
+                               Message_AppendF(Server, MSG_TYPE_SERVER, user, user, "Set by %s", message);\r
+                               break;\r
                        case 353:       // /NAMES list\r
                                // <user> = <channel> :list\r
-//                             GetValue(Line, &pos);   // '='\r
+                               // '=' was eaten in and set to message\r
                                user = GetValue(Line, &pos);    // Actually channel\r
                                message = Line + pos + 1;       // List\r
-                               Message_AppendF(Server, MSG_TYPE_SERVER, user, "", "Names: %s", message);\r
+                               Message_AppendF(Server, MSG_TYPE_SERVER, user, user, "Names: %s", message);\r
                                break;\r
                        case 366:       // end of /NAMES list\r
                                // <user> <channel> :msg\r
                                user = message;\r
                                message = Line + pos + 1;\r
-                               Message_Append(Server, MSG_TYPE_SERVER, user, "", message);\r
+                               Message_Append(Server, MSG_TYPE_SERVER, user, user, message);\r
                                break;\r
                        case 372:       // MOTD Data\r
                        case 376:       // MOTD End\r
@@ -597,13 +614,17 @@ void ParseServerLine(tServer *Server, char *Line)
                        else {\r
                                message = GetValue(Line, &pos);\r
                        }\r
+\r
+                       // TODO: Catch when the privmsg is addressed to the user\r
+\r
 //                     Cmd_PRIVMSG(Server, dest, ident, message);\r
+                       *strchr(ident, '!') = '\0';     // Hello SIGSEGV\r
                        Message_Append(Server, MSG_TYPE_STANDARD, ident, dest, message);\r
                }\r
                else if( strcmp(cmd, "JOIN" ) == 0 )\r
                {\r
                        char    *channel;\r
-                       channel = GetValue(Line, &pos) + 1;\r
+                       channel = Line + pos + 1;\r
                        Window_Create(Server, channel);\r
                }\r
                else\r

UCC git Repository :: git.ucc.asn.au