Subversion Repositories RepoView

Rev

Rev 12 | Rev 15 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12 Rev 14
Line 1... Line 1...
1
/* $Id: repo.c 12 2024-08-21 05:05:19Z nishi $ */
1
/* $Id: repo.c 14 2024-08-21 14:24:05Z nishi $ */
2
 
2
 
3
#include "rv_repo.h"
3
#include "rv_repo.h"
4
 
4
 
5
#include "../config.h"
5
#include "../config.h"
6
 
6
 
Line 164... Line 164...
164
		free(d);
164
		free(d);
165
		return sz;
165
		return sz;
166
	}
166
	}
167
}
167
}
168
 
168
 
-
 
169
void rv_remove_repo(const char* repouser) {
-
 
170
	printf("");
-
 
171
	char* svnpath = rv_strcat3(SVN_ROOT, "/", repouser);
-
 
172
	pid_t pid = fork();
-
 
173
	if(pid == 0) {
-
 
174
		char* cmd[] = {"rm", "-rf", svnpath, NULL};
-
 
175
		execvp("rm", cmd);
-
 
176
		_exit(0);
-
 
177
	} else {
-
 
178
		waitpid(pid, 0, 0);
-
 
179
	}
-
 
180
	free(svnpath);
-
 
181
 
-
 
182
	FILE* f = fopen(APACHE_AUTHZ, "r+");
-
 
183
	lockf(fileno(f), F_LOCK, 0);
-
 
184
 
-
 
185
	fseek(f, 0, SEEK_SET);
-
 
186
	struct stat s;
-
 
187
	stat(APACHE_AUTHZ, &s);
-
 
188
	char* buffer = malloc(s.st_size + 1);
-
 
189
	fread(buffer, 1, s.st_size, f);
-
 
190
	buffer[s.st_size] = 0;
-
 
191
 
-
 
192
	f = freopen(APACHE_AUTHZ, "w+", f);
-
 
193
	lockf(fileno(f), F_LOCK, 0);
-
 
194
	int incr = 0;
-
 
195
	int i;
-
 
196
	char* start = rv_strcat("#%START ", repouser);
-
 
197
	bool discard = false;
-
 
198
	for(i = 0;; i++) {
-
 
199
		if(buffer[i] == '\n' || buffer[i] == 0) {
-
 
200
			char oldc = buffer[i];
-
 
201
			buffer[i] = 0;
-
 
202
 
-
 
203
			char* line = buffer + incr;
-
 
204
			if(strcmp(line, start) == 0) {
-
 
205
				discard = true;
-
 
206
			} else if(discard && strcmp(line, "#%END") == 0) {
-
 
207
				discard = false;
-
 
208
			} else if(!discard) {
-
 
209
				fprintf(f, "%s\n", line);
-
 
210
			}
-
 
211
 
-
 
212
			incr = i + 1;
-
 
213
			if(oldc == 0) break;
-
 
214
		}
-
 
215
	}
-
 
216
 
-
 
217
	lockf(fileno(f), F_ULOCK, 0);
-
 
218
	fclose(f);
-
 
219
}
-
 
220
 
169
bool rv_get_list(const char* repouser, const char* path, void (*handler)(const char* pathname), int* isdir) {
221
bool rv_get_list(const char* repouser, const char* path, void (*handler)(const char* pathname), int* isdir) {
170
	char* svnpath = rv_strcat3(SVN_ROOT, "/", repouser);
222
	char* svnpath = rv_strcat3(SVN_ROOT, "/", repouser);
171
	int pipes[2];
223
	int pipes[2];
172
	*isdir = 0;
224
	*isdir = 0;
173
	pipe(pipes);
225
	pipe(pipes);