Branch: Tag:

1999-10-04

1999-10-04 15:00:28 by Per Hedbor <ph@opera.com>

Slower, but works

Rev: server/modules/misc/pathinfo.pike:1.4

1:   /* -  * $Id: pathinfo.pike,v 1.3 1999/03/25 22:01:22 grubba Exp $ +  * $Id: pathinfo.pike,v 1.4 1999/10/04 15:00:28 per Exp $    *    * PATH_INFO support for Roxen.    *
10:      inherit "module";    - constant cvs_version = "$Id: pathinfo.pike,v 1.3 1999/03/25 22:01:22 grubba Exp $"; + constant cvs_version = "$Id: pathinfo.pike,v 1.4 1999/10/04 15:00:28 per Exp $";   constant thread_safe = 1;      // #define PATHINFO_DEBUG
36:    }       string query = id->not_query; + #if 0    array(int) offsets = Array.map(query/"/", sizeof);       int sum = 0;
71: Inside #if defined(PATHINFO_DEBUG)
  #ifdef PATHINFO_DEBUG    roxen_perror(sprintf("PATHINFO: Directory: %O\n", file));   #endif /* PATHINFO_DEBUG */ -  +  /* Hm. Lets try this: */ +  id->misc->path_info = query[offsets[probe]+1..]; +  id->not_query = file+"/"; +  return 1;    lo = probe + 1;    } else {    hi = probe - 1;    }    } -  /* not_query is zapped by id->conf->stat_file(). */ + #else /* Slower, but it works... */ +  string pi = ""; +  while( (search( query, "/" ) != -1) && strlen( query ) > 0 ) +  { +  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; +  array st = id->conf->stat_file( query, id ); +  if( st ) +  {    id->not_query = query; -  +  return 1; +  } +  } + #endif    return 0;   }