tags:

views:

41

answers:

1

I'd like to write an online SVN repository browser. I've decided to implement it as an Apache module, wrapping around the command line client (for the time being). As I'm getting started, I have the following code:

FILE *f;
f = popen("/usr/local/bin/svn cat http://myrepo/svn/shell.c", "r");
char buf[1025];

if (f) {
  ap_rputs("open ok\n", r);
}
else {
  ap_rputs("not open ok\n", r);
}

while (fgets(buf, 1024, f) != NULL) {
  ap_rprintf(r,"%s<br />", buf );
}

ap_rprintf(r, "return: %d\n", pclose(f));

This command fails, with the termination status 256. What error does this correspond to? I've been unable to find this documentation.

Simple calls such as "cat somefile" are successfully printed out. In fact, the call "svn info path-to-a-working-copy" are successful. However I'd like to deal with possibly remote repositories for flexibility.

Do you have any suggestions?

Edit: exit codes are should fall in the range 0-255. This one clearly does not. What does this tell me?

Edit2: as a test case, I created a bash script which would run the desired SVN command, then print its return value. The expected SVN behavior was not encountered, and the script printed "1" as the exit value for SVN. This was visible on the browser end.

+2  A: 

Just a guess: Perhaps svn cat on a URL is causing svn to want to prompt for username/password?

When you created the bash script, did you redirect stderr to stdout to try and catch any error messages?

ZoogieZork
redirecting stderr was a great idea. when i printed it to stdout, I received a warning about authentication, just like you suggested. Thanks!
Willi Ballenthin