Subversion Repositories RepoView

Rev

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

Rev Author Line No. Line
1 nishi 1
/* $Id: sanity.c 15 2024-08-21 15:36:37Z nishi $ */
2
 
3
#include "rv_sanity.h"
4
 
5
#include "rv_version.h"
6
#include "rv_util.h"
7
#include "../config.h"
8
 
9
#include <stdbool.h>
10
#include <stdlib.h>
11
#include <stdio.h>
12
#include <unistd.h>
13
 
3 nishi 14
bool rv_find_executable(const char* name) {
1 nishi 15
#ifdef USE_PATH
16
	char* path = rv_strcat(USE_PATH, "");
17
#else
18
	char* path = rv_strcat(getenv("PATH"), "");
19
#endif
20
	int i;
21
	int incr = 0;
3 nishi 22
	for(i = 0;; i++) {
23
		if(path[i] == 0 || path[i] == PATH_DELIM) {
1 nishi 24
			char oldc = path[i];
25
			path[i] = 0;
26
			char* exec = rv_strcat3(path + incr, "/", name);
27
#ifdef __MINGW32__
28
			char* tmp = exec;
29
			exec = rv_strcat(exec, ".exe");
30
			free(tmp);
31
#endif
3 nishi 32
			if(access(exec, F_OK) == 0) {
1 nishi 33
				free(exec);
34
				free(path);
35
				return true;
36
			}
37
			free(exec);
38
			incr = i + 1;
39
			if(oldc == 0) break;
40
		}
41
	}
42
	free(path);
43
	return false;
44
}
45
 
3 nishi 46
void rv_check_sanity(void) {
1 nishi 47
	bool sane = true;
48
 
49
	bool svnlook = rv_find_executable("svnlook");
50
	bool svnadmin = rv_find_executable("svnadmin");
51
	bool htpasswd = rv_find_executable("htpasswd");
15 nishi 52
#ifdef USE_ENSCRIPT
13 nishi 53
	bool enscript = rv_find_executable("enscript");
15 nishi 54
#endif
55
	bool rm = rv_find_executable("rm");
1 nishi 56
 
57
	if(!svnlook) sane = false;
58
	if(!svnadmin) sane = false;
59
	if(!htpasswd) sane = false;
15 nishi 60
#ifdef USE_ENSCRIPT
13 nishi 61
	if(!enscript) sane = false;
15 nishi 62
#endif
63
	if(!rm) sane = false;
1 nishi 64
 
3 nishi 65
	if(!sane) {
1 nishi 66
		rv_error_http();
67
		if(!svnlook) printf("svnlook not found\n");
68
		if(!svnadmin) printf("svnadmin not found\n");
69
		if(!htpasswd) printf("htpasswd not found\n");
15 nishi 70
#ifdef USE_ENSCRIPT
13 nishi 71
		if(!enscript) printf("enscript not found\n");
15 nishi 72
#endif
73
		if(!rm) printf("rm not found\n");
1 nishi 74
		exit(1);
75
	}
76
}