103 return IRC_GENERAL_ERROR; |
103 return IRC_GENERAL_ERROR; |
104 |
104 |
105 if ((pwd = getpwnam (user)) == NULL) |
105 if ((pwd = getpwnam (user)) == NULL) |
106 return IRC_GENERAL_ERROR; |
106 return IRC_GENERAL_ERROR; |
107 |
107 |
108 if (password == NULL) |
|
109 return IRC_LOGIN_ERROR; |
|
110 |
|
111 if (stream == NULL) |
108 if (stream == NULL) |
112 return IRC_GENERAL_ERROR; |
109 return IRC_GENERAL_ERROR; |
113 else |
110 else |
114 message.stream = stream; |
111 message.stream = stream; |
115 |
112 |
116 fprintf (stream, "NICK %s\r\n", nick); |
113 fprintf (stream, "NICK %s\r\n", nick); |
117 fprintf (stream, "USER %s 0 %s %s\r\n", user, server, pwd->pw_gecos); |
114 fprintf (stream, "USER %s 0 %s %s\r\n", user, server, pwd->pw_gecos); |
118 fprintf (stream, "PRIVMSG NICKSERV :IDENTIFY %s\r\n", password); |
115 |
|
116 if (password != NULL) |
|
117 fprintf (stream, "PRIVMSG NICKSERV :IDENTIFY %s\r\n", password); |
119 |
118 |
120 for (;;) { |
119 for (;;) { |
121 *msg = '\0'; |
120 *msg = '\0'; |
122 fgets (msg, 512, stream); |
121 fgets (msg, 512, stream); |
123 if ((user = irc_parsemessage (msg, &message)) != NULL) |
122 if ((user = irc_parsemessage (msg, &message)) != NULL) |
327 case 441: /* THEY AREN'T ON THIS CHANNEL */ |
332 case 441: /* THEY AREN'T ON THIS CHANNEL */ |
328 message->channel = strtok (message->line, " "); |
333 message->channel = strtok (message->line, " "); |
329 message->line = strtok (NULL, "\r\n"); |
334 message->line = strtok (NULL, "\r\n"); |
330 fprintf (message->stream, "PRIVMSG %s :%s\r\n", message->current_channel, message->line); |
335 fprintf (message->stream, "PRIVMSG %s :%s\r\n", message->current_channel, message->line); |
331 return command; |
336 return command; |
|
337 case 433: /* NICK ALREADY IN USE */ |
|
338 case 451: /* REGISTER FIRST */ |
|
339 return command; |
332 case 474: |
340 case 474: |
333 case 475: |
341 case 475: |
334 case 476: |
342 case 476: |
335 case 477: |
343 case 477: |
336 case 482: |
344 case 482: |