projects
/
NeonServV5.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0a90b26
)
fixed bot user handling (bot should only have a user when connected)
author
pk910
<philipp@zoelle1.de>
Sat, 12 Nov 2011 20:55:00 +0000
(21:55 +0100)
committer
pk910
<philipp@zoelle1.de>
Sat, 12 Nov 2011 20:56:05 +0000
(21:56 +0100)
src/ClientSocket.c
patch
|
blob
|
history
src/ClientSocket.h
patch
|
blob
|
history
src/IRCParser.c
patch
|
blob
|
history
src/bot_DummyServ.c
patch
|
blob
|
history
src/bot_NeonServ.c
patch
|
blob
|
history
src/bot_NeonSpam.c
patch
|
blob
|
history
diff --git
a/src/ClientSocket.c
b/src/ClientSocket.c
index b76e6f62c421c9af81e9cb6be9a629bf34ac425c..1a3d94984279b477265f42dd5a3d8eec55df0582 100644
(file)
--- a/
src/ClientSocket.c
+++ b/
src/ClientSocket.c
@@
-42,7
+42,7
@@
static void init_sockets() {
sockets->count = 0;
}
sockets->count = 0;
}
-struct ClientSocket* create_socket(char *host, int port, char *pass,
struct UserNode *user
) {
+struct ClientSocket* create_socket(char *host, int port, char *pass,
char *nick, char *ident, char *realname
) {
if(sockets == NULL) init_sockets();
struct ClientSocket *client = malloc(sizeof(*client));
if (!client)
if(sockets == NULL) init_sockets();
struct ClientSocket *client = malloc(sizeof(*client));
if (!client)
@@
-54,7
+54,10
@@
struct ClientSocket* create_socket(char *host, int port, char *pass, struct User
client->port = port;
printf("Connect: %s:%d\n", client->host, client->port);
client->pass = (pass == NULL ? NULL : strdup(pass));
client->port = port;
printf("Connect: %s:%d\n", client->host, client->port);
client->pass = (pass == NULL ? NULL : strdup(pass));
- client->user = user;
+ client->nick = strdup(nick);
+ client->ident = strdup(ident);
+ client->realname = strdup(realname);
+ client->user = NULL;
client->flags = 0;
client->bufferpos = 0;
client->traffic_in = 0;
client->flags = 0;
client->bufferpos = 0;
client->traffic_in = 0;
@@
-115,9
+118,9
@@
int connect_socket(struct ClientSocket *client) {
len = sprintf(sendBuf, "PASS :%s\n", client->pass);
write_socket(client, sendBuf, len);
}
len = sprintf(sendBuf, "PASS :%s\n", client->pass);
write_socket(client, sendBuf, len);
}
- len = sprintf(sendBuf, "USER %s 0 0 :%s\n", client->
user->ident, client->user
->realname);
+ len = sprintf(sendBuf, "USER %s 0 0 :%s\n", client->
ident, client
->realname);
write_socket(client, sendBuf, len);
write_socket(client, sendBuf, len);
- len = sprintf(sendBuf, "NICK %s\n", client->
user->
nick);
+ len = sprintf(sendBuf, "NICK %s\n", client->nick);
write_socket(client, sendBuf, len);
return 1;
write_socket(client, sendBuf, len);
return 1;
@@
-168,11
+171,11
@@
int connect_socket(struct ClientSocket *client) {
len = sprintf(sendBuf, "PASS :%s\n", client->pass);
write_socket(client, sendBuf, len);
}
len = sprintf(sendBuf, "PASS :%s\n", client->pass);
write_socket(client, sendBuf, len);
}
- len = sprintf(sendBuf, "USER %s 0 0 :%s\n", client->
user->ident, client->user
->realname);
+ len = sprintf(sendBuf, "USER %s 0 0 :%s\n", client->
ident, client
->realname);
write_socket(client, sendBuf, len);
write_socket(client, sendBuf, len);
- len = sprintf(sendBuf, "NICK %s\n", client->
user->
nick);
+ len = sprintf(sendBuf, "NICK %s\n", client->nick);
write_socket(client, sendBuf, len);
write_socket(client, sendBuf, len);
-
+
return 1;
}
return 1;
}
diff --git
a/src/ClientSocket.h
b/src/ClientSocket.h
index f0334508c502779638cc478145b46ab6030a3af9..39d7bb0ca6dbeb7dbe69d93c43ac5bf31ef33ced 100644
(file)
--- a/
src/ClientSocket.h
+++ b/
src/ClientSocket.h
@@
-39,6
+39,9
@@
struct ClientSocket {
char *host;
int port;
char *pass;
char *host;
int port;
char *pass;
+ char *nick;
+ char *ident;
+ char *realname;
struct UserNode *user;
unsigned long traffic_in;
unsigned long traffic_out;
struct UserNode *user;
unsigned long traffic_in;
unsigned long traffic_out;
@@
-58,7
+61,7
@@
struct ClientSocket {
struct ClientSocket *next;
};
struct ClientSocket *next;
};
-struct ClientSocket* create_socket(char *host, int port, char *pass,
struct UserNode *user
);
+struct ClientSocket* create_socket(char *host, int port, char *pass,
char *nick, char *ident, char *realname
);
int connect_socket(struct ClientSocket *client);
int close_socket(struct ClientSocket *client);
int write_socket_force(struct ClientSocket *client, char* msg, int len);
int connect_socket(struct ClientSocket *client);
int close_socket(struct ClientSocket *client);
int write_socket_force(struct ClientSocket *client, char* msg, int len);
diff --git
a/src/IRCParser.c
b/src/IRCParser.c
index da752c562c198e7ade467d3370b6539e5885d698..38b02a4563db3caa0d485d3784c15cf718b96b25 100644
(file)
--- a/
src/IRCParser.c
+++ b/
src/IRCParser.c
@@
-116,6
+116,8
@@
static USERLIST_CALLBACK(got_channel_userlist) {
}
static IRC_CMD(raw_001) {
}
static IRC_CMD(raw_001) {
+ client->user = addUser(argv[0]);
+ client->user->flags |= USERFLAG_ISBOT;
client->flags |= SOCKET_FLAG_READY;
event_bot_ready(client);
return 1;
client->flags |= SOCKET_FLAG_READY;
event_bot_ready(client);
return 1;
diff --git
a/src/bot_DummyServ.c
b/src/bot_DummyServ.c
index b618045e242f625a0d641569d8f0c5b3ab1e7431..9bbdcfeef3e4bf5de48f8a5396c25a752b5c833e 100644
(file)
--- a/
src/bot_DummyServ.c
+++ b/
src/bot_DummyServ.c
@@
-65,7
+65,6
@@
static void dummyserv_trigger_callback(struct ChanNode *chan, char *trigger) {
}
static void start_bots() {
}
static void start_bots() {
- struct UserNode *user;
struct ClientSocket *client;
MYSQL_RES *res, *res2;
MYSQL_ROW row;
struct ClientSocket *client;
MYSQL_RES *res, *res2;
MYSQL_ROW row;
@@
-74,11
+73,7
@@
static void start_bots() {
res = mysql_use();
while ((row = mysql_fetch_row(res)) != NULL) {
res = mysql_use();
while ((row = mysql_fetch_row(res)) != NULL) {
- user = addUser(row[0]);
- strcpy(user->ident, row[1]);
- strcpy(user->realname, row[2]);
- user->flags |= USERFLAG_ISBOT;
- client = create_socket(row[3], atoi(row[4]), row[5], user);
+ client = create_socket(row[3], atoi(row[4]), row[5], row[0], row[1], row[2]);
client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0);
client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0);
client->botid = BOTID;
client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0);
client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0);
client->botid = BOTID;
diff --git
a/src/bot_NeonServ.c
b/src/bot_NeonServ.c
index dbf3acb5a04befcd38b08ec91132e19526808b1e..3f9fc6e5962baa5260195c779c55d10ebc9ce386 100644
(file)
--- a/
src/bot_NeonServ.c
+++ b/
src/bot_NeonServ.c
@@
-405,7
+405,6
@@
static void neonserv_trigger_callback(struct ChanNode *chan, char *trigger) {
}
static void start_bots() {
}
static void start_bots() {
- struct UserNode *user;
struct ClientSocket *client;
MYSQL_RES *res, *res2;
MYSQL_ROW row;
struct ClientSocket *client;
MYSQL_RES *res, *res2;
MYSQL_ROW row;
@@
-414,11
+413,7
@@
static void start_bots() {
res = mysql_use();
while ((row = mysql_fetch_row(res)) != NULL) {
res = mysql_use();
while ((row = mysql_fetch_row(res)) != NULL) {
- user = addUser(row[0]);
- strcpy(user->ident, row[1]);
- strcpy(user->realname, row[2]);
- user->flags |= USERFLAG_ISBOT;
- client = create_socket(row[3], atoi(row[4]), row[5], user);
+ client = create_socket(row[3], atoi(row[4]), row[5], row[0], row[1], row[2]);
client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0);
client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0);
client->botid = BOTID;
client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0);
client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0);
client->botid = BOTID;
diff --git
a/src/bot_NeonSpam.c
b/src/bot_NeonSpam.c
index 050bc107799b35b42bc795bb411ae15b3e1c0b07..33e9cbf1ecb9d3bd7a5f6e4feec4b40f3306c3b1 100644
(file)
--- a/
src/bot_NeonSpam.c
+++ b/
src/bot_NeonSpam.c
@@
-118,7
+118,6
@@
static void neonspam_trigger_callback(struct ChanNode *chan, char *trigger) {
}
static void start_bots() {
}
static void start_bots() {
- struct UserNode *user;
struct ClientSocket *client;
MYSQL_RES *res, *res2;
MYSQL_ROW row;
struct ClientSocket *client;
MYSQL_RES *res, *res2;
MYSQL_ROW row;
@@
-127,11
+126,7
@@
static void start_bots() {
res = mysql_use();
while ((row = mysql_fetch_row(res)) != NULL) {
res = mysql_use();
while ((row = mysql_fetch_row(res)) != NULL) {
- user = addUser(row[0]);
- strcpy(user->ident, row[1]);
- strcpy(user->realname, row[2]);
- user->flags |= USERFLAG_ISBOT;
- client = create_socket(row[3], atoi(row[4]), row[5], user);
+ client = create_socket(row[3], atoi(row[4]), row[5], row[0], row[1], row[2]);
client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0);
client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0);
client->botid = BOTID;
client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0);
client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0);
client->botid = BOTID;