From: pk910 Date: Tue, 9 Aug 2011 23:52:32 +0000 (+0200) Subject: *push* X-Git-Tag: v5.3~652 X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=commitdiff_plain;h=fa4f6def317b63cc10e37ffc08e5f70f212e251e *push* --- diff --git a/ClientSocket.c b/ClientSocket.c index 5c81c04..7ca76d2 100644 --- a/ClientSocket.c +++ b/ClientSocket.c @@ -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; diff --git a/ClientSocket.h b/ClientSocket.h index dd8df54..6841d14 100644 --- a/ClientSocket.h +++ b/ClientSocket.h @@ -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 diff --git a/IRCParser.c b/IRCParser.c index 4dc2da8..2b7f240 100644 --- a/IRCParser.c +++ b/IRCParser.c @@ -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() { diff --git a/IRCParser.h b/IRCParser.h index 65d4765..b32d60f 100644 --- a/IRCParser.h +++ b/IRCParser.h @@ -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 a3a6840..f06fc6f 100644 --- a/main.h +++ b/main.h @@ -21,6 +21,19 @@ #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