Roxen.git / server / etc / modules / Roxen.pmod

version» Context lines:

Roxen.git/server/etc/modules/Roxen.pmod:1:   // This is a roxen pike module. Copyright © 1999 - 2001, Roxen IS.   // - // $Id: Roxen.pmod,v 1.150 2002/10/22 08:50:01 jonasw Exp $ + // $Id: Roxen.pmod,v 1.151 2003/02/10 16:23:06 grubba Exp $      #include <roxen.h>   #include <config.h>   #include <version.h>   #include <module.h>   #include <variables.h>   #include <stat.h>   #define roxen roxenp()      #ifdef HTTP_DEBUG
Roxen.git/server/etc/modules/Roxen.pmod:655:   // --- From the old 'roxenlib' file -------------------------------      string extract_query(string from)   {    if(!from) return "";    if(sscanf(from, "%*s?%s%*[ \t\n]", from))    return (from/"\r")[0];    return "";   }    + static string mk_env_var_name(string name) + { +  name = replace(name, " ", "_"); +  string res = ""; +  do { +  string ok_part=""; +  sscanf(name, "%[A-Za-z0-9_]%s", ok_part, name); +  res += ok_part; +  if (sizeof(name)) { +  res += "_"; +  name = name[1..]; +  } +  } while (sizeof(name)); +  return res; + } +    mapping build_env_vars(string f, RequestID id, string path_info)   //! Generate a mapping with environment variables suitable for use   //! with CGI-scripts or SSI scripts etc.   //!   //! @mapping   //! @member string INDEX   //! @member string SCRIPT_NAME   //! @member string PATH_INFO   //! @member string PATH_TRANSLATED   //! @member string DOCUMENT_NAME
Roxen.git/server/etc/modules/Roxen.pmod:785:       mapping hdrs;       if ((hdrs = id->request_headers)) {    foreach(indices(hdrs) - ({ "authorization", "proxy-authorization",    "security-scheme", }), string h) {    string hh = "HTTP_" + replace(upper_case(h),    ({ " ", "-", "\0", "=" }),    ({ "_", "_", "", "_" }));    -  new[hh] = replace(hdrs[h], ({ "\0" }), ({ "" })); +  new[mk_env_var_name(hh)] = replace(hdrs[h], ({ "\0" }), ({ "" }));    }    if (!new["HTTP_HOST"]) {    if(objectp(id->my_fd) && id->my_fd->query_address(1))    new["HTTP_HOST"] = replace(id->my_fd->query_address(1)," ",":");    }    } else {    if(id->misc->host)    new["HTTP_HOST"]=id->misc->host;    else if(objectp(id->my_fd) && id->my_fd->query_address(1))    new["HTTP_HOST"]=replace(id->my_fd->query_address(1)," ",":");
Roxen.git/server/etc/modules/Roxen.pmod:900:   {    mapping(string:string) new = ([]);    string tmp;       if(id->cookies->RoxenUserID)    new["ROXEN_USER_ID"]=id->cookies->RoxenUserID;       new["COOKIES"] = "";    foreach(indices(id->cookies), tmp)    { -  new["COOKIE_"+tmp] = id->cookies[tmp]; -  new["COOKIES"]+= tmp+" "; +  new["COOKIE_"+mk_env_var_name(tmp)] = id->cookies[tmp]; +  new["COOKIES"]+= mk_env_var_name(tmp)+" ";    }       foreach(indices(id->config), tmp)    { -  new["CONFIG_"+replace(tmp, " ", "_")]="true"; +  tmp = mk_env_var_name(tmp); +  new["CONFIG_"+tmp]="true";    if(new["CONFIGS"]) -  new["CONFIGS"] += " " + replace(tmp, " ", "_"); +  new["CONFIGS"] += " " + tmp;    else -  new["CONFIGS"] = replace(tmp, " ", "_"); +  new["CONFIGS"] = tmp;    }       foreach(indices(id->variables), tmp)    { -  string name = replace(tmp," ","_"); +  string name = mk_env_var_name(tmp); +  while(    if (mixed value = id->variables[tmp])    if (!catch (value = (string) value) && (sizeof(value) < 8192)) {    // Some shells/OS's don't like LARGE environment variables    new["QUERY_"+name] = replace(value,"\000"," ");    new["VAR_"+name] = replace(value,"\000","#");    }    // Is it correct to record the names for variables with no values here? /mast    if(new["VARIABLES"])    new["VARIABLES"]+= " " + name;    else    new["VARIABLES"]= name;    }       foreach(indices(id->prestate), tmp)    { -  new["PRESTATE_"+replace(tmp, " ", "_")]="true"; +  tmp = mk_env_var_name(tmp); +  new["PRESTATE_"+tmp]="true";    if(new["PRESTATES"]) -  new["PRESTATES"] += " " + replace(tmp, " ", "_"); +  new["PRESTATES"] += " " + tmp;    else -  new["PRESTATES"] = replace(tmp, " ", "_"); +  new["PRESTATES"] = tmp;    }       foreach(indices(id->supports), tmp)    { -  new["SUPPORTS_"+replace(tmp-",", " ", "_")]="true"; +  tmp = mk_env_var_name(tmp-","); +  new["SUPPORTS_"+tmp]="true";    if (new["SUPPORTS"]) -  new["SUPPORTS"] += " " + replace(tmp, " ", "_"); +  new["SUPPORTS"] += " " + tmp;    else -  new["SUPPORTS"] = replace(tmp, " ", "_"); +  new["SUPPORTS"] = tmp;    }    return new;   }      string strip_config(string from)   //! Remove all 'config' data from the given (local) URL.   {    sscanf(from, "/<%*s>%s", from);    return from;   }