Updated error codes

This commit is contained in:
Michiel Broek 2005-05-01 20:46:30 +00:00
parent 85b7d186f8
commit 053e2f2897

View File

@ -806,8 +806,8 @@ int command_pass(char *hostname, char *parameters)
lnk = strtok(NULL, " \0"); lnk = strtok(NULL, " \0");
if (version == NULL) { if (version == NULL) {
send_msg(tnsl, "461 PASS: Not enough parameters\r\n"); send_msg(tnsl, "400 PASS: Not enough parameters\r\n");
return 461; return 400;
} }
if (strcmp(passwd, tnsl->passwd)) { if (strcmp(passwd, tnsl->passwd)) {
@ -815,6 +815,11 @@ int command_pass(char *hostname, char *parameters)
return 0; return 0;
} }
if (tnsl->state == NCS_CONNECT) {
send_msg(tnsl, "401: PASS: Already registered\r\n");
return 401;
}
tnsl->gotpass = TRUE; tnsl->gotpass = TRUE;
tnsl->version = atoi(version); tnsl->version = atoi(version);
if (lnk && strchr(lnk, 'Z')) if (lnk && strchr(lnk, 'Z'))
@ -851,8 +856,8 @@ int command_server(char *hostname, char *parameters)
} }
if (fullname == NULL) { if (fullname == NULL) {
send_msg(tnsl, "461 SERVER: Not enough parameters\r\n"); send_msg(tnsl, "400 SERVER: Not enough parameters\r\n");
return 461; return 400;
} }
token = atoi(id); token = atoi(id);
@ -1020,8 +1025,8 @@ int command_user(char *hostname, char *parameters)
realname = strtok(NULL, "\0"); realname = strtok(NULL, "\0");
if (realname == NULL) { if (realname == NULL) {
send_msg(tnsl, "461 USER: Not enough parameters\r\n"); send_msg(tnsl, "400 USER: Not enough parameters\r\n");
return 461; return 400;
} }
if (add_user(&users, server, name, realname) == 0) { if (add_user(&users, server, name, realname) == 0) {
@ -1049,8 +1054,8 @@ int command_quit(char *hostname, char *parameters)
message = strtok(NULL, "\0"); message = strtok(NULL, "\0");
if (server == NULL) { if (server == NULL) {
send_msg(tnsl, "461 QUIT: Not enough parameters\r\n"); send_msg(tnsl, "400 QUIT: Not enough parameters\r\n");
return 461; return 400;
} }
if (message) { if (message) {
@ -1084,13 +1089,13 @@ int command_nick(char *hostname, char *parameters)
realname = strtok(NULL, "\0"); realname = strtok(NULL, "\0");
if (realname == NULL) { if (realname == NULL) {
send_msg(tnsl, "461 NICK: Not enough parameters\r\n"); send_msg(tnsl, "400 NICK: Not enough parameters\r\n");
return 1; return 1;
} }
if (strlen(nick) > 9) { if (strlen(nick) > 9) {
send_msg(tnsl, "432 %s: Erroneous nickname\r\n", nick); send_msg(tnsl, "402 %s: Erroneous nickname\r\n", nick);
return 432; return 402;
} }
// FIXME: check 1st char is alpha, rest alpha/digit // FIXME: check 1st char is alpha, rest alpha/digit
@ -1103,8 +1108,8 @@ int command_nick(char *hostname, char *parameters)
} }
} }
if (found) { if (found) {
send_msg(tnsl, "433 %s: Nickname is already in use\r\n", nick); send_msg(tnsl, "403 %s: Nickname is already in use\r\n", nick);
return 433; return 403;
} }
for (tmp = users; tmp; tmp = tmp->next) { for (tmp = users; tmp; tmp = tmp->next) {
@ -1118,8 +1123,8 @@ int command_nick(char *hostname, char *parameters)
} }
} }
if (!found) { if (!found) {
send_msg(tnsl, "437 %s@%s: Can't change nick\r\n", name, server); send_msg(tnsl, "404 %s@%s: Can't change nick\r\n", name, server);
return 437; return 404;
} }
broadcast(hostname, "NICK %s %s %s %s\r\n", nick, name, server, realname); broadcast(hostname, "NICK %s %s %s %s\r\n", nick, name, server, realname);
@ -1147,13 +1152,13 @@ int command_join(char *hostname, char *parameters)
channel = strtok(NULL, "\0"); channel = strtok(NULL, "\0");
if (channel == NULL) { if (channel == NULL) {
send_msg(tnsl, "461 JOIN: Not enough parameters\r\n"); send_msg(tnsl, "400 JOIN: Not enough parameters\r\n");
return 461; return 400;
} }
if (strlen(channel) > 20) { if (strlen(channel) > 20) {
send_msg(tnsl, "432 %s: Erroneous channelname\r\n", nick); send_msg(tnsl, "402 %s: Erroneous channelname\r\n", nick);
return 432; return 402;
} }
if (strcasecmp(channel, "#sysop") == 0) { if (strcasecmp(channel, "#sysop") == 0) {
@ -1213,8 +1218,8 @@ int command_part(char *hostname, char *parameters)
message = strtok(NULL, "\0"); message = strtok(NULL, "\0");
if (channel == NULL) { if (channel == NULL) {
send_msg(tnsl, "461 PART: Not enough parameters\r\n"); send_msg(tnsl, "400 PART: Not enough parameters\r\n");
return 461; return 400;
} }
if (strcasecmp(channel, "#sysop") == 0) { if (strcasecmp(channel, "#sysop") == 0) {
@ -1276,8 +1281,8 @@ int command_topic(char *hostname, char *parameters)
topic = strtok(NULL, "\0"); topic = strtok(NULL, "\0");
if (topic == NULL) { if (topic == NULL) {
send_msg(tnsl, "461 TOPIC: Not enough parameters\r\n"); send_msg(tnsl, "400 TOPIC: Not enough parameters\r\n");
return 461; return 400;
} }
for (tmp = channels; tmp; tmp = tmp->next) { for (tmp = channels; tmp; tmp = tmp->next) {
@ -1318,8 +1323,8 @@ int command_privmsg(char *hostname, char *parameters)
} }
if (channel[0] != '#') { if (channel[0] != '#') {
send_msg(tnsl, "401 PRIVMSG: Not for a channel\r\n"); // FIXME: also check users send_msg(tnsl, "499 PRIVMSG: Not for a channel\r\n"); // FIXME: also check users
return 401; return 499;
} }
for (tmp = channels; tmp; tmp = tmp->next) { for (tmp = channels; tmp; tmp = tmp->next) {
@ -1331,8 +1336,8 @@ int command_privmsg(char *hostname, char *parameters)
} }
} }
send_msg(tnsl, "403 %s: no such channel\r\n", channel); send_msg(tnsl, "409 %s: Cannot sent to channel\r\n", channel);
return 403; return 409;
} }
@ -1365,8 +1370,8 @@ int do_command(char *hostname, char *command, char *parameters)
* Commands with parameters * Commands with parameters
*/ */
if (parameters == NULL) { if (parameters == NULL) {
send_msg(tnsl, "461 %s: Not enough parameters\r\n", command); send_msg(tnsl, "400 %s: Not enough parameters\r\n", command);
return 461; return 400;
} }
if (! strcmp(command, (char *)"PASS")) { if (! strcmp(command, (char *)"PASS")) {
@ -1400,8 +1405,8 @@ int do_command(char *hostname, char *command, char *parameters)
return command_privmsg(hostname, parameters); return command_privmsg(hostname, parameters);
} }
send_msg(tnsl, "421 %s: Unknown command\r\n", command); send_msg(tnsl, "413 %s: Unknown command\r\n", command);
return 421; return 413;
} }