Subversion Repositories IRCServ

Rev

Rev 6 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 nishi 1
/* $Id: check.c 7 2024-08-25 20:49:55Z nishi $ */
2
 
3
#include "config.h"
4
 
5 nishi 5
#include <string.h>
2 nishi 6
#include <stdio.h>
7
 
8
int check_log(void) {
9
	int count = 0;
10
	const char* name = "";
11
#ifdef USE_SYSLOG
12
	name = "Syslog";
13
	count++;
14
#endif
15
#ifdef USE_STDERR
16
	name = "stderr";
17
	count++;
18
#endif
19
	if(count == 0) {
20
		fprintf(stderr, "Select a logger\n");
21
		return 1;
22
	} else if(count > 1) {
23
		fprintf(stderr, "Too many loggers\n");
24
		return 1;
25
	} else {
26
		printf("Using %s for logging\n", name);
27
		return 0;
28
	}
29
}
30
 
6 nishi 31
int check_ircd(void) {
32
	int count = 0;
33
	const char* name = "";
34
#ifdef USE_BAHAMUT_IRCD
35
	name = "Bahamut";
36
	count++;
37
#endif
38
	if(count == 0) {
39
		fprintf(stderr, "Select an IRCd\n");
40
		return 1;
41
	} else if(count > 1) {
42
		fprintf(stderr, "Too many IRCds\n");
43
		return 1;
44
	} else {
45
		printf("Using %s for IRCd\n", name);
46
		return 0;
47
	}
48
}
49
 
5 nishi 50
int check_irc(void) {
3 nishi 51
	int st = 0;
52
#ifndef IRC_SERVER
53
	fprintf(stderr, "Set a server IP\n");
54
	st = 1;
55
#endif
56
#ifndef IRC_PORT
57
	fprintf(stderr, "Set a server port\n");
58
	st = 1;
59
#endif
60
#ifndef IRC_SECRET
61
	fprintf(stderr, "Set a service password\n");
62
	st = 1;
63
#endif
64
#ifndef IRC_SERVICE
65
	fprintf(stderr, "Set a service name\n");
66
	st = 1;
67
#endif
7 nishi 68
#ifndef IRC_SERVICE_DESCRIPTION
69
	fprintf(stderr, "Set a service description\n");
70
	st = 1;
71
#endif
3 nishi 72
	return st;
73
}
74
 
5 nishi 75
int main(int argc, char** argv) {
76
	if(argc == 1) {
77
		int st = 0;
78
		st = check_log();
79
		if(st != 0) goto cleanup;
80
		st = check_irc();
81
		if(st != 0) goto cleanup;
6 nishi 82
		st = check_ircd();
83
		if(st != 0) goto cleanup;
5 nishi 84
	cleanup:
85
		return st;
86
	} else if(strcmp(argv[1], "objs") == 0) {
87
#if defined(USE_SYSLOG)
88
		printf("log/syslog.o");
89
#elif defined(USE_STDERR)
90
		printf("log/stderr.o");
91
#endif
6 nishi 92
 
93
		printf(" ");
94
#if defined(USE_BAHAMUT_IRCD)
95
		printf("ircd/bahamut.o");
96
#endif
97
 
98
		printf(" ");
99
#ifdef USE_NICKSERV
100
		printf("service/nickserv.o");
101
#endif
102
 
103
		printf(" ");
104
#ifdef USE_CHANSERV
105
		printf("service/chanserv.o");
106
#endif
107
 
108
		printf(" ");
109
#ifdef USE_MEMOSERV
110
		printf("service/memoserv.o");
111
#endif
112
 
113
		printf(" ");
114
#ifdef USE_OPERSERV
115
		printf("service/operserv.o");
116
#endif
5 nishi 117
		printf("\n");
118
	}
2 nishi 119
}