]> arthur.barton.de Git - ngircd.git/blobdiff - src/ngircd/conf.c
Fix "implicit conversion shortens 64-bit value" warning
[ngircd.git] / src / ngircd / conf.c
index eccf13cc3edec2a78d533287c2d92a18ce2345ce..71f0fe8ee81551c8e843f7927937f48e938a0176 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2009 Alexander Barton (alex@barton.de)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -152,8 +152,8 @@ ports_parse(array *a, int Line, char *Arg)
         * must be separated by "," */
        ptr = strtok( Arg, "," );
        while (ptr) {
-               ngt_TrimStr( ptr );
-               port = atol( ptr );
+               ngt_TrimStr(ptr);
+               port = atoi(ptr);
                if (port > 0 && port < 0xFFFF) {
                        port16 = (UINT16) port;
                        if (!array_catb(a, (char*)&port16, sizeof port16))
@@ -542,6 +542,16 @@ Set_Defaults( bool InitServers )
 } /* Set_Defaults */
 
 
+static bool
+no_listenports(void)
+{
+       size_t cnt = array_bytes(&Conf_ListenPorts);
+#ifdef SSL_SUPPORT
+       cnt += array_bytes(&Conf_SSLOptions.ListenPorts);
+#endif
+       return cnt == 0;
+}
+
 static bool
 Read_Config( bool ngircd_starting )
 {
@@ -698,12 +708,14 @@ Read_Config( bool ngircd_starting )
                Conf_Server[New_Server_Idx] = New_Server;
        }
 
-       if (0 == array_length(&Conf_ListenPorts, sizeof(UINT16))) {
-               if (!array_copyb(&Conf_ListenPorts, (char*) &defaultport, sizeof defaultport)) {
-                       Config_Error( LOG_ALERT, "Could not add default listening Port %u: %s",
-                                                       (unsigned int) defaultport, strerror(errno));
-                       exit( 1 );
-               }
+       /* not a single listening port? Add default. */
+       if (no_listenports() &&
+               !array_copyb(&Conf_ListenPorts, (char*) &defaultport, sizeof defaultport))
+       {
+               Config_Error(LOG_ALERT, "Could not add default listening Port %u: %s",
+                                       (unsigned int) defaultport, strerror(errno));
+
+               exit(1);
        }
 
        if (!Conf_ListenAddress)