10 #include "urlencode.h"
13 * url canonization process
16 /* terrible code, FIXME
18 * few ideas for making ordinary web pages more-or-less browsable
20 * 1) if occurs dir1/dir2/page as url in current pake, mark dir1 as directory
21 * 2) if occurs /dir1/dir2/dir3/page as url, and we are in /dir1/dir2/dir3 add page
22 * 3) what about symlinks to different part of the site?
26 char *prefixes
[] = { "http://", "ftp://", "https://", "mailto:", "/", NULL
};
29 static inline int bad_prefix(char *s
)
32 for (i
=0; prefixes
[i
]; i
++) {
33 if (!strncasecmp(prefixes
[i
], s
, strlen(prefixes
[i
])))
40 void canonize(void *ctx
, char *par
, time_t time
, size_t size
)
42 struct canon
*c
= ctx
;
46 memset(&stb
, 0, sizeof(stb
));
51 if (par
[strlen(par
)-1] == '/') {
52 stb
.st_mode
= S_IFDIR
| 0555;
53 par
[strlen(par
)-1] = 0;
55 stb
.st_mode
= S_IFREG
| 0444;
58 if (strchr(par
, '/') || strchr(par
, '#') || par
[0] == '?')
66 c
->filler(c
->h
, g
.s
, &stb
);