Introduction
Introduction Statistics Contact Development Disclaimer Help
example.c - uriparser - URI parser
git clone git://git.codemadness.org/uriparser
Log
Files
Refs
README
LICENSE
---
example.c (1507B)
---
1 #include <stdio.h>
2
3 #include "util.h"
4
5 void
6 printfields(struct uri *u)
7 {
8 printf("* proto: %s\n", u->proto);
9 printf("* userinfo: %s\n", u->userinfo);
10 printf("* host: %s\n", u->host);
11 printf("* port: %s\n", u->port);
12 printf("* path: %s\n", u->path);
13 printf("* query: %s\n", u->query);
14 printf("* fragment: %s\n", u->fragment);
15 }
16
17 int
18 main(int argc, char *argv[])
19 {
20 struct uri b, u, abs;
21 char buf[4096];
22 int r;
23
24 if (argc < 2 || argc > 3) {
25 fprintf(stderr, "usage: %s <url> [baseurl]\n", argv[0]);
26 return 1;
27 }
28
29 r = uri_parse(argv[1], &u);
30 printf("uri_parse() for %s returned: %d\n", argv[1], r);
31 if (r != -1) {
32 printf("success!\n\nfields for %s:\n", argv[1]);
33 printfields(&u);
34 printf("\n");
35
36 if (argc > 2) {
37 r = uri_parse(argv[2], &b);
38 printf("uri_parse() for %s returned: %d\n", argv…
39 if (r != -1) {
40 printf("success!\n\nfields for %s:\n", a…
41 printfields(&b);
42 printf("\n");
43
44 r = uri_makeabs(&abs, &u, &b);
45 printf("uri_makeabs() for %s and %s retu…
46 if (r != -1) {
47 printf("success!\n\nfields for %…
48 printfields(&abs);
49 r = uri_format(buf, sizeof(buf),…
50 printf("uri_format() for absolut…
51 if (r > 0 && r < sizeof(buf))
52 printf("formatted URI: %…
53 } else {
54 printf("failure!\n");
55 }
56 } else {
57 printf("failure!\n");
58 }
59 }
60 } else {
61 printf("failure!\n");
62 }
63
64 return 0;
65 }
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.