Subversion Repositories RepoView

Rev

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

Rev Author Line No. Line
1 nishi 1
/* $Id: sanity.c 13 2024-08-21 12:31:40Z 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");
13 nishi 52
	bool enscript = rv_find_executable("enscript");
1 nishi 53
 
54
	if(!svnlook) sane = false;
55
	if(!svnadmin) sane = false;
56
	if(!htpasswd) sane = false;
13 nishi 57
	if(!enscript) sane = false;
1 nishi 58
 
3 nishi 59
	if(!sane) {
1 nishi 60
		rv_error_http();
61
		if(!svnlook) printf("svnlook not found\n");
62
		if(!svnadmin) printf("svnadmin not found\n");
63
		if(!htpasswd) printf("htpasswd not found\n");
13 nishi 64
		if(!enscript) printf("enscript not found\n");
1 nishi 65
		exit(1);
66
	}
67
}