]> jfr.im git - solanum.git/blobdiff - ircd/ircd.c
DICTIONARY_FOREACH → RB_DICTIONARY_FOREACH
[solanum.git] / ircd / ircd.c
index 9343b6bc8be05ec53825192247525175c05ebbaa..6d88a2cc37f1b2733ad93307dbb16ed813578fb6 100644 (file)
@@ -26,7 +26,7 @@
 #include "rb_lib.h"
 #include "stdinc.h"
 #include "setup.h"
-#include "config.h"
+#include "defaults.h"
 #include "ircd.h"
 #include "channel.h"
 #include "class.h"
@@ -103,10 +103,10 @@ bool dorehash = false;
 bool dorehashbans = false;
 bool doremotd = false;
 bool kline_queued = false;
-int server_state_foreground = 0;
-int opers_see_all_users = 0;
-int ssl_ok = 0;
-int zlib_ok = 1;
+bool server_state_foreground = false;
+bool opers_see_all_users = false;
+bool ircd_ssl_ok = false;
+bool ircd_zlib_ok = true;
 
 int testing_conf = 0;
 time_t startup_time;
@@ -156,6 +156,7 @@ print_startup(int pid)
 {
        int fd;
 
+#ifndef _WIN32
        close(1);
        fd = open("/dev/null", O_RDWR);
        if (fd == -1) {
@@ -166,19 +167,24 @@ print_startup(int pid)
                fd = dup(fd);
        if (fd != 1)
                abort();
-
+#endif
+       inotice("runtime path: %s", rb_path_to_self());
        inotice("now running in %s mode from %s as pid %d ...",
               !server_state_foreground ? "background" : "foreground",
                ConfigFileEntry.dpath, pid);
 
+#ifndef _WIN32
        /* let the parent process know the initialization was successful
         * -- jilles */
        if (!server_state_foreground)
-               write(0, ".", 1);
+       {
+               (void) write(0, ".", 1);
+       }
        if (dup2(1, 0) == -1)
                abort();
        if (dup2(1, 2) == -1)
                abort();
+#endif
 }
 
 /*
@@ -191,7 +197,7 @@ print_startup(int pid)
 static void
 init_sys(void)
 {
-#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)
+#if !defined(_WIN32) && defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)
        struct rlimit limit;
 
        if(!getrlimit(RLIMIT_NOFILE, &limit))
@@ -212,6 +218,7 @@ init_sys(void)
 static int
 make_daemon(void)
 {
+#ifndef _WIN32
        int pid;
        int pip[2];
        char c;
@@ -246,7 +253,7 @@ make_daemon(void)
 /*     fclose(stdin);
        fclose(stdout);
        fclose(stderr); */
-
+#endif
        return 0;
 }
 
@@ -412,7 +419,7 @@ check_pidfile(const char *filename)
                if(fgets(buff, 20, fb) != NULL)
                {
                        pidfromfile = atoi(buff);
-                       if(!kill(pidfromfile, 0))
+                       if(!rb_kill(pidfromfile, 0))
                        {
                                printf("ircd: daemon is already running\n");
                                exit(-1);
@@ -539,12 +546,14 @@ charybdis_main(int argc, char *argv[])
 {
        int fd;
 
+#ifndef _WIN32
        /* Check to see if the user is running us as root, which is a nono */
        if(geteuid() == 0)
        {
                fprintf(stderr, "Don't run ircd as root!!!\n");
                return -1;
        }
+#endif
 
        init_sys();
 
@@ -605,8 +614,9 @@ charybdis_main(int argc, char *argv[])
        setup_signals();
 
        if (testing_conf)
-               server_state_foreground = 1;
+               server_state_foreground = true;
 
+#ifndef _WIN32
        /* Make sure fd 0, 1 and 2 are in use -- jilles */
        do
        {
@@ -616,6 +626,7 @@ charybdis_main(int argc, char *argv[])
                close(fd);
        else if (fd == -1)
                exit(1);
+#endif
 
        /* Check if there is pidfile and daemon already running */
        if(!testing_conf)
@@ -663,7 +674,7 @@ charybdis_main(int argc, char *argv[])
 
        init_auth();            /* Initialise the auth code */
        init_authd();           /* Start up authd. */
-       init_nameserver_cache();        /* Get our nameserver cache for STATS a/A */
+       init_dns();             /* Start up DNS query system */
 
        privilegeset_set_new("default", "", 0);
 
@@ -713,10 +724,10 @@ charybdis_main(int argc, char *argv[])
                if(!rb_setup_ssl_server(ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params, ServerInfo.ssl_cipher_list))
                {
                        ilog(L_MAIN, "WARNING: Unable to setup SSL.");
-                       ssl_ok = 0;
+                       ircd_ssl_ok = false;
                }
                else
-                       ssl_ok = 1;
+                       ircd_ssl_ok = true;
        }
 
        if (testing_conf)