src/irc.c
changeset 6 7eb12be31bb5
parent 5 7c7fc8906920
child 9 aff6726b8b87
--- a/src/irc.c
+++ b/src/irc.c
@@ -34,7 +34,7 @@
     char *ip;
     struct sockaddr_in ca;
     int csocket;
-    FILE *stream;
+    FILE *stream = NULL;
 
     he = gethostbyname (server);
     if (he == NULL) {
@@ -62,19 +62,23 @@
      * rw mode,but many seek errors ...
      */
 #ifdef NETBSD
-    /* BEGIN OF STREAM */
+    /*
+     * BEGIN OF STREAM
+     */
     stream = fdopen (csocket, "r+");
 #else
-    /* END OF STREAM */
+    /*
+     * END OF STREAM
+     */
     stream = fdopen (csocket, "a+");
 #endif
-    csocket = fileno(stream);
+    csocket = fileno (stream);
 
     printf ("Using filedescriptor %d for stream operations\n", csocket);
     return stream;
 }
 
-int irc_login (FILE * stream, char *nick, char *password)
+int irc_login (FILE * stream, char *server, char *nick, char *password)
 {
     MSG message;
     char msg[513];
@@ -85,7 +89,7 @@
         if ((pwd = getpwnam (user)) == NULL)
             return IRC_GENERAL_ERROR;
 
-    if (strlen (password) == 0)
+    if (password == NULL)
         return IRC_LOGIN_ERROR;
 
     if (stream == NULL)
@@ -93,7 +97,7 @@
 
     fprintf (stream, "NICK %s\r\n", nick);
 
-    fprintf (stream, "USER %s 0 irc.freenode.net %s\r\n", user, pwd->pw_gecos);
+    fprintf (stream, "USER %s 0 %s %s\r\n", user, server, pwd->pw_gecos);
 
     fprintf (stream, "PRIVMSG NICKSERV :IDENTIFY %s\r\n", password);