Subversion Repositories RepoView

Rev

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

Rev Author Line No. Line
1 nishi 1
/* $Id: check.c 43 2024-08-22 05:51:35Z nishi $ */
2
 
3
#include "config.h"
4
 
5
#include <stdio.h>
6
 
3 nishi 7
int check_db(void) {
1 nishi 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
3 nishi 22
	if(counter > 1) {
1 nishi 23
		fprintf(stderr, "You cannot use multiple database types at once.\n");
24
		return 1;
3 nishi 25
	} else if(counter == 0) {
1 nishi 26
		fprintf(stderr, "You must select a database type.\n");
27
		return 1;
3 nishi 28
	} else {
1 nishi 29
		printf("Database type is %s\n", db);
30
	}
31
	return 0;
32
}
33
 
3 nishi 34
int check_theme(void) {
1 nishi 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
3 nishi 45
	if(counter > 1) {
1 nishi 46
		fprintf(stderr, "You cannot use multiple themes at once.\n");
47
		return 1;
3 nishi 48
	} else if(counter == 0) {
1 nishi 49
		fprintf(stderr, "You must select a theme.\n");
50
		return 1;
3 nishi 51
	} else {
1 nishi 52
		printf("Theme is %s\n", theme);
53
	}
54
	return 0;
55
}
56
 
3 nishi 57
int check_auth(void) {
1 nishi 58
	int counter = 0;
59
	const char* method = "";
60
#ifdef USE_COOKIE
61
	counter++;
62
	method = "Cookie";
63
#endif
3 nishi 64
	if(counter > 1) {
1 nishi 65
		fprintf(stderr, "You cannot use multiple authentication methods at once.\n");
66
		return 1;
3 nishi 67
	} else if(counter == 0) {
1 nishi 68
		fprintf(stderr, "You must select an authentication method.\n");
69
		return 1;
3 nishi 70
	} else {
1 nishi 71
		printf("Authentication method is %s\n", method);
72
	}
73
	return 0;
74
}
75
 
8 nishi 76
int check_files(void) {
77
	int st = 0;
78
#ifndef APACHE_PASSWD
79
	fprintf(stderr, "Apache htpasswd file is not set.\n");
80
	st = 1;
81
#endif
82
#ifndef APACHE_AUTHZ
83
	fprintf(stderr, "Apache authz file is not set.\n");
84
	st = 1;
85
#endif
10 nishi 86
#ifndef REPO_USER_DELIM
87
	fprintf(stderr, "Repo/User delimeter is not set.\n");
88
	st = 1;
89
#endif
8 nishi 90
	return st;
91
}
92
 
27 nishi 93
int check_mypage(void) {
94
	int st = 0;
95
#if defined(USE_MYPAGE) && !defined(USE_GRAPHICSMAGICK)
96
	fprintf(stderr, "USE_MYPAGE is defined, but USE_GRAPHICSMAGICK is not defined.\n");
97
	st = 1;
98
#endif
99
#if defined(USE_MYPAGE) && !defined(USE_LIBPNG)
100
	fprintf(stderr, "USE_MYPAGE is defined, but USE_LIBPNG is not defined.\n");
101
	st = 1;
102
#endif
37 nishi 103
#if defined(USE_MYPAGE) && !defined(USE_AVATAR)
104
	fprintf(stderr, "USE_MYPAGE is defined, but USE_AVATAR is not defined.\n");
105
	st = 1;
106
#endif
43 nishi 107
#if defined(USE_MYPAGE) && !defined(BIO_ROOT)
108
	fprintf(stderr, "USE_MYPAGE is defined, but BIO_ROOT is not defined.\n");
109
	st = 1;
110
#endif
27 nishi 111
	return st;
112
}
113
 
37 nishi 114
int check_avatar(void) {
115
	int st = 0;
116
#if defined(USE_AVATAR) && !defined(USE_LIBPNG)
117
	fprintf(stderr, "USE_AVATAR is defined, but USE_LIBPNG is not defined.\n");
118
	st = 1;
119
#endif
38 nishi 120
#if defined(USE_AVATAR) && !defined(WWW_AVATAR_ROOT)
121
	fprintf(stderr, "USE_AVATAR is defined, but WWW_AVATAR_ROOT is not defined.\n");
122
	st = 1;
123
#endif
124
#if defined(USE_AVATAR) && !defined(AVATAR_ROOT)
125
	fprintf(stderr, "USE_AVATAR is defined, but AVATAR_ROOT is not defined.\n");
126
	st = 1;
127
#endif
37 nishi 128
	return st;
129
}
130
 
3 nishi 131
int main() {
1 nishi 132
	int st;
133
	st = check_db();
134
	if(st != 0) goto fail;
135
	st = check_auth();
136
	if(st != 0) goto fail;
137
	st = check_theme();
138
	if(st != 0) goto fail;
8 nishi 139
	st = check_files();
140
	if(st != 0) goto fail;
27 nishi 141
	st = check_mypage();
142
	if(st != 0) goto fail;
37 nishi 143
	st = check_avatar();
144
	if(st != 0) goto fail;
1 nishi 145
	printf("Config validation successful.\n");
146
	return 0;
147
fail:
148
	fprintf(stderr, "Config validation failure.\n");
149
	return st;
150
}