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: sanity.c 1 2024-08-20 19:18:25Z 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
 
14
bool rv_find_executable(const char* name){
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;
22
	for(i = 0;; i++){
23
		if(path[i] == 0 || path[i] == PATH_DELIM){
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
32
			if(access(exec, F_OK) == 0){
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
 
46
void rv_check_sanity(void){
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");
52
 
53
	if(!svnlook) sane = false;
54
	if(!svnadmin) sane = false;
55
	if(!htpasswd) sane = false;
56
 
57
	if(!sane){
58
		rv_error_http();
59
		if(!svnlook) printf("svnlook not found\n");
60
		if(!svnadmin) printf("svnadmin not found\n");
61
		if(!htpasswd) printf("htpasswd not found\n");
62
		exit(1);
63
	}
64
}