Subversion Repositories IRCServ

Rev

Rev 5 | Rev 8 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 nishi 1
/* $Id: main.c 7 2024-08-25 20:49:55Z nishi $ */
2
 
3
#include "is_version.h"
5 nishi 4
#include "is_util.h"
5
#include "is_log.h"
7 nishi 6
#include "is_socket.h"
7
#include "is_ircd.h"
2 nishi 8
 
7 nishi 9
#include "../config.h"
10
 
11
#ifdef USE_NICKSERV
12
#include "is_nickserv.h"
13
#endif
14
 
15
#ifdef USE_CHANSERV
16
#include "is_chanserv.h"
17
#endif
18
 
19
#ifdef USE_MEMOSERV
20
#include "is_memoserv.h"
21
#endif
22
 
23
#ifdef USE_OPERSERV
24
#include "is_operserv.h"
25
#endif
26
 
3 nishi 27
#include <stdio.h>
5 nishi 28
#include <stdlib.h>
29
#include <unistd.h>
30
#include <stdbool.h>
31
#include <string.h>
3 nishi 32
 
7 nishi 33
struct is_config config;
34
 
3 nishi 35
int main(int argc, char** argv) {
5 nishi 36
	bool daemon = true;
37
	int i;
38
	for(i = 1; i < argc; i++) {
39
		if(strcmp(argv[i], "-D") == 0) {
40
			daemon = false;
41
			break;
42
		}
43
	}
7 nishi 44
 
45
	char* str;
46
	int st;
47
 
48
	str = is_strcat("IRCServ version ", is_get_version());
49
	is_log(str);
50
	free(str);
51
 
52
	is_log("Initializing the socket");
53
	st = is_socket_init();
54
	if(st != 0) goto cleanup;
55
 
56
	is_log("Initializing the connection");
57
	st = is_ircd_connect();
58
	if(st != 0) goto cleanup;
59
 
60
	is_log("Initializing the services");
61
 
62
#ifdef USE_NICKSERV
63
	st = is_nickserv_init();
64
	if(st != 0) goto cleanup;
65
#endif
66
#ifdef USE_CHANSERV
67
	st = is_chanserv_init();
68
	if(st != 0) goto cleanup;
69
#endif
70
#ifdef USE_MEMOSERV
71
	st = is_memoserv_init();
72
	if(st != 0) goto cleanup;
73
#endif
74
#ifdef USE_OPERSERV
75
	st = is_operserv_init();
76
	if(st != 0) goto cleanup;
77
#endif
78
 
5 nishi 79
	pid_t pid = 0;
80
	if(daemon) {
81
		pid = fork();
82
	}
83
	if(pid == 0) {
7 nishi 84
		/* Main */
85
		is_log("Initialization successful, hello from daemon");
5 nishi 86
 
7 nishi 87
		is_socket_close();
5 nishi 88
		return 0;
89
	} else {
90
		return 0;
91
	}
7 nishi 92
cleanup:
93
	fprintf(stderr, "IRCServ exiting with error, check the log.\n");
94
	return st;
3 nishi 95
}