#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"
const char *pidFileName = PPATH;
char **myargv;
-int dorehash = 0;
-int dorehashbans = 0;
-int doremotd = 0;
+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;
{
int fd;
+#ifndef _WIN32
close(1);
fd = open("/dev/null", O_RDWR);
if (fd == -1) {
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
}
/*
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))
static int
make_daemon(void)
{
+#ifndef _WIN32
int pid;
int pip[2];
char c;
/* fclose(stdin);
fclose(stdout);
fclose(stderr); */
-
+#endif
return 0;
}
if(dorehash)
{
rehash(1);
- dorehash = 0;
+ dorehash = false;
}
if(dorehashbans)
{
rehash_bans(1);
- dorehashbans = 0;
+ dorehashbans = false;
}
if(doremotd)
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Got signal SIGUSR1, reloading ircd motd file");
cache_user_motd();
- doremotd = 0;
+ doremotd = false;
}
}
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);
{
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();
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
{
close(fd);
else if (fd == -1)
exit(1);
+#endif
/* Check if there is pidfile and daemon already running */
if(!testing_conf)
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);
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)