Subversion Repositories RepoView

Rev

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

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