Skip to content

Commit

Permalink
add --relative to testURI
Browse files Browse the repository at this point in the history
Example: testURI --relative --base file:///a/b/c file:///a/x/y

Result: ../x/y
  • Loading branch information
speleo3 authored and veillard committed Nov 29, 2018
1 parent c7461f6 commit 25f13e7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion testURI.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
static const char *base = NULL;
static int escape = 0;
static int debug = 0;
static int relative = 0;

static void handleURI(const char *str) {
int ret;
Expand Down Expand Up @@ -57,7 +58,12 @@ static void handleURI(const char *str) {
}
}
} else {
res = xmlBuildURI((xmlChar *)str, (xmlChar *) base);
if (relative) {
res = xmlBuildRelativeURI((xmlChar *)str, (xmlChar *) base);
} else {
res = xmlBuildURI((xmlChar *)str, (xmlChar *) base);
}

if (res != NULL) {
printf("%s\n", (char *) res);
}
Expand All @@ -74,6 +80,11 @@ static void handleURI(const char *str) {
int main(int argc, char **argv) {
int i, arg = 1;

if ((argc > arg) && (argv[arg] != NULL) &&
(!strcmp(argv[arg], "--relative"))) {
arg++;
relative++;
}
if ((argc > arg) && (argv[arg] != NULL) &&
((!strcmp(argv[arg], "-base")) || (!strcmp(argv[arg], "--base")))) {
arg++;
Expand Down

0 comments on commit 25f13e7

Please sign in to comment.