Subversion Repositories IRCServ

Rev

Rev 3 | Rev 6 | 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 5 2024-08-25 11:58:10Z 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
 
5 nishi 31
int check_irc(void) {
3 nishi 32
	int st = 0;
33
#ifndef IRC_SERVER
34
	fprintf(stderr, "Set a server IP\n");
35
	st = 1;
36
#endif
37
#ifndef IRC_PORT
38
	fprintf(stderr, "Set a server port\n");
39
	st = 1;
40
#endif
41
#ifndef IRC_SECRET
42
	fprintf(stderr, "Set a service password\n");
43
	st = 1;
44
#endif
45
#ifndef IRC_SERVICE
46
	fprintf(stderr, "Set a service name\n");
47
	st = 1;
48
#endif
49
	return st;
50
}
51
 
5 nishi 52
int main(int argc, char** argv) {
53
	if(argc == 1) {
54
		int st = 0;
55
		st = check_log();
56
		if(st != 0) goto cleanup;
57
		st = check_irc();
58
		if(st != 0) goto cleanup;
59
	cleanup:
60
		return st;
61
	} else if(strcmp(argv[1], "objs") == 0) {
62
#if defined(USE_SYSLOG)
63
		printf("log/syslog.o");
64
#elif defined(USE_STDERR)
65
		printf("log/stderr.o");
66
#endif
67
		printf("\n");
68
	}
2 nishi 69
}