Subversion Repositories RepoView

Rev

Rev 3 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 nishi 1
/* $Id: check.c 1 2024-08-20 19:18:25Z nishi $ */
2
 
3
#include "config.h"
4
 
5
#include <stdio.h>
6
 
7
int check_db(void){
8
	int counter = 0;
9
	const char* db = "";
10
#ifdef USE_SQLITE
11
	counter++;
12
	db = "SQLite";
13
#endif
14
#ifdef USE_GDBM
15
	counter++;
16
	db = "GDBM";
17
#endif
18
#ifdef USE_NDBM
19
	counter++;
20
	db = "NDBM";
21
#endif
22
	if(counter > 1){
23
		fprintf(stderr, "You cannot use multiple database types at once.\n");
24
		return 1;
25
	}else if(counter == 0){
26
		fprintf(stderr, "You must select a database type.\n");
27
		return 1;
28
	}else{
29
		printf("Database type is %s\n", db);
30
	}
31
	return 0;
32
}
33
 
34
int check_theme(void){
35
	int counter = 0;
36
	const char* theme = "";
37
#ifdef USE_MODERN
38
	counter++;
39
	theme = "Modern";
40
#endif
41
#ifdef USE_OPTIMIZED
42
	counter++;
43
	theme = "Optimized";
44
#endif
45
	if(counter > 1){
46
		fprintf(stderr, "You cannot use multiple themes at once.\n");
47
		return 1;
48
	}else if(counter == 0){
49
		fprintf(stderr, "You must select a theme.\n");
50
		return 1;
51
	}else{
52
		printf("Theme is %s\n", theme);
53
	}
54
	return 0;
55
}
56
 
57
int check_auth(void){
58
	int counter = 0;
59
	const char* method = "";
60
#ifdef USE_COOKIE
61
	counter++;
62
	method = "Cookie";
63
#endif
64
	if(counter > 1){
65
		fprintf(stderr, "You cannot use multiple authentication methods at once.\n");
66
		return 1;
67
	}else if(counter == 0){
68
		fprintf(stderr, "You must select an authentication method.\n");
69
		return 1;
70
	}else{
71
		printf("Authentication method is %s\n", method);
72
	}
73
	return 0;
74
}
75
 
76
int main(){
77
	int st;
78
	st = check_db();
79
	if(st != 0) goto fail;
80
	st = check_auth();
81
	if(st != 0) goto fail;
82
	st = check_theme();
83
	if(st != 0) goto fail;
84
	printf("Config validation successful.\n");
85
	return 0;
86
fail:
87
	fprintf(stderr, "Config validation failure.\n");
88
	return st;
89
}