Subversion Repositories IRCServ

Rev

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

Rev Author Line No. Line
2 nishi 1
/* $Id: check.c 6 2024-08-25 19:00:39Z 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
68
	return st;
69
}
70
 
5 nishi 71
int main(int argc, char** argv) {
72
	if(argc == 1) {
73
		int st = 0;
74
		st = check_log();
75
		if(st != 0) goto cleanup;
76
		st = check_irc();
77
		if(st != 0) goto cleanup;
6 nishi 78
		st = check_ircd();
79
		if(st != 0) goto cleanup;
5 nishi 80
	cleanup:
81
		return st;
82
	} else if(strcmp(argv[1], "objs") == 0) {
83
#if defined(USE_SYSLOG)
84
		printf("log/syslog.o");
85
#elif defined(USE_STDERR)
86
		printf("log/stderr.o");
87
#endif
6 nishi 88
 
89
		printf(" ");
90
#if defined(USE_BAHAMUT_IRCD)
91
		printf("ircd/bahamut.o");
92
#endif
93
 
94
		printf(" ");
95
#ifdef USE_NICKSERV
96
		printf("service/nickserv.o");
97
#endif
98
 
99
		printf(" ");
100
#ifdef USE_CHANSERV
101
		printf("service/chanserv.o");
102
#endif
103
 
104
		printf(" ");
105
#ifdef USE_MEMOSERV
106
		printf("service/memoserv.o");
107
#endif
108
 
109
		printf(" ");
110
#ifdef USE_OPERSERV
111
		printf("service/operserv.o");
112
#endif
5 nishi 113
		printf("\n");
114
	}
2 nishi 115
}