Subversion Repositories IRCServ

Rev

Rev 7 | 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 8 2024-08-25 20:51:19Z 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
#ifdef USE_NICKSERV
8 nishi 61
	is_log("Initializing NickServ");
7 nishi 62
	st = is_nickserv_init();
63
	if(st != 0) goto cleanup;
64
#endif
65
#ifdef USE_CHANSERV
8 nishi 66
	is_log("Initializing ChanServ");
7 nishi 67
	st = is_chanserv_init();
68
	if(st != 0) goto cleanup;
69
#endif
70
#ifdef USE_MEMOSERV
8 nishi 71
	is_log("Initializing MemoServ");
7 nishi 72
	st = is_memoserv_init();
73
	if(st != 0) goto cleanup;
74
#endif
75
#ifdef USE_OPERSERV
8 nishi 76
	is_log("Initializing OperServ");
7 nishi 77
	st = is_operserv_init();
78
	if(st != 0) goto cleanup;
79
#endif
80
 
5 nishi 81
	pid_t pid = 0;
82
	if(daemon) {
83
		pid = fork();
84
	}
85
	if(pid == 0) {
7 nishi 86
		/* Main */
87
		is_log("Initialization successful, hello from daemon");
5 nishi 88
 
7 nishi 89
		is_socket_close();
5 nishi 90
		return 0;
91
	} else {
92
		return 0;
93
	}
7 nishi 94
cleanup:
95
	fprintf(stderr, "IRCServ exiting with error, check the log.\n");
96
	return st;
3 nishi 97
}