5a31bd | 1998-10-02 | Henrik Grubbström (Grubba) | |
#include <module.h>
|
e793be | 1999-10-10 | Per Hedbor | | #include <stat.h>
|
5a31bd | 1998-10-02 | Henrik Grubbström (Grubba) | |
inherit "module";
|
28bb74 | 2000-02-10 | Martin Nilsson | | constant cvs_version = "$Id: pathinfo.pike,v 1.9 2000/02/10 06:44:08 nilsson Exp $";
|
5a31bd | 1998-10-02 | Henrik Grubbström (Grubba) | | constant thread_safe = 1;
|
29c8dd | 1999-12-28 | Martin Nilsson | | #ifdef PATHINFO_DEBUG
# define PATHINFO_WERR(X) werror("PATHINFO: "+X+"\n");
#else
# define PATHINFO_WERR(X)
#endif
|
28bb74 | 2000-02-10 | Martin Nilsson | | constant module_type = MODULE_LAST;
constant module_name = "PATH_INFO support";
constant module_doc = "Support for PATH_INFO style URLs.";
|
5a31bd | 1998-10-02 | Henrik Grubbström (Grubba) | |
mapping|int last_resort(object id)
{
|
29c8dd | 1999-12-28 | Martin Nilsson | | PATHINFO_WERR(sprintf("Checking %O...", id->not_query));
|
5a31bd | 1998-10-02 | Henrik Grubbström (Grubba) | | if (id->misc->path_info) {
|
29c8dd | 1999-12-28 | Martin Nilsson | | PATHINFO_WERR(sprintf("Been here, done that."));
|
5a31bd | 1998-10-02 | Henrik Grubbström (Grubba) | | return 0;
}
|
b5019b | 1999-03-25 | Kadlecsik Jozsi | |
string query = id->not_query;
|
7ae17d | 1999-10-04 | Per Hedbor | | string pi = "";
|
e793be | 1999-10-10 | Per Hedbor | | while( (search( query[1..], "/" ) != -1) && strlen( query ) > 0 )
|
7ae17d | 1999-10-04 | Per Hedbor | | {
query = reverse(query);
string add_path_info;
sscanf( query, "%[^/]/%s", add_path_info, query );
query = reverse( query );
if( strlen( pi ) )
pi = "/"+reverse( add_path_info )+pi;
else
pi = "/"+add_path_info;
id->misc->path_info = pi;
|
29c8dd | 1999-12-28 | Martin Nilsson | | PATHINFO_WERR(sprintf("Trying: %O (%O)", query, pi));
|
7ae17d | 1999-10-04 | Per Hedbor | | array st = id->conf->stat_file( query, id );
|
e793be | 1999-10-10 | Per Hedbor | | if( st && (st[ ST_SIZE ] > 0))
|
7ae17d | 1999-10-04 | Per Hedbor | | {
id->not_query = query;
|
29c8dd | 1999-12-28 | Martin Nilsson | | PATHINFO_WERR(sprintf("Found: %O:%O",
id->not_query, id->misc->path_info));
|
7ae17d | 1999-10-04 | Per Hedbor | | return 1;
}
}
|
5a31bd | 1998-10-02 | Henrik Grubbström (Grubba) | | return 0;
}
|