*push*
authorpk910 <philipp@zoelle1.de>
Tue, 9 Aug 2011 23:52:32 +0000 (01:52 +0200)
committerpk910 <philipp@zoelle1.de>
Tue, 9 Aug 2011 23:52:32 +0000 (01:52 +0200)
ClientSocket.c
ClientSocket.h
IRCParser.c
IRCParser.h
main.h

index 5c81c040e07390ebc65a82918b1720f78944a9b2..7ca76d2eedce63bcece32cd5c7dfa25ceabc52f9 100644 (file)
@@ -81,9 +81,9 @@ int connect_socket(struct ClientSocket *client) {
         write_socket(client, sendBuf, len);
     }
     len = sprintf(sendBuf, "USER %s 0 0 :%s\n", client->user->ident, client->user->realname);
-    write_socket(client, &sendBuf, len);
+    write_socket(client, sendBuf, len);
     len = sprintf(sendBuf, "NICK %s\n", client->user->nick);
-    write_socket(client, &sendBuf, len);
+    write_socket(client, sendBuf, len);
 
     client->sock = sock;
     client->flags |= SOCKET_FLAG_CONNECTED;
@@ -155,7 +155,7 @@ void socket_loop(int timeout_seconds) {
                 //error
                 sock->flags &= ~(SOCKET_FLAG_CONNECTED | SOCKET_FLAG_READY);
             } else {
-                int used = parse_lines(sock->buffer, sock->bufferpos);
+                int used = parse_lines(sock, sock->buffer, sock->bufferpos);
                 if(used == sock->bufferpos + 1) {
                     //used all bytes so just reset the bufferpos
                     sock->bufferpos = 0;
index dd8df540a02e437ecb4e578ac4ca1fd3ca6c0c7e..6841d14cacb0485d74806be71210e62f83a86cb0 100644 (file)
@@ -3,9 +3,9 @@
 
 #include "main.h"
 
-#define SOCKET_FLAG_DEAD 0x01;
-#define SOCKET_FLAG_CONNECTED 0x02;
-#define SOCKET_FLAG_READY 0x04;
+#define SOCKET_FLAG_DEAD 0x01
+#define SOCKET_FLAG_CONNECTED 0x02
+#define SOCKET_FLAG_READY 0x04
 
 #define BUF_SIZ 512
 
index 4dc2da8a12b11957d03b9f22cdc8f399845facc8..2b7f2401ec21d2b5393f1d84747f53d0e0dc6989 100644 (file)
@@ -11,9 +11,9 @@ static void parse_raw(struct ClientSocket *client, char *from, char *cmd, char *
 int parse_lines(struct ClientSocket *client, char *lines, int len) {
     int i, startpos = 0;
     for(i = 0; i < len; i++) {
-        if(*lines[i] == "\r") //just zero it out :D
+        if(lines[i] == '\r') //just zero it out :D
             lines[i] = 0;
-        if(*lines[i] == "\n") {
+        if(lines[i] == '\n') {
             lines[i] = 0;
             parse_line(client, lines);
             startpos = i+1;
@@ -76,6 +76,7 @@ static void parse_raw(struct ClientSocket *client, char *from, char *cmd, char *
 static IRC_CMD(raw_001) {
     client->flags |= SOCKET_FLAG_READY;
     write_socket(client, "PRIVMSG Watchcat :hi\n", 21);
+    return 1;
 }
 
 void parser_init() {
index 65d476520b232929dbf482bfc818aa5e14143090..b32d60f4f2b4c1941223b5fc4cf3e88f370b0595 100644 (file)
@@ -6,7 +6,7 @@
 
 #define MAXNUMPARAMS 200 /* maximum number of parameters in one line */
 
-#define IRC_CMD(NAME) int NAME(UNUSED_ARG(const char *from), UNUSED_ARG(char **argv), UNUSED_ARG(unsigned int argc))
+#define IRC_CMD(NAME) int NAME(ClientSocket *client, UNUSED_ARG(const char *from), UNUSED_ARG(char **argv), UNUSED_ARG(unsigned int argc))
 typedef IRC_CMD(irc_cmd_t);
 
 struct irc_cmd {
diff --git a/main.h b/main.h
index a3a6840cc58949479f456db90c70d85cb2784400..f06fc6fc610ed61b17911672c0aae65071808eed 100644 (file)
--- a/main.h
+++ b/main.h
 #define UNUSED_ARG(ARG) ARG
 #endif
 
+int stricmp (const char *s1, const char *s2)
+{
+   if (s1 == NULL) return s2 == NULL ? 0 : -(*s2);
+   if (s2 == NULL) return *s1;
+   char c1, c2;
+   while ((c1 = tolower (*s1)) == (c2 = tolower (*s2)))
+   {
+     if (*s1 == '\0') break;
+     ++s1; ++s2;
+   }
+   return c1 - c2;
+}
+
 
 #define NICKLEN         30
 #define USERLEN         10