835c6c | 2001-06-17 | Martin Nilsson | |
|
b655bf | 2004-06-30 | Martin Stjernholm | |
|
835c6c | 2001-06-17 | Martin Nilsson | |
|
a89693 | 2001-01-03 | Per Hedbor | | #include <stat.h>
#include <config.h>
|
f7ea0c | 2002-02-06 | Martin Stjernholm | | #include <module.h>
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | #include <variables.h>
|
3e3bab | 2001-01-19 | Per Hedbor | | #include <module_constants.h>
|
d1f2c8 | 2006-05-31 | Martin Stjernholm | | constant cvs_version="$Id: prototypes.pike,v 1.171 2006/05/31 15:33:25 mast Exp $";
|
c2d7aa | 2004-04-13 | Martin Stjernholm | |
#ifdef DAV_DEBUG
#define DAV_WERROR(X...) werror(X)
#else /* !DAV_DEBUG */
#define DAV_WERROR(X...)
#endif /* DAV_DEBUG */
object Roxen;
|
a89693 | 2001-01-03 | Per Hedbor | |
|
119a55 | 2004-05-07 | Martin Stjernholm | |
|
8cedaa | 2004-05-07 | Martin Stjernholm | | constant ignore_identifiers = (<
|
119a55 | 2004-05-07 | Martin Stjernholm | | "cvs_version", "Roxen", "ignore_identifiers"
|
8cedaa | 2004-05-07 | Martin Stjernholm | | >);
|
119a55 | 2004-05-07 | Martin Stjernholm | | static class Variable
|
a89693 | 2001-01-03 | Per Hedbor | | {
constant is_variable = 1;
constant type = "Basic";
string get_warnings();
int get_flags();
void set_flags( int flags );
int check_visibility( RequestID id,
int more_mode,
int expert_mode,
int devel_mode,
int initial,
int|void variable_in_cfif );
void set_invisibility_check_callback( function(RequestID,Variable:int) cb );
function(Variable:void) get_changed_callback( );
void set_changed_callback( function(Variable:void) cb );
void add_changed_callback( function(Variable:void) cb );
function(RequestID,Variable:int) get_invisibility_check_callback() ;
string doc( );
string name( );
string type_hint( );
mixed default_value();
void set_warning( string to );
int set( mixed to );
int low_set( mixed to );
mixed query();
int is_defaulted();
array(string|mixed) verify_set( mixed new_value );
mapping(string:string) get_form_vars( RequestID id );
mixed transform_from_form( string what );
void set_from_form( RequestID id );
string path();
void set_path( string to );
string render_form( RequestID id, void|mapping additional_args );
string render_view( RequestID id );
}
class BasicDefvar
{
mapping(string:Variable) variables=([]);
Variable getvar( string name );
int deflocaledoc( string locale, string variable,
string name, string doc, mapping|void translate );
void set(string var, mixed value);
int killvar(string var);
void setvars( mapping (string:mixed) vars );
Variable defvar(string var, mixed value,
mapping|string|void|object name,
int|void type,
mapping|string|void|object doc_str,
mixed|void misc,
int|function|void not_in_config,
mapping|void option_translations);
mixed query(string|void var, int|void ok);
void definvisvar(string name, mixed value, int type, array|void misc);
}
class StringFile( string data, mixed|void _st )
{
int offset;
string _sprintf()
{
return "StringFile("+strlen(data)+","+offset+")";
}
string read(int nbytes)
{
if(!nbytes)
{
offset = strlen(data);
return data;
}
string d = data[offset..offset+nbytes-1];
offset += strlen(d);
return d;
}
array stat()
{
if( _st ) return (array)_st;
return ({ 0, strlen(data), time(), time(), time(), 0, 0, 0 });
}
void write(mixed ... args)
{
throw( ({ "File not open for write\n", backtrace() }) );
}
void seek(int to)
{
offset = to;
}
}
class ModuleInfo
{
string sname;
string filename;
int last_checked;
int type, multiple_copies;
|
ea262c | 2002-04-17 | Marcus Wellhardh | | int|string locked;
mapping(Configuration:int) config_locked;
|
a89693 | 2001-01-03 | Per Hedbor | | string get_name();
string get_description();
RoxenModule instance( object conf, void|int silent );
void save();
|
fc7f63 | 2005-09-02 | Martin Stjernholm | | void update_with( RoxenModule mod, string what );
|
a89693 | 2001-01-03 | Per Hedbor | | int init_module( string what );
int find_module( string sn );
int check (void|int force);
}
class ModuleCopies
{
mapping copies = ([]);
mixed `[](mixed q )
{
return copies[q];
}
mixed `[]=(mixed q,mixed w )
{
return copies[q]=w;
}
array _indices()
{
return indices(copies);
}
array _values()
{
return values(copies);
}
|
4d7e51 | 2001-01-16 | Martin Nilsson | | string _sprintf( ) { return "ModuleCopies("+sizeof(copies)+")"; }
|
a89693 | 2001-01-03 | Per Hedbor | | }
|
b0c9b8 | 2004-04-30 | Henrik Grubbström (Grubba) | |
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | static constant SimpleNode = Parser.XML.Tree.SimpleNode;
static constant SimpleRootNode = Parser.XML.Tree.SimpleRootNode;
static constant SimpleHeaderNode = Parser.XML.Tree.SimpleHeaderNode;
static constant SimpleTextNode = Parser.XML.Tree.SimpleTextNode;
static constant SimpleElementNode = Parser.XML.Tree.SimpleElementNode;
|
b0c9b8 | 2004-04-30 | Henrik Grubbström (Grubba) | |
|
0ddcae | 2004-05-04 | Martin Stjernholm | |
|
fcfa7b | 2004-05-14 | Henrik Grubbström (Grubba) | | class DAVLock
{
string locktoken;
|
826577 | 2004-04-29 | Martin Stjernholm | |
|
fcfa7b | 2004-05-14 | Henrik Grubbström (Grubba) | | string path;
|
826577 | 2004-04-29 | Martin Stjernholm | |
|
fcfa7b | 2004-05-14 | Henrik Grubbström (Grubba) | | int(0..1) recursive;
|
826577 | 2004-04-29 | Martin Stjernholm | |
|
fcfa7b | 2004-05-14 | Henrik Grubbström (Grubba) | | string|SimpleNode lockscope;
|
826577 | 2004-04-29 | Martin Stjernholm | |
|
fcfa7b | 2004-05-14 | Henrik Grubbström (Grubba) | | string|SimpleNode locktype;
|
826577 | 2004-04-29 | Martin Stjernholm | |
|
fcfa7b | 2004-05-14 | Henrik Grubbström (Grubba) | | int(0..) expiry_delta;
array(SimpleNode) owner;
|
826577 | 2004-04-29 | Martin Stjernholm | |
|
071d47 | 2004-05-06 | Martin Stjernholm | |
|
490832 | 2004-04-29 | Martin Stjernholm | |
|
fcfa7b | 2004-05-14 | Henrik Grubbström (Grubba) | |
int(0..) expiry_time;
static void create(string locktoken, string path, int(0..1) recursive,
string|SimpleNode lockscope, string|SimpleNode locktype,
int(0..) expiry_delta, array(SimpleNode) owner)
{
DAVLock::locktoken = locktoken;
DAVLock::path = path;
DAVLock::recursive = recursive;
DAVLock::lockscope = lockscope;
DAVLock::locktype = locktype;
DAVLock::expiry_delta = expiry_delta;
DAVLock::owner = owner;
if (expiry_delta) {
if (expiry_delta < 0) error("Negative expiry delta!\n");
|
1bb72e | 2006-01-11 | Martin Stjernholm | | expiry_time = time() + expiry_delta;
|
fcfa7b | 2004-05-14 | Henrik Grubbström (Grubba) | | }
}
|
b0c9b8 | 2004-04-30 | Henrik Grubbström (Grubba) | |
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | |
|
b0c9b8 | 2004-04-30 | Henrik Grubbström (Grubba) | |
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | SimpleNode get_xml()
|
b0c9b8 | 2004-04-30 | Henrik Grubbström (Grubba) | | {
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | SimpleElementNode res = SimpleElementNode("DAV:activelock", ([]))->
add_child(SimpleElementNode("DAV:locktype", ([]))->
add_child(stringp(locktype)?
SimpleElementNode(locktype, ([])):locktype))->
add_child(SimpleElementNode("DAV:lockscope", ([]))->
add_child(stringp(lockscope)?
SimpleElementNode(lockscope, ([])):lockscope))->
add_child(SimpleElementNode("DAV:depth", ([]))->
add_child(recursive?
SimpleTextNode("Infinity"):SimpleTextNode("0")));
|
b0c9b8 | 2004-04-30 | Henrik Grubbström (Grubba) | |
if (owner) {
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | SimpleElementNode node;
res->add_child(node = SimpleElementNode("DAV:owner", ([])));
node->replace_children(owner);
|
b0c9b8 | 2004-04-30 | Henrik Grubbström (Grubba) | | }
|
fcfa7b | 2004-05-14 | Henrik Grubbström (Grubba) | | if (expiry_delta) {
res->add_child(SimpleElementNode("DAV:timeout", ([]))->
add_child(SimpleTextNode(sprintf("Second-%d",
expiry_delta))));
} else {
res->add_child(SimpleElementNode("DAV:timeout", ([]))->
add_child(SimpleTextNode("Infinite")));
}
|
b0c9b8 | 2004-04-30 | Henrik Grubbström (Grubba) | |
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | res->add_child(SimpleElementNode("DAV:locktoken", ([]))->
add_child(SimpleElementNode("DAV:href", ([]))->
add_child(SimpleTextNode(locktoken))));
|
b0c9b8 | 2004-04-30 | Henrik Grubbström (Grubba) | |
return res;
}
|
a72041 | 2004-05-14 | Martin Stjernholm | |
static string _sprintf (int flag)
{
return flag == 'O' &&
sprintf ("DAVLock(%O on %O, %s, %s%s)", locktoken, path,
recursive ? "rec" : "norec",
lockscope == "DAV:exclusive" ? "excl" :
lockscope == "DAV:shared" ? "shared" :
sprintf ("%O", lockscope),
locktype == "DAV:write" ? "" : sprintf (", %O", locktype));
}
|
4c87da | 2004-04-28 | Henrik Grubbström (Grubba) | | }
|
091e70 | 2004-05-19 | Henrik Grubbström (Grubba) | |
|
7f66d8 | 2001-08-24 | Martin Nilsson | | class Configuration
|
a89693 | 2001-01-03 | Per Hedbor | | {
inherit BasicDefvar;
constant is_configuration = 1;
mapping enabled_modules = ([]);
mapping(string:array(int)) error_log=([]);
#ifdef PROFILE
|
091e70 | 2004-05-19 | Henrik Grubbström (Grubba) | | mapping(string:array(int)) profile_map = ([]);
|
a89693 | 2001-01-03 | Per Hedbor | | #endif
class Priority
{
string _sprintf()
{
return "Priority()";
}
array (RoxenModule) url_modules = ({ });
array (RoxenModule) logger_modules = ({ });
array (RoxenModule) location_modules = ({ });
array (RoxenModule) filter_modules = ({ });
array (RoxenModule) last_modules = ({ });
array (RoxenModule) first_modules = ({ });
mapping (string:array(RoxenModule)) file_extension_modules = ([ ]);
mapping (RoxenModule:multiset(string)) provider_modules = ([ ]);
}
class DataCache
{
int current_size, max_size, max_file_size;
int hits, misses;
void flush();
|
ac55dd | 2005-12-05 | Henrik Grubbström (Grubba) | | void expire_entry(string url, RequestID id);
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | | void set(string url, string data, mapping meta, int expire, RequestID id);
array(string|mapping(string:mixed)) get(string url, RequestID id);
|
a89693 | 2001-01-03 | Per Hedbor | | void init_from_variables( );
};
array(Priority) allocate_pris();
object throttler;
RoxenModule types_module;
RoxenModule dir_module;
function types_fun;
string name;
int inited;
int requests, sent, hsent, received;
function(string:int) log_function;
DataCache datacache;
int get_config_id();
string get_doc_for( string region, string variable );
string query_internal_location(RoxenModule|void mod);
string query_name();
string comment();
|
0e1557 | 2001-02-23 | Martin Stjernholm | | void unregister_urls();
void stop(void|int asynch);
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | string|array(string) type_from_filename( string file, int|void to,
string|void myext );
|
a89693 | 2001-01-03 | Per Hedbor | |
|
c109fc | 2001-07-21 | Martin Stjernholm | | string get_url();
|
a89693 | 2001-01-03 | Per Hedbor | | array (RoxenModule) get_providers(string provides);
RoxenModule get_provider(string provides);
array(mixed) map_providers(string provides, string fun, mixed ... args);
mixed call_provider(string provides, string fun, mixed ... args);
array(function) file_extension_modules(string ext);
array(function) url_modules();
mapping api_functions(void|RequestID id);
array(function) logger_modules();
array(function) last_modules();
array(function) first_modules();
array location_modules();
array(function) filter_modules();
void init_log_file();
int|mapping check_security(function|object a, RequestID id, void|int slevel);
void invalidate_cache();
void clear_memory_caches();
string examine_return_mapping(mapping m);
|
21d18b | 2004-05-14 | Henrik Grubbström (Grubba) | | multiset(DAVLock) find_locks(string path, int(0..1) recursive,
int(0..1) exclude_shared, RequestID id);
DAVLock|LockFlag check_locks(string path, int(0..1) recursive, RequestID id);
|
a72041 | 2004-05-14 | Martin Stjernholm | | mapping(string:mixed) unlock_file(string path, DAVLock lock, RequestID|int(0..0) id);
|
1894be | 2004-05-14 | Henrik Grubbström (Grubba) | | int expire_locks(RequestID id);
void refresh_lock(DAVLock lock);
|
21d18b | 2004-05-14 | Henrik Grubbström (Grubba) | | mapping(string:mixed)|DAVLock lock_file(string path,
int(0..1) recursive,
string lockscope,
string locktype,
int(0..) expiry_delta,
array(Parser.XML.Tree.Node) owner,
RequestID id);
|
a89693 | 2001-01-03 | Per Hedbor | | mapping|int(-1..0) low_get_file(RequestID id, int|void no_magic);
mapping get_file(RequestID id, int|void no_magic, int|void internal_get);
array(string) find_dir(string file, RequestID id, void|int(0..1) verbose);
|
ce6427 | 2001-01-14 | Martin Nilsson | | array(int)|object(Stdio.Stat) stat_file(string file, RequestID id);
|
d72008 | 2004-04-19 | Martin Stjernholm | | array open_file(string fname, string mode, RequestID id, void|int ig, void|int rc);
|
a89693 | 2001-01-03 | Per Hedbor | | mapping(string:array(mixed)) find_dir_stat(string file, RequestID id);
array access(string file, RequestID id);
string real_file(string file, RequestID id);
int|string try_get_file(string s, RequestID id,
int|void status, int|void nocache,
|
6a613a | 2002-06-17 | Anders Johansson | | int|void not_internal, mapping|void result_mapping);
|
2fbed1 | 2001-09-13 | Martin Nilsson | | int(0..1) is_file(string virt_path, RequestID id, int(0..1)|void internal);
|
a89693 | 2001-01-03 | Per Hedbor | | void start(int num);
void save_me();
int save_one( RoxenModule o );
RoxenModule reload_module( string modname );
RoxenModule enable_module( string modname, RoxenModule|void me,
ModuleInfo|void moduleinfo,
|
7902be | 2002-04-09 | Marcus Wellhardh | | int|void nostart,
int|void nosave );
|
a89693 | 2001-01-03 | Per Hedbor | | void call_start_callbacks( RoxenModule me,
ModuleInfo moduleinfo,
ModuleCopies module );
void call_low_start_callbacks( RoxenModule me,
ModuleInfo moduleinfo,
ModuleCopies module );
int disable_module( string modname, int|void nodest );
int add_modules( array(string) mods, int|void now );
RoxenModule find_module(string name);
|
850c28 | 2001-01-10 | Per Hedbor | | #if ROXEN_COMPAT < 2.2
Sql.Sql sql_cache_get(string what);
Sql.Sql sql_connect(string db);
#endif
|
a89693 | 2001-01-03 | Per Hedbor | | void enable_all_modules();
void low_init(void|int modules_already_enabled);
string parse_rxml(string what, RequestID id,
void|Stdio.File file,
void|mapping defines );
void add_parse_module (RoxenModule mod);
void remove_parse_module (RoxenModule mod);
string real_file(string a, RequestID b);
|
649529 | 2001-01-19 | Per Hedbor | |
mapping authenticate_throw( RequestID id, string realm,
UserDB|void database,
AuthModule|void method);
User authenticate( RequestID id,
UserDB|void database,
AuthModule|void method );
array(AuthModule) auth_modules();
array(UserDB) user_databases();
|
e3f466 | 2001-01-19 | Per Hedbor | | AuthModule find_auth_module( string name );
UserDB find_user_database( string name );
|
a89693 | 2001-01-03 | Per Hedbor | | static string _sprintf( )
{
return "Configuration("+name+")";
}
}
|
7f66d8 | 2001-08-24 | Martin Nilsson | |
|
a89693 | 2001-01-03 | Per Hedbor | | class Protocol
{
inherit BasicDefvar;
|
a9fa0d | 2001-07-21 | Martin Stjernholm | |
|
a89693 | 2001-01-03 | Per Hedbor | | constant name = "unknown";
|
a9fa0d | 2001-07-21 | Martin Stjernholm | |
constant prot_name = "unknown";
|
a89693 | 2001-01-03 | Per Hedbor | | constant supports_ipless = 0;
constant requesthandlerfile = "";
constant default_port = 4711;
int bound;
int refs;
program requesthandler;
string path;
int port;
string ip;
array(string) sorted_urls = ({});
mapping(string:mapping) urls = ([]);
|
ea65f7 | 2001-07-21 | Martin Stjernholm | | mapping(Configuration:mapping) conf_data = ([]);
|
a89693 | 2001-01-03 | Per Hedbor | | void ref(string url, mapping data);
void unref(string url);
Configuration find_configuration_for_url( string url, RequestID id,
int|void no_default );
string get_key();
void save();
void restore();
};
|
e0ffe3 | 2001-02-05 | Per Hedbor | | class FakedVariables( mapping real_variables )
{
|
e08587 | 2005-11-24 | Henrik Grubbström (Grubba) | |
|
e0ffe3 | 2001-02-05 | Per Hedbor | | static array _indices()
{
return indices( real_variables );
}
static array _values()
{
return map( _indices(), `[] );
}
static mixed fix_value( mixed what )
{
if( !what ) return what;
if( !arrayp(what) ) return what;
if( sizeof( what ) == 1 )
return what[0];
return what*"\0";
}
static mixed `[]( string ind ) {
return fix_value( real_variables[ ind ] );
}
static mixed `->(string ind ) {
return `[]( ind );
}
static mixed `[]=( string ind, mixed what ) {
real_variables[ ind ] = ({ what });
return what;
}
static mixed `->=(string ind, mixed what ) {
return `[]=( ind,what );
}
static mixed _m_delete( mixed what ) {
|
91d3c3 | 2001-03-12 | Martin Nilsson | |
|
e0ffe3 | 2001-02-05 | Per Hedbor | | return fix_value( m_delete( real_variables, what ) );
}
static int _equal( mixed what ) {
return `==(what);
}
static int `==( mixed what ) {
if( mappingp( what ) && (real_variables == what) )
return 1;
}
static string _sprintf( int f )
{
switch( f )
{
case 'O':
return sprintf( "FakedVariables(%O)", real_variables );
default:
return sprintf( sprintf("%%%c", f ), real_variables );
}
}
static this_program `|( mapping what )
{
foreach( indices(what), string q )`[]=( q,what[q] );
return this_object();
}
static this_program `+=( mapping what )
{
foreach( indices(what), string q )`[]=( q,what[q] );
return this_object();
}
static this_program `+( mapping what )
{
foreach( indices(what), string q )`[]=( q,what[q] );
return this_object();
}
|
e734d5 | 2001-02-18 | Mirar (Pontus Hagland) | |
static mapping cast(string to)
{
if (to[..6]=="mapping")
|
3ce592 | 2001-02-18 | Mirar (Pontus Hagland) | | {
array v=indices(real_variables);
return mkmapping(v,map(v,`[]));
}
|
e734d5 | 2001-02-18 | Mirar (Pontus Hagland) | | error("can't cast to %O\n",to);
}
|
e0ffe3 | 2001-02-05 | Per Hedbor | | }
|
13b353 | 2002-10-25 | Martin Stjernholm | | class PrefLanguages
{
int decoded=0;
int sorted=0;
array(string) subtags=({});
array(string) languages=({});
array(float) qualities=({});
|
876628 | 2004-05-05 | Marcus Wellhardh | | static string _sprintf(int c, mapping|void attrs)
{
return sprintf("PrefLanguages(%O)", get_languages());
}
|
13b353 | 2002-10-25 | Martin Stjernholm | | array(string) get_languages() {
sort_lang();
return languages;
}
string get_language() {
if(!languages || !sizeof(languages)) return 0;
sort_lang();
return languages[0];
}
array(float) get_qualities() {
sort_lang();
return qualities;
}
float get_quality() {
if(!qualities || !sizeof(qualities)) return 0.0;
sort_lang();
return qualities[0];
}
void set_sorted(array(string) lang, void|array(float) q) {
languages=lang;
if(q && sizeof(q)==sizeof(lang))
qualities=q;
else
qualities=({1.0})*sizeof(lang);
sorted=1;
decoded=1;
}
void sort_lang() {
if(sorted && decoded) return;
array(float) q;
array(string) s=reverse(languages)-({""}), u=({});
if(!decoded) {
q=({});
s=Array.map(s, lambda(string x) {
float n=1.0;
string sub="";
sscanf(lower_case(x), "%s;q=%f", x, n);
if(n==0.0) return "";
sscanf(x, "%s-%s", x, sub);
|
2d722b | 2006-04-19 | Marcus Wellhardh | | if(x == "" ) return "";
|
13b353 | 2002-10-25 | Martin Stjernholm | | q+=({n});
u+=({sub});
return x;
});
s-=({""});
decoded=1;
}
else
q=reverse(qualities);
sort(q,s,u);
languages=reverse(s);
qualities=reverse(q);
subtags=reverse(u);
sorted=1;
}
}
|
48b411 | 2003-02-05 | Jonas Wallden | |
|
b19253 | 2004-05-25 | Martin Stjernholm | | typedef function(CacheKey,mixed...:void) CacheActivationCB;
|
48b411 | 2003-02-05 | Jonas Wallden | |
|
b19253 | 2004-05-25 | Martin Stjernholm | | class CacheKey
{
|
3751a5 | 2004-05-18 | Martin Stjernholm | | #if ID_CACHEKEY_DEBUG
|
b19253 | 2004-05-25 | Martin Stjernholm | | RoxenDebug.ObjectMarker __marker = RoxenDebug.ObjectMarker (this);
#endif
static array(array(CacheActivationCB|array)) activation_cbs;
static void create (void|int activate_immediately)
{
if (!activate_immediately) activation_cbs = ({});
}
void add_activation_cb (CacheActivationCB cb, mixed... args)
|
5c5d65 | 2004-05-25 | Martin Stjernholm | |
|
b19253 | 2004-05-25 | Martin Stjernholm | |
{
if (activation_cbs)
activation_cbs += ({({cb, args})});
else
cb (this, @args);
}
|
975069 | 2004-06-01 | Martin Stjernholm | | int activate()
|
b19253 | 2004-05-25 | Martin Stjernholm | |
|
975069 | 2004-06-01 | Martin Stjernholm | |
|
b19253 | 2004-05-25 | Martin Stjernholm | | {
if (array(array(CacheActivationCB|array)) cbs = activation_cbs) {
activation_cbs = 0;
foreach (cbs, [CacheActivationCB cb, array args])
cb (this, @args);
|
975069 | 2004-06-01 | Martin Stjernholm | | return sizeof (cbs);
|
b19253 | 2004-05-25 | Martin Stjernholm | | }
|
975069 | 2004-06-01 | Martin Stjernholm | | return 0;
|
b19253 | 2004-05-25 | Martin Stjernholm | | }
int activated()
{
return !activation_cbs;
}
|
975069 | 2004-06-01 | Martin Stjernholm | | int activate_if_necessary()
|
b19253 | 2004-05-25 | Martin Stjernholm | | {
if (array(array(CacheActivationCB|array)) cbs = activation_cbs) {
|
975069 | 2004-06-01 | Martin Stjernholm | | if (sizeof (cbs)) {
if (this)
activation_cbs = 0;
foreach (cbs, [CacheActivationCB cb, array args])
cb (this, @args);
return 1;
}
|
b19253 | 2004-05-25 | Martin Stjernholm | | }
|
975069 | 2004-06-01 | Martin Stjernholm | | return 0;
|
b19253 | 2004-05-25 | Martin Stjernholm | | }
string _sprintf (int flag)
{
return flag == 'O' && ("CacheKey()"
#ifdef ID_CACHEKEY_DEBUG
+ (__marker ? "[" + __marker->count + "]" : "")
|
3751a5 | 2004-05-18 | Martin Stjernholm | | #endif
|
b19253 | 2004-05-25 | Martin Stjernholm | | );
}
|
3751a5 | 2004-05-18 | Martin Stjernholm | | }
|
b19253 | 2004-05-25 | Martin Stjernholm | |
static function _charset_decoder_func;
|
a89693 | 2001-01-03 | Per Hedbor | | class RequestID
|
7f66d8 | 2001-08-24 | Martin Nilsson | |
|
a89693 | 2001-01-03 | Per Hedbor | |
{
|
b19253 | 2004-05-25 | Martin Stjernholm | | #ifdef ID_OBJ_DEBUG
RoxenDebug.ObjectMarker __marker = RoxenDebug.ObjectMarker (this);
#endif
|
a89693 | 2001-01-03 | Per Hedbor | | Configuration conf;
Protocol port_obj;
int time;
string raw_url;
int do_not_disconnect;
|
e0ffe3 | 2001-02-05 | Per Hedbor | | mapping (string:array) real_variables;
|
a89693 | 2001-01-03 | Per Hedbor | |
|
e0ffe3 | 2001-02-05 | Per Hedbor | |
|
a89693 | 2001-01-03 | Per Hedbor | |
|
5aca9b | 2001-09-28 | Martin Stjernholm | | mapping(string:mixed)|FakedVariables variables;
|
e0ffe3 | 2001-02-05 | Per Hedbor | |
|
964473 | 2001-11-27 | Martin Stjernholm | | mapping (string:mixed) misc;
|
a89693 | 2001-01-03 | Per Hedbor | |
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
|
ac55dd | 2005-12-05 | Henrik Grubbström (Grubba) | |
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
|
ac55dd | 2005-12-05 | Henrik Grubbström (Grubba) | |
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
|
ac55dd | 2005-12-05 | Henrik Grubbström (Grubba) | |
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
|
ac55dd | 2005-12-05 | Henrik Grubbström (Grubba) | |
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
|
ac55dd | 2005-12-05 | Henrik Grubbström (Grubba) | |
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
|
ac55dd | 2005-12-05 | Henrik Grubbström (Grubba) | |
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
|
ac55dd | 2005-12-05 | Henrik Grubbström (Grubba) | |
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
|
ac55dd | 2005-12-05 | Henrik Grubbström (Grubba) | |
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
|
a89693 | 2001-01-03 | Per Hedbor | |
|
99e65a | 2003-06-18 | Tomas Nilsson | | mapping (string:mixed) connection_misc;
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | |
|
e1559d | 2005-12-09 | Henrik Grubbström (Grubba) | |
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | |
static class CookieJar
{
|
f060a0 | 2006-04-20 | Henrik Grubbström (Grubba) | |
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | | static mapping(string:string) jar = ([]);
|
f060a0 | 2006-04-20 | Henrik Grubbström (Grubba) | |
static mapping(string:string) eaten = ([]);
|
cc70a4 | 2005-12-07 | Henrik Grubbström (Grubba) | | static void create(string|array(string)|void contents)
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | | {
if(!contents)
return;
array tmp = arrayp(contents) ? contents : ({ contents});
foreach(tmp, string cookieheader) {
foreach(((cookieheader/";") - ({""})), string c)
{
string name, value;
while(sizeof(c) && c[0]==' ') c=c[1..];
if(sscanf(c, "%s=%s", name, value) == 2)
{
|
dbd94b | 2005-12-07 | Henrik Grubbström (Grubba) | | value=_Roxen.http_decode_string(value);
name=_Roxen.http_decode_string(name);
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | | jar[ name ]=value;
#ifdef OLD_RXML_CONFIG
if( (name == "RoxenConfig") && strlen(value) )
config = mkmultiset( value/"," );
#endif
}
}
}
}
static string `->(string cookie)
{
|
6b423e | 2006-05-22 | Jonas Wallden | | if (supports && zero_type(eaten[cookie])) {
|
989262 | 2006-05-17 | Anders Johansson | |
register_vary_callback("User-Agent",
lambda(string ignored, RequestID id)
{
return (string)!has_value(id->client, "MSIE");
});
if (supports->vary) {
register_vary_callback("Cookie", Roxen->get_cookie_callback(cookie));
} else {
register_vary_callback("User-Agent",
Roxen->get_cookie_callback(cookie));
}
|
f060a0 | 2006-04-20 | Henrik Grubbström (Grubba) | | }
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | | return jar[cookie];
}
static string `[](mixed cookie)
{
|
dbd94b | 2005-12-07 | Henrik Grubbström (Grubba) | | if (stringp(cookie)) {
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | | return `->(cookie);
}
return UNDEFINED;
}
static string `->=(string cookie, string value)
{
|
f060a0 | 2006-04-20 | Henrik Grubbström (Grubba) | | if (zero_type(eaten[cookie])) {
eaten[cookie] = jar[cookie];
}
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | | return jar[cookie] = value;
}
static string `[]=(mixed cookie, string value)
{
return `->=(cookie, value);
}
|
dbd94b | 2005-12-07 | Henrik Grubbström (Grubba) | | static string _m_delete(string cookie)
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | | {
|
f060a0 | 2006-04-20 | Henrik Grubbström (Grubba) | | if (zero_type(eaten[cookie])) {
eaten[cookie] = jar[cookie];
}
|
dbd94b | 2005-12-07 | Henrik Grubbström (Grubba) | | return m_delete(jar, cookie);
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | | }
static array(string) _indices()
{
register_vary_callback("Cookie");
return indices(jar);
}
static array(string) _values()
{
register_vary_callback("Cookie");
return values(jar);
}
static int _sizeof()
{
register_vary_callback("Cookie");
return sizeof(jar);
}
|
f060a0 | 2006-04-20 | Henrik Grubbström (Grubba) | | static mapping(string:string) `+(mapping(string:string) other)
|
45004c | 2005-12-09 | Martin Stjernholm | | {
|
e1559d | 2005-12-09 | Henrik Grubbström (Grubba) | | register_vary_callback("Cookie");
|
45004c | 2005-12-09 | Martin Stjernholm | | return jar + other;
}
|
f060a0 | 2006-04-20 | Henrik Grubbström (Grubba) | | static mapping(string:string) ``+(mapping(string:string) other)
|
45004c | 2005-12-09 | Martin Stjernholm | | {
|
e1559d | 2005-12-09 | Henrik Grubbström (Grubba) | | register_vary_callback("Cookie");
|
45004c | 2005-12-09 | Martin Stjernholm | | return other + jar;
}
|
f060a0 | 2006-04-20 | Henrik Grubbström (Grubba) | |
static mapping(string:string) `~()
{
return jar + eaten;
}
|
3583aa | 2005-12-07 | Henrik Grubbström (Grubba) | | static string _sprintf(int fmt)
{
|
45004c | 2005-12-09 | Martin Stjernholm | | return fmt == 'O' && sprintf("CookieJar(%O)", jar);
|
3583aa | 2005-12-07 | Henrik Grubbström (Grubba) | | }
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | | }
|
f060a0 | 2006-04-20 | Henrik Grubbström (Grubba) | | CookieJar|mapping(string:string) cookies;
|
a89693 | 2001-01-03 | Per Hedbor | |
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | |
|
f060a0 | 2006-04-20 | Henrik Grubbström (Grubba) | |
|
ad7da4 | 2005-12-07 | Henrik Grubbström (Grubba) | |
void init_cookies()
{
if (!cookies) {
cookies = CookieJar(request_headers["cookie"]);
}
}
|
a89693 | 2001-01-03 | Per Hedbor | |
|
558869 | 2001-04-22 | Per Hedbor | | mapping (string:array(string)|string) request_headers;
|
a89693 | 2001-01-03 | Per Hedbor | |
mapping (string:mixed) throttle;
mapping (string:mixed) client_var;
multiset(string) prestate;
multiset(string) config;
multiset(string) supports;
multiset(string) pragma;
array(string) client;
array(string) referer;
Stdio.File my_fd;
string prot;
string clientprot;
string method;
string realfile;
string virtfile;
string rest_query;
string raw;
string query;
string not_query;
|
b66eae | 2005-01-14 | Martin Stjernholm | |
|
a89693 | 2001-01-03 | Per Hedbor | |
string extra_extension;
string data;
string leftovers;
|
9689f1 | 2002-09-03 | Martin Stjernholm | | string rawauth, realauth;
|
a89693 | 2001-01-03 | Per Hedbor | | string since;
string remoteaddr;
string host;
|
632261 | 2004-05-06 | Martin Stjernholm | | multiset(string) cache_status = (<>);
|
b5f3de | 2006-04-20 | Henrik Grubbström (Grubba) | |
|
46d4cb | 2001-08-22 | Martin Stjernholm | |
|
b5f3de | 2006-04-20 | Henrik Grubbström (Grubba) | |
|
46d4cb | 2001-08-22 | Martin Stjernholm | |
|
7fafb8 | 2001-07-25 | Johan Sundström | | object root_id;
|
a89693 | 2001-01-03 | Per Hedbor | | static void create(Stdio.File fd, Protocol port, Configuration conf){}
void send(string|object what, int|void len){}
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | static SimpleNode xml_data;
|
24e914 | 2003-04-22 | Henrik Grubbström (Grubba) | |
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | SimpleNode get_xml_data()
|
24e914 | 2003-04-22 | Henrik Grubbström (Grubba) | | {
|
b105b5 | 2003-06-11 | Henrik Grubbström (Grubba) | | if (!sizeof(data)) return 0;
|
24e914 | 2003-04-22 | Henrik Grubbström (Grubba) | | if (xml_data) return xml_data;
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | DAV_WERROR("Parsing XML data: %O\n", data);
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | return xml_data =
Parser.XML.Tree.simple_parse_input(data,
0,
Parser.XML.Tree.PARSE_ENABLE_NAMESPACES);
|
24e914 | 2003-04-22 | Henrik Grubbström (Grubba) | | }
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | |
|
53cb8b | 2004-05-06 | Henrik Grubbström (Grubba) | | static mapping(string:array(array(array(string)))) if_data;
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | |
|
2550a4 | 2004-05-17 | Martin Stjernholm | | #ifdef IF_HEADER_DEBUG
#define IF_HDR_MSG(X...) werror (X)
#else
#define IF_HDR_MSG(X...)
#endif
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | |
|
1093e4 | 2004-05-05 | Henrik Grubbström (Grubba) | |
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | |
|
1093e4 | 2004-05-05 | Henrik Grubbström (Grubba) | |
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | | mapping(string:array(array(array(string)))) get_if_data()
{
|
2550a4 | 2004-05-17 | Martin Stjernholm | | if (if_data) {
IF_HDR_MSG ("get_if_data(): Returning cached result\n");
return sizeof(if_data) && if_data;
}
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | |
|
53cb8b | 2004-05-06 | Henrik Grubbström (Grubba) | | if_data = ([]);
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | |
string raw_header;
|
2550a4 | 2004-05-17 | Martin Stjernholm | | if (!(raw_header = request_headers->if)) {
IF_HDR_MSG ("get_if_data(): No if header\n");
return 0;
}
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | |
array(array(string|int|array(array(string)))) decoded_if =
MIME.decode_words_tokenized_labled(raw_header);
|
2550a4 | 2004-05-17 | Martin Stjernholm | | #if 0
IF_HDR_MSG("get_if_data(): decoded_if: %O\n", decoded_if);
#endif
if (!sizeof(decoded_if)) {
IF_HDR_MSG("Got only whitespace.\n");
return 0;
}
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | |
mapping(string:array(array(array(string)))) res = ([ 0: ({}) ]);
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | string tmp_resource;
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | | string resource;
foreach(decoded_if, array(string|int|array(array(string))) symbol) {
switch (symbol[0]) {
case "special":
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | switch(symbol[1]) {
case '<': tmp_resource = ""; break;
case '>':
resource = tmp_resource;
tmp_resource = 0;
catch { resource = Standards.URI(resource)->path; };
if (!sizeof(resource) || (resource[-1] != '/')) resource += "/";
if (!res[resource])
res[resource] = ({});
break;
default:
if (tmp_resource) tmp_resource += sprintf("%c", symbol[1]);
break;
}
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | | break;
case "word":
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | case "domain-literal":
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | |
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | if (!tmp_resource) return 0;
tmp_resource += symbol[1];
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | | break;
case "comment":
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | if (tmp_resource) {
tmp_resource += "(" + symbol[1][0][0] + ")";
break;
}
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | | array(array(string|int|array(array(string)))) sub_expr =
MIME.decode_words_tokenized_labled(symbol[1][0][0]);
int i;
array(array(string)) expr = ({});
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | string tmp_key;
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | | for (i = 0; i < sizeof(sub_expr); i++) {
switch(sub_expr[i][0]) {
case "special":
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | switch(sub_expr[i][1]) {
case '<': tmp_key = ""; break;
case '>':
|
2550a4 | 2004-05-17 | Martin Stjernholm | | if (!tmp_key) {
IF_HDR_MSG("No tmp_key.\n");
return 0;
}
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | expr += ({ ({ "key", tmp_key }) });
tmp_key = 0;
break;
default:
if (tmp_key) tmp_key += sprintf("%c", sub_expr[i][1]);
break;
}
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | | break;
case "domain-literal":
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | if (tmp_key) {
tmp_key += sub_expr[i][1];
break;
}
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | |
string etag = sub_expr[i][1];
|
e589e5 | 2004-05-10 | Henrik Grubbström (Grubba) | | sscanf(etag, "[%s]", etag);
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | | expr += ({ ({ "etag", etag }) });
break;
case "word":
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | if (tmp_key) {
tmp_key += sub_expr[i][1];
break;
}
if (lower_case(sub_expr[i][1]) == "not") {
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | |
expr += ({ ({ "not", 0 }) });
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | break;
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | | }
|
2550a4 | 2004-05-17 | Martin Stjernholm | | IF_HDR_MSG("Word outside key: %O\n", sub_expr[i][1]);
report_debug("Syntax error in if-header: %O\n", raw_header);
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | return 0;
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | | }
}
|
2550a4 | 2004-05-17 | Martin Stjernholm | | if (tmp_key) {
IF_HDR_MSG("Active tmp_key: %O\n", tmp_key);
report_debug("Syntax error in if-header: %O\n", raw_header);
return 0;
}
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | | res[resource] += ({ expr });
break;
default:
report_debug("Syntax error in if-header: %O\n", raw_header);
return 0;
}
}
|
2550a4 | 2004-05-17 | Martin Stjernholm | | if (tmp_resource) {
IF_HDR_MSG("Active tmp_resource: %O\n", tmp_resource);
report_debug("Syntax error in if-header: %O\n", raw_header);
return 0;
}
IF_HDR_MSG("get_if_data(): Parsed if header: %s:\n"
"%O\n", raw_header, res);
|
76d119 | 2004-05-05 | Henrik Grubbström (Grubba) | | return if_data = res;
}
|
24e914 | 2003-04-22 | Henrik Grubbström (Grubba) | |
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
|
ac55dd | 2005-12-05 | Henrik Grubbström (Grubba) | |
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
void register_vary_callback(string|void vary,
function(string, RequestID: string)|void cb)
{
if (!misc->vary) {
misc->vary = (< vary || "*" >);
} else {
misc->vary[vary || "*"] = 1;
}
|
861751 | 2005-12-05 | Henrik Grubbström (Grubba) | | if (vary) vary = lower_case(vary);
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | | if (!misc->vary_cb_set) {
misc->vary_cb_set = (< cb || vary >);
misc->vary_cb_order = ({ cb || vary });
return;
}
if (misc->vary_cb_set[cb || vary]) {
return;
}
if (vary && misc->vary_cb_set[vary]) {
return;
}
misc->vary_cb_set[cb || vary] = 1;
misc->vary_cb_order += ({ cb || vary });
}
|
543060 | 2001-07-21 | Martin Stjernholm | | static string cached_url_base;
string url_base()
|
3c4961 | 2001-07-21 | Martin Stjernholm | |
|
543060 | 2001-07-21 | Martin Stjernholm | |
{
if (!cached_url_base) {
string tmp;
|
3c4961 | 2001-07-21 | Martin Stjernholm | |
if (port_obj) {
string host = port_obj->conf_data[conf]->hostname;
if (host == "*" && conf && sizeof (host = conf->get_url()))
if (sscanf (host, "%*s://%[^:/]", host) < 2)
host = port_obj->ip;
cached_url_base = port_obj->prot_name + "://" + host;
|
543060 | 2001-07-21 | Martin Stjernholm | | if (port_obj->port != port_obj->default_port)
cached_url_base += ":" + port_obj->port;
}
|
3c4961 | 2001-07-21 | Martin Stjernholm | |
else if (conf && sizeof (tmp = conf->get_url()))
cached_url_base = tmp[..sizeof (tmp) - 2];
|
543060 | 2001-07-21 | Martin Stjernholm | |
|
3c4961 | 2001-07-21 | Martin Stjernholm | |
else return cached_url_base = "";
|
543060 | 2001-07-21 | Martin Stjernholm | |
if (string p = misc->site_prefix_path) cached_url_base += p;
cached_url_base += "/";
}
return cached_url_base;
}
|
f7ea0c | 2002-02-06 | Martin Stjernholm | | void add_response_header (string name, string value)
|
b42193 | 2002-01-29 | Martin Stjernholm | |
|
f7ea0c | 2002-02-06 | Martin Stjernholm | | {
mapping hdrs = misc->defines && misc->defines[" _extra_heads"] || misc->moreheads;
if (!hdrs) hdrs = misc->moreheads = ([]);
array|string cur_val = hdrs[name];
if(cur_val) {
if(arrayp(cur_val)) {
if (!has_value(cur_val, value))
cur_val += ({ value });
} else {
if (cur_val != value)
cur_val = ({ cur_val, value });
}
}
else
cur_val = value;
if (hdrs == misc->moreheads)
hdrs[name] = cur_val;
else if (object ctx = RXML_CONTEXT)
ctx->set_var (name, cur_val, "header");
else
hdrs[name] = cur_val;
}
|
b42193 | 2002-01-29 | Martin Stjernholm | |
|
f7ea0c | 2002-02-06 | Martin Stjernholm | | void set_response_header (string name, string value)
|
b42193 | 2002-01-29 | Martin Stjernholm | |
|
f7ea0c | 2002-02-06 | Martin Stjernholm | | {
if (misc->defines && misc->defines[" _extra_heads"]) {
misc->defines[" _extra_heads"][name] = value;
if (object ctx = RXML_CONTEXT)
ctx->signal_var_change (name, "header");
}
else {
if (!misc->moreheads) misc->moreheads = ([]);
misc->moreheads[name] = value;
}
}
|
b42193 | 2002-01-29 | Martin Stjernholm | |
|
ae77c4 | 2004-05-05 | Martin Stjernholm | | static MultiStatus multi_status;
MultiStatus get_multi_status()
|
8cedaa | 2004-05-07 | Martin Stjernholm | |
|
a5303e | 2004-06-28 | Martin Stjernholm | |
|
8cedaa | 2004-05-07 | Martin Stjernholm | |
|
ae77c4 | 2004-05-05 | Martin Stjernholm | |
|
8cedaa | 2004-05-07 | Martin Stjernholm | |
|
ae77c4 | 2004-05-05 | Martin Stjernholm | |
{
if (!multi_status) multi_status = MultiStatus();
return multi_status;
}
int multi_status_size()
{
return multi_status && multi_status->num_responses();
}
void set_status_for_path (string path, int status_code,
string|void message, mixed... args)
|
197e81 | 2004-05-06 | Martin Stjernholm | |
|
ae77c4 | 2004-05-05 | Martin Stjernholm | |
{
if (sizeof (args)) message = sprintf (message, @args);
ASSERT_IF_DEBUG (has_prefix (path, "/"));
get_multi_status()->add_status (url_base() + path[1..],
status_code, message);
}
void set_status_for_url (string url, int status_code,
string|void message, mixed... args)
{
if (sizeof (args)) message = sprintf (message, @args);
get_multi_status()->add_status (url, status_code, message);
}
|
48b411 | 2003-02-05 | Jonas Wallden | |
|
632261 | 2004-05-06 | Martin Stjernholm | | array(string) output_charset = ({});
|
9689f1 | 2002-09-03 | Martin Stjernholm | | string input_charset;
void set_output_charset( string|function to, int|void mode )
{
|
80f43b | 2003-03-24 | Martin Stjernholm | | if (object ctx = RXML_CONTEXT)
ctx->add_p_code_callback ("set_output_charset", to, mode);
|
632261 | 2004-05-06 | Martin Stjernholm | | if( search( output_charset, to ) != -1 )
|
9689f1 | 2002-09-03 | Martin Stjernholm | | return;
|
632261 | 2004-05-06 | Martin Stjernholm | | switch( mode )
|
9689f1 | 2002-09-03 | Martin Stjernholm | | {
case 0:
output_charset = ({ to });
break;
case 1:
if( !sizeof( output_charset ) )
output_charset = ({ to });
break;
case 2:
|
66d363 | 2005-04-12 | Anders Johansson | | if (sizeof (output_charset) &&
(!stringp (to) || !stringp (output_charset[0])))
error ("Can't join charsets with functions (%O with %O).\n",
to, output_charset[0]);
|
9689f1 | 2002-09-03 | Martin Stjernholm | | output_charset |= ({ to });
break;
}
}
|
66d363 | 2005-04-12 | Anders Johansson | | string|function(string:string) get_output_charset()
{
string charset;
function(string:string) encoder;
foreach( output_charset, string|function f )
[charset,encoder] = join_charset(charset, f, encoder, 0);
return charset || encoder;
}
|
48b411 | 2003-02-05 | Jonas Wallden | | static string charset_name(function|string what)
{
switch (what) {
case string_to_unicode: return "ISO10646-1";
case string_to_utf8: return "UTF-8";
default: return upper_case((string) what);
}
}
static function charset_function(function|string what, int allow_entities)
{
switch (what) {
case "ISO-10646-1":
case "ISO10646-1":
case string_to_unicode:
return string_to_unicode;
case "UTF-8":
case string_to_utf8:
return string_to_utf8;
default:
catch {
function fallback_func =
allow_entities &&
lambda(string char) {
return sprintf("&#x%x;", char[0]);
};
_charset_decoder_func =
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | _charset_decoder_func || Roxen->_charset_decoder;
|
48b411 | 2003-02-05 | Jonas Wallden | | return
_charset_decoder_func(Locale.Charset.encoder((string) what, "",
fallback_func))
->decode;
};
}
return lambda(string what) { return what; };
}
static array(string) join_charset(string old,
function|string add,
function oldcodec,
int allow_entities)
{
switch (old && upper_case(old)) {
case 0:
return ({ charset_name(add), charset_function(add, allow_entities) });
case "ISO10646-1":
case "UTF-8":
return ({ old, oldcodec });
case "ISO-2022":
return ({ old, oldcodec });
default:
|
66d363 | 2005-04-12 | Anders Johansson | | #if 1
return ({"UTF-8", string_to_utf8});
#else
|
48b411 | 2003-02-05 | Jonas Wallden | | return ({ charset_name(add), charset_function(add, allow_entities) });
|
66d363 | 2005-04-12 | Anders Johansson | | #endif
|
48b411 | 2003-02-05 | Jonas Wallden | | }
}
|
360c1b | 2004-06-30 | Stefan Wallström | | array replace_charset_placeholder(string charset, string what, int allow_entities) {
if(allow_entities && charset)
|
7e9fec | 2004-06-30 | Stefan Wallström | | what = replace(what, Roxen->magic_charset_variable_placeholder, charset);
|
360c1b | 2004-06-30 | Stefan Wallström | | return ({ charset, what });
}
|
48b411 | 2003-02-05 | Jonas Wallden | | array(string) output_encode(string what, int|void allow_entities,
string|void force_charset)
{
|
b038b1 | 2003-02-19 | Jonas Wallden | |
if (String.width(what) == 8) {
if (force_charset) {
if (upper_case(force_charset) == "ISO-8859-1")
|
360c1b | 2004-06-30 | Stefan Wallström | | return replace_charset_placeholder("ISO-8859-1", what, allow_entities);
|
b038b1 | 2003-02-19 | Jonas Wallden | | } else {
|
632261 | 2004-05-06 | Martin Stjernholm | | if (sizeof(output_charset) == 1 &&
|
b038b1 | 2003-02-19 | Jonas Wallden | | upper_case(output_charset[0]) == "ISO-8859-1")
|
360c1b | 2004-06-30 | Stefan Wallström | | return replace_charset_placeholder("ISO-8859-1", what, allow_entities);
|
b038b1 | 2003-02-19 | Jonas Wallden | | }
}
|
48b411 | 2003-02-05 | Jonas Wallden | | if (!force_charset) {
string charset;
function encoder;
|
632261 | 2004-05-06 | Martin Stjernholm | | foreach( output_charset, string|function f )
|
48b411 | 2003-02-05 | Jonas Wallden | | [charset,encoder] = join_charset(charset, f, encoder, allow_entities);
if (!encoder)
if (String.width(what) > 8) {
charset = "UTF-8";
encoder = string_to_utf8;
}
if (encoder)
what = encoder(what);
|
360c1b | 2004-06-30 | Stefan Wallström | | return replace_charset_placeholder( charset, what, allow_entities );
|
48b411 | 2003-02-05 | Jonas Wallden | | } else
return ({
0,
Locale.Charset.encoder((force_charset / "=")[-1])->feed(what)->drain()
});
}
|
a89693 | 2001-01-03 | Per Hedbor | | string scan_for_query( string f )
{
if(sscanf(f,"%s?%s", f, query) == 2)
{
string v, a, b;
foreach(query / "&", v)
|
ccf831 | 2001-08-15 | Per Hedbor | | if(sscanf(v, "%s=%s", a, b) == 2)
{
a = _Roxen.http_decode_string(replace(a, "+", " "));
b = _Roxen.http_decode_string(replace(b, "+", " "));
real_variables[ a ] += ({ b });
} else
if(strlen( rest_query ))
rest_query += "&" + _Roxen.http_decode_string( v );
else
rest_query = _Roxen.http_decode_string( v );
|
a89693 | 2001-01-03 | Per Hedbor | | rest_query=replace(rest_query, "+", "\000");
}
return f;
}
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | mapping(string:string) make_response_headers (mapping(string:mixed) file)
|
2e9a31 | 2004-04-13 | Martin Stjernholm | |
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | {
|
a7332e | 2004-04-20 | Martin Stjernholm | | if (!file->stat) file->stat = misc->stat;
if(objectp(file->file)) {
|
50b5a1 | 2004-06-16 | Henrik Grubbström (Grubba) | | if(!file->stat && file->file->stat)
|
a7332e | 2004-04-20 | Martin Stjernholm | | file->stat = file->file->stat();
if (zero_type(misc->cacheable) && file->file->is_file) {
misc->cacheable = (predef::time(1) - file->stat[ST_MTIME])/4;
}
}
if( Stat fstat = file->stat )
{
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | if( !file->len && (fstat[1] >= 0) && file->file )
|
a7332e | 2004-04-20 | Martin Stjernholm | | file->len = fstat[1];
if ( fstat[ST_MTIME] > misc->last_modified )
misc->last_modified = fstat[ST_MTIME];
}
if (!file->error)
file->error = Protocols.HTTP.HTTP_OK;
|
c2d7aa | 2004-04-13 | Martin Stjernholm | |
|
de29ac | 2004-04-14 | Martin Stjernholm | | if(!file->type) file->type="text/plain";
|
a7332e | 2004-04-20 | Martin Stjernholm | | mapping(string:string) heads = ([]);
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | if( !zero_type(misc->cacheable) &&
(misc->cacheable != INITIAL_CACHEABLE) ) {
if (!misc->cacheable) {
heads["Expires"] = Roxen->http_date( predef::time(1)-31557600 );
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
misc->vary = (< 0 >);
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | } else
heads["Expires"] = Roxen->http_date( predef::time(1)+misc->cacheable );
if (misc->cacheable < INITIAL_CACHEABLE) {
misc->last_modified = predef::time(1);
}
}
if (misc->last_modified)
heads["Last-Modified"] = Roxen->http_date(misc->last_modified);
string charset="";
if( stringp(file->data) )
{
|
66d363 | 2005-04-12 | Anders Johansson | | if (file->charset)
set_output_charset (file->charset, 2);
|
632261 | 2004-05-06 | Martin Stjernholm | | if (sizeof (output_charset) ||
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | has_prefix (file->type, "text/") ||
(String.width(file->data) > 8))
{
int allow_entities =
has_prefix(file->type, "text/xml") ||
has_prefix(file->type, "text/html");
[charset,file->data] = output_encode( file->data, allow_entities );
if( charset && (search(file["type"], "; charset=") == -1))
charset = "; charset="+charset;
else
charset = "";
}
file->len = strlen(file->data);
}
|
de29ac | 2004-04-14 | Martin Stjernholm | | heads["Content-Type"] = file->type + charset;
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | |
|
c2d7aa | 2004-04-13 | Martin Stjernholm | |
heads["Accept-Ranges"] = "bytes";
|
349ed5 | 2005-08-16 | Martin Stjernholm | | heads["Server"] = replace(roxenp()->version(), " ", "_");
|
2a86b6 | 2004-05-08 | Henrik Grubbström (Grubba) | | if (file->error == 500) {
heads["Connection"] = "close";
misc->connection = "close";
} else if( misc->connection )
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | heads["Connection"] = misc->connection;
if(file->encoding) heads["Content-Encoding"] = file->encoding;
heads->Date = Roxen->http_date(predef::time(1));
if(file->expires)
heads->Expires = Roxen->http_date(file->expires);
heads["Content-Length"] = (string)file->len;
|
56b585 | 2004-04-13 | Martin Stjernholm | | if (misc->etag)
heads->ETag = misc->etag;
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | #ifdef RAM_CACHE
|
56b585 | 2004-04-13 | Martin Stjernholm | | if (!misc->etag && file->len &&
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | (file->data || file->file) &&
|
2e9a31 | 2004-04-13 | Martin Stjernholm | | file->error == 200 && (<"HEAD", "GET">)[method] &&
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | (file->len < conf->datacache->max_file_size)) {
string data = "";
if (file->file) {
data = file->file->read(file->len);
if (file->data && (sizeof(data) < file->len)) {
data += file->data[..file->len - (sizeof(data)+1)];
}
|
2e9a31 | 2004-04-13 | Martin Stjernholm | | m_delete(file, "file");
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | } else if (file->data) {
data = file->data[..file->len - 1];
}
file->data = data;
heads->ETag = misc->etag =
|
b0838c | 2004-05-03 | Henrik Grubbström (Grubba) | | sprintf("\"%s\"",
Crypto.string_to_hex(Crypto.md5()->update(data)->digest()));
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | }
#endif /* RAM_CACHE */
|
0f0650 | 2005-12-02 | Henrik Grubbström (Grubba) | | if (misc->vary) {
if (misc->vary[0]) {
heads->Vary = "*";
} else {
heads->Vary = ((array)misc->vary) * ", ";
}
|
bb5555 | 2004-05-18 | Henrik Grubbström (Grubba) | | }
|
2e9a31 | 2004-04-13 | Martin Stjernholm | | if(mappingp(file->extra_heads))
heads |= file->extra_heads;
if(mappingp(misc->moreheads))
heads |= misc->moreheads;
|
c2d7aa | 2004-04-13 | Martin Stjernholm | | return heads;
}
|
9689f1 | 2002-09-03 | Martin Stjernholm | | void adjust_for_config_path( string p )
{
if( not_query ) not_query = not_query[ strlen(p).. ];
raw_url = raw_url[ strlen(p).. ];
misc->site_prefix_path = p;
}
|
a89693 | 2001-01-03 | Per Hedbor | | void end(string|void s, int|void keepit){}
void ready_to_receive(){}
|
12bbbd | 2004-05-10 | Martin Stjernholm | |
void send_result(mapping|void result)
{
#ifdef DEBUG
error ("send_result not overridden.\n");
#endif
}
|
a89693 | 2001-01-03 | Per Hedbor | | RequestID clone_me()
{
object c,t;
c=object_program(t=this_object())(0, port_obj, conf);
c->port_obj = port_obj;
c->conf = conf;
|
7fafb8 | 2001-07-25 | Johan Sundström | | c->root_id = root_id;
|
a89693 | 2001-01-03 | Per Hedbor | | c->time = time;
c->raw_url = raw_url;
|
ccf831 | 2001-08-15 | Per Hedbor | |
c->real_variables = copy_value( real_variables );
c->variables = FakedVariables( c->real_variables );
|
a89693 | 2001-01-03 | Per Hedbor | | c->misc = copy_value( misc );
c->misc->orig = t;
|
99e65a | 2003-06-18 | Tomas Nilsson | | c->connection_misc = connection_misc;
|
a89693 | 2001-01-03 | Per Hedbor | | c->prestate = prestate;
c->supports = supports;
c->config = config;
c->client_var = client_var;
c->remoteaddr = remoteaddr;
c->host = host;
c->client = client;
c->referer = referer;
c->pragma = pragma;
c->cookies = cookies;
|
fcfa7b | 2004-05-14 | Henrik Grubbström (Grubba) | | c->request_headers = request_headers + ([]);
|
a89693 | 2001-01-03 | Per Hedbor | | c->my_fd = 0;
c->prot = prot;
c->clientprot = clientprot;
c->method = method;
c->rest_query = rest_query;
c->raw = raw;
c->query = query;
c->not_query = not_query;
c->data = data;
c->extra_extension = extra_extension;
c->realauth = realauth;
c->rawauth = rawauth;
c->since = since;
return c;
}
Stdio.File connection( )
{
return my_fd;
}
Configuration configuration()
{
return conf;
}
|
b19253 | 2004-05-25 | Martin Stjernholm | |
string _sprintf (int flag)
{
return flag == 'O' && ("RequestID(" + (raw_url||"") + ")"
#ifdef ID_OBJ_DEBUG
+ (__marker ? "[" + __marker->count + "]" : "")
#endif
);
}
|
a89693 | 2001-01-03 | Per Hedbor | | }
|
197e81 | 2004-05-06 | Martin Stjernholm | | class MultiStatusStatus (int http_code, void|string message)
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | {
|
197e81 | 2004-05-06 | Martin Stjernholm | | constant is_status = 1;
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | void build_response (SimpleElementNode response_node)
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | {
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | SimpleElementNode node = SimpleElementNode("DAV:status", ([]));
|
197e81 | 2004-05-06 | Martin Stjernholm | | response_node->add_child (node);
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | node->add_child(SimpleTextNode(sprintf("HTTP/1.1 %d ", http_code)));
|
197e81 | 2004-05-06 | Martin Stjernholm | |
if (message) {
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | node = SimpleElementNode ("DAV:responsedescription", ([]));
|
197e81 | 2004-05-06 | Martin Stjernholm | | response_node->add_child (node);
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | node->add_child (SimpleTextNode (message));
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | }
|
197e81 | 2004-05-06 | Martin Stjernholm | | }
int `== (mixed other)
{
return objectp (other) &&
object_program (other) == this_program &&
other->http_code == http_code &&
other->message == message;
}
int __hash()
{
return http_code + (message && hash (message));
}
string _sprintf (int flag)
{
return flag == 'O' &&
sprintf ("MultiStatusStatus(%d,%O)", http_code, message);
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | }
}
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | private SimpleElementNode ok_status_node =
|
066275 | 2004-05-13 | Martin Stjernholm | | SimpleElementNode("DAV:status", ([]))->add_child(SimpleTextNode("HTTP/1.1 200 OK"));
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | |
|
197e81 | 2004-05-06 | Martin Stjernholm | | class MultiStatusPropStat
{
constant is_prop_stat = 1;
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | |
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | mapping(string:string|SimpleNode|array(SimpleNode)|MultiStatusStatus)
properties = ([]);
|
071d47 | 2004-05-06 | Martin Stjernholm | |
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | |
|
071d47 | 2004-05-06 | Martin Stjernholm | |
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | |
|
071d47 | 2004-05-06 | Martin Stjernholm | |
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | |
|
071d47 | 2004-05-06 | Martin Stjernholm | |
|
190428 | 2003-06-17 | Henrik Grubbström (Grubba) | |
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | void build_response (SimpleElementNode response_node)
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | {
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | SimpleElementNode ok_prop_node = SimpleElementNode("DAV:prop", ([]));
mapping(MultiStatusStatus:SimpleNode) prop_nodes = ([]);
|
197e81 | 2004-05-06 | Martin Stjernholm | |
foreach (properties;
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | string prop_name;
string|SimpleNode|array(SimpleNode)|MultiStatusStatus value) {
|
197e81 | 2004-05-06 | Martin Stjernholm | | if (objectp (value) && value->is_status) {
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | SimpleNode prop_node = prop_nodes[value];
|
197e81 | 2004-05-06 | Martin Stjernholm | | if (!prop_node)
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | prop_nodes[value] = prop_node = SimpleElementNode("DAV:prop", ([]));
prop_node->add_child(SimpleElementNode(prop_name, ([])));
|
a7332e | 2004-04-20 | Martin Stjernholm | | }
|
197e81 | 2004-05-06 | Martin Stjernholm | |
else {
string ms_type;
switch (prop_name) {
case "DAV:creationdate": ms_type = "dateTime.tz"; break;
case "DAV:getlastmodified": ms_type = "dateTime.rfc1123"; break;
}
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | SimpleElementNode node =
SimpleElementNode(prop_name,
ms_type ?
([ "urn:schemas-microsoft-com:datatypesdt":
ms_type ]) : ([]));
|
197e81 | 2004-05-06 | Martin Stjernholm | | ok_prop_node->add_child (node);
if (arrayp (value))
node->replace_children (value);
else if (stringp (value))
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | node->add_child(SimpleTextNode(value));
|
197e81 | 2004-05-06 | Martin Stjernholm | | else if (objectp (value))
node->add_child (value);
|
190428 | 2003-06-17 | Henrik Grubbström (Grubba) | | }
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | }
|
197e81 | 2004-05-06 | Martin Stjernholm | | if (ok_prop_node->count_children()) {
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | SimpleElementNode propstat_node =
SimpleElementNode("DAV:propstat", ([]));
|
197e81 | 2004-05-06 | Martin Stjernholm | | response_node->add_child (propstat_node);
propstat_node->add_child (ok_prop_node);
propstat_node->add_child (ok_status_node);
|
190428 | 2003-06-17 | Henrik Grubbström (Grubba) | | }
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | |
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | foreach (prop_nodes; MultiStatusStatus status; SimpleNode prop_node) {
SimpleElementNode propstat_node =
SimpleElementNode("DAV:propstat", ([]));
|
197e81 | 2004-05-06 | Martin Stjernholm | | response_node->add_child (propstat_node);
propstat_node->add_child (prop_node);
status->build_response (propstat_node);
}
}
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | |
|
197e81 | 2004-05-06 | Martin Stjernholm | | string _sprintf (int flag)
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | {
|
197e81 | 2004-05-06 | Martin Stjernholm | | return flag == 'O' && sprintf ("MultiStatusPropStat(%O)", properties);
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | }
}
|
197e81 | 2004-05-06 | Martin Stjernholm | | typedef MultiStatusStatus|MultiStatusPropStat MultiStatusNode;
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | class MultiStatus
{
|
197e81 | 2004-05-06 | Martin Stjernholm | | static mapping(string:MultiStatusNode) status_set = ([]);
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | |
|
f8874d | 2004-04-29 | Martin Stjernholm | | static mapping(string:string) args = ([
"xmlns:DAV": "DAV:",
"xmlns:MS": "urn:schemas-microsoft-com:datatypes",
]);
|
ae77c4 | 2004-05-05 | Martin Stjernholm | | int num_responses()
|
b303da | 2004-03-03 | Henrik Grubbström (Grubba) | | {
|
197e81 | 2004-05-06 | Martin Stjernholm | | return sizeof (status_set);
|
b303da | 2004-03-03 | Henrik Grubbström (Grubba) | | }
|
197e81 | 2004-05-06 | Martin Stjernholm | | MultiStatusNode get_response (string href)
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | {
|
197e81 | 2004-05-06 | Martin Stjernholm | | return status_set[href];
}
mapping(string:MultiStatusNode) get_responses_by_prefix (string href_prefix)
{
if (href_prefix == "")
return status_set + ([]);
mapping(string:MultiStatusNode) result = ([]);
if (!has_suffix (href_prefix, "/")) {
if (MultiStatusNode stat = status_set[href_prefix])
result[href_prefix] = stat;
href_prefix += "/";
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | }
|
197e81 | 2004-05-06 | Martin Stjernholm | | foreach (status_set; string href; MultiStatusNode stat)
if (has_prefix (href, href_prefix))
result[href] = stat;
return result;
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | }
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | |
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | |
|
197e81 | 2004-05-06 | Martin Stjernholm | |
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | |
void add_property(string href, string prop_name,
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | void|int(0..0)|string|array(SimpleNode)|SimpleNode|
|
197e81 | 2004-05-06 | Martin Stjernholm | | MultiStatusStatus|mapping(string:mixed) prop_value)
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | {
|
197e81 | 2004-05-06 | Martin Stjernholm | | MultiStatusPropStat prop_stat;
if (MultiStatusNode stat = status_set[href])
if (stat->is_prop_stat)
prop_stat = stat;
if (!prop_stat)
prop_stat = status_set[href] = MultiStatusPropStat();
if (mappingp (prop_value))
prop_value = MultiStatusStatus (prop_value->error, prop_value->rettext);
prop_stat->properties[prop_name] = prop_value;
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | }
|
ae77c4 | 2004-05-05 | Martin Stjernholm | | void add_status (string href, int status_code,
void|string message, mixed... args)
{
|
197e81 | 2004-05-06 | Martin Stjernholm | | if (sizeof (args)) message = sprintf (message, @args);
|
59ec34 | 2004-05-09 | Henrik Grubbström (Grubba) | | if (!status_code) error("Bad status code!\n");
|
197e81 | 2004-05-06 | Martin Stjernholm | | status_set[href] = MultiStatusStatus (status_code, message);
|
ae77c4 | 2004-05-05 | Martin Stjernholm | | }
|
f8874d | 2004-04-29 | Martin Stjernholm | | void add_namespace (string namespace)
{
int ns_count = 0;
string ns_name;
while (args[ns_name = "xmlns:NS" + ns_count]) {
if (args[ns_name] == namespace) return;
ns_count++;
}
args[ns_name] = namespace;
}
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | SimpleNode get_xml_node()
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | {
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | SimpleElementNode node;
SimpleRootNode root = SimpleRootNode()->
add_child(SimpleHeaderNode((["version": "1.0",
"encoding": "utf-8"])))->
add_child(node = SimpleElementNode("DAV:multistatus", args));
|
f8874d | 2004-04-29 | Martin Stjernholm | |
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | array(SimpleNode) response_xml = allocate(sizeof(status_set));
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | int i;
|
ca0492 | 2003-12-22 | Henrik Grubbström (Grubba) | | DAV_WERROR("Generating XML Nodes for status_set:%O\n",
status_set);
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | |
|
8cedaa | 2004-05-07 | Martin Stjernholm | |
|
bd5d4d | 2003-12-15 | Henrik Grubbström (Grubba) | | foreach(sort(indices(status_set)), string href) {
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | SimpleElementNode response_node =
SimpleElementNode("DAV:response", ([]))->
add_child(SimpleElementNode("DAV:href", ([]))->
add_child(SimpleTextNode(href)));
|
197e81 | 2004-05-06 | Martin Stjernholm | | response_xml[i++] = response_node;
status_set[href]->build_response (response_node);
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | }
|
f8874d | 2004-04-29 | Martin Stjernholm | | node->replace_children(response_xml);
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | return root;
}
mapping(string:mixed) http_answer()
{
string xml = get_xml_node()->render_xml();
return ([
"error": 207,
"data": xml,
"len": sizeof(xml),
"type": "text/xml; charset=\"utf-8\"",
]);
}
|
ae77c4 | 2004-05-05 | Martin Stjernholm | | class Prefixed (static string href_prefix)
{
MultiStatus get_multi_status() {return MultiStatus::this;}
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | void add_property(string path, string prop_name,
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | void|int(0..0)|string|array(SimpleNode)|SimpleNode|
|
197e81 | 2004-05-06 | Martin Stjernholm | | MultiStatusStatus|mapping(string:mixed) prop_value)
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | {
MultiStatus::add_property(href_prefix + path, prop_name, prop_value);
}
|
ae77c4 | 2004-05-05 | Martin Stjernholm | | void add_status (string path, int status_code,
void|string message, mixed... args)
|
f8874d | 2004-04-29 | Martin Stjernholm | | {
|
ae77c4 | 2004-05-05 | Martin Stjernholm | | MultiStatus::add_status (href_prefix + path, status_code, message, @args);
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | }
|
ae77c4 | 2004-05-05 | Martin Stjernholm | | void add_namespace (string namespace)
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | {
|
ae77c4 | 2004-05-05 | Martin Stjernholm | | MultiStatus::add_namespace (namespace);
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | }
|
ae77c4 | 2004-05-05 | Martin Stjernholm | | MultiStatus.Prefixed prefix(string href_prefix) {
return this_program (this_program::href_prefix + href_prefix);
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | }
}
|
ae77c4 | 2004-05-05 | Martin Stjernholm | |
MultiStatus.Prefixed prefix (string href_prefix)
{
return Prefixed (href_prefix);
}
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | }
|
c5dd9f | 2004-03-16 | Henrik Grubbström (Grubba) | |
static class PropertySet
{
string path;
|
ae77c4 | 2004-05-05 | Martin Stjernholm | | RequestID id;
Stat get_stat();
mapping(string:string) get_response_headers();
|
c5dd9f | 2004-03-16 | Henrik Grubbström (Grubba) | | multiset(string) query_all_properties();
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | string|array(SimpleNode)|mapping(string:mixed)
|
c5dd9f | 2004-03-16 | Henrik Grubbström (Grubba) | | query_property(string prop_name);
mapping(string:mixed) start();
void unroll();
void commit();
mapping(string:mixed) set_property(string prop_name,
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | string|array(SimpleNode) value);
|
c5dd9f | 2004-03-16 | Henrik Grubbström (Grubba) | | mapping(string:mixed) set_dead_property(string prop_name,
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | array(SimpleNode) value);
|
c5dd9f | 2004-03-16 | Henrik Grubbström (Grubba) | | mapping(string:mixed) remove_property(string prop_name);
mapping(string:mixed) find_properties(string mode,
|
ae77c4 | 2004-05-05 | Martin Stjernholm | | MultiStatus.Prefixed result,
|
c5dd9f | 2004-03-16 | Henrik Grubbström (Grubba) | | multiset(string)|void filt);
}
|
066275 | 2004-05-13 | Martin Stjernholm | |
|
119a55 | 2004-05-07 | Martin Stjernholm | | enum LockFlag {
LOCK_NONE = 0,
LOCK_SHARED_BELOW = 2,
LOCK_SHARED_AT = 3,
LOCK_OWN_BELOW = 4,
LOCK_EXCL_BELOW = 6,
LOCK_EXCL_AT = 7
};
|
066275 | 2004-05-13 | Martin Stjernholm | |
|
cdaab0 | 2004-05-10 | Martin Stjernholm | | enum Overwrite {
|
066275 | 2004-05-13 | Martin Stjernholm | |
|
dd03b2 | 2006-04-20 | Henrik Grubbström (Grubba) | | NEVER_OVERWRITE = -1,
|
066275 | 2004-05-13 | Martin Stjernholm | |
|
102dbe | 2004-05-13 | Martin Stjernholm | |
|
dd03b2 | 2006-04-20 | Henrik Grubbström (Grubba) | | MAYBE_OVERWRITE = 0,
|
066275 | 2004-05-13 | Martin Stjernholm | |
|
dd03b2 | 2006-04-20 | Henrik Grubbström (Grubba) | | DO_OVERWRITE = 1,
|
cdaab0 | 2004-05-10 | Martin Stjernholm | | };
|
dfc1ad | 2004-05-13 | Henrik Grubbström (Grubba) | |
|
a72041 | 2004-05-14 | Martin Stjernholm | |
|
dfc1ad | 2004-05-13 | Henrik Grubbström (Grubba) | |
typedef int(0..1)|multiset(string) PropertyBehavior;
|
cdaab0 | 2004-05-10 | Martin Stjernholm | |
|
a89693 | 2001-01-03 | Per Hedbor | | class RoxenModule
{
inherit BasicDefvar;
constant is_module = 1;
constant module_type = 0;
constant module_unique = 1;
|
7787ac | 2001-07-31 | Per Hedbor | | LocaleString module_name;
LocaleString module_doc;
|
a89693 | 2001-01-03 | Per Hedbor | |
|
0aa37d | 2001-08-23 | Martin Stjernholm | | string module_identifier();
string module_local_id();
|
a89693 | 2001-01-03 | Per Hedbor | | array(int|string|mapping) register_module();
string file_name_and_stuff();
|
d1f2c8 | 2006-05-31 | Martin Stjernholm | | void start (void|int variable_save, void|Configuration conf,
void|int newly_added);
|
a89693 | 2001-01-03 | Per Hedbor | |
string query_internal_location();
string query_location();
|
740d68 | 2004-06-17 | Henrik Grubbström (Grubba) | | string|multiset(string) query_provides();
|
bd5d4d | 2003-12-15 | Henrik Grubbström (Grubba) | | function(RequestID:int|mapping) query_seclevels();
|
119a55 | 2004-05-07 | Martin Stjernholm | | void set_status_for_path (string path, RequestID id, int status_code,
string|void message, mixed... args);
|
ce6427 | 2001-01-14 | Martin Nilsson | | array(int)|object(Stdio.Stat) stat_file(string f, RequestID id);
|
c8c135 | 2003-01-13 | Henrik Grubbström (Grubba) | | array(string) find_dir(string f, RequestID id);
|
a89693 | 2001-01-03 | Per Hedbor | | mapping(string:array(mixed)) find_dir_stat(string f, RequestID id);
string real_file(string f, RequestID id);
void save();
mapping api_functions();
mapping query_tag_callers();
mapping query_container_callers();
string info(object conf);
string comment();
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | |
|
c11ef7 | 2004-05-10 | Martin Stjernholm | | PropertySet|mapping(string:mixed) query_property_set(string path, RequestID id);
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | string|array(SimpleNode)|mapping(string:mixed)
|
c8bfed | 2003-06-02 | Henrik Grubbström (Grubba) | | query_property(string path, string prop_name, RequestID id);
|
e9ceb9 | 2004-06-02 | Martin Stjernholm | | mapping(string:mixed) recurse_find_properties(string path, string mode, int depth,
RequestID id,
multiset(string)|void filt);
|
a98f75 | 2004-03-03 | Henrik Grubbström (Grubba) | | mapping(string:mixed) patch_properties(string path,
array(PatchPropertyCommand) instructions,
|
cdaab0 | 2004-05-10 | Martin Stjernholm | | RequestID id);
|
4c87da | 2004-04-28 | Henrik Grubbström (Grubba) | | mapping(string:mixed) set_property (string path, string prop_name,
|
a8e2b3 | 2004-05-07 | Henrik Grubbström (Grubba) | | string|array(SimpleNode) value,
|
4c87da | 2004-04-28 | Henrik Grubbström (Grubba) | | RequestID id);
mapping(string:mixed) remove_property (string path, string prop_name,
RequestID id);
|
8cedaa | 2004-05-07 | Martin Stjernholm | |
|
0ddcae | 2004-05-04 | Martin Stjernholm | | string resource_id (string path, RequestID id);
|
de070f | 2004-05-04 | Martin Stjernholm | | string|int authenticated_user_id (string path, RequestID id);
|
47fa21 | 2004-05-03 | Martin Stjernholm | | multiset(DAVLock) find_locks(string path,
int(0..1) recursive,
int(0..1) exclude_shared,
RequestID id);
|
119a55 | 2004-05-07 | Martin Stjernholm | | DAVLock|LockFlag check_locks(string path,
int(0..1) recursive,
RequestID id);
|
085061 | 2004-05-03 | Martin Stjernholm | | mapping(string:mixed) lock_file(string path,
DAVLock lock,
RequestID id);
|
490832 | 2004-04-29 | Martin Stjernholm | | mapping(string:mixed) unlock_file (string path,
DAVLock lock,
RequestID id);
|
28c81a | 2004-05-12 | Martin Stjernholm | | mapping(string:mixed)|int(0..1) check_if_header(string relative_path,
int(0..1) recursive,
RequestID id);
|
8cedaa | 2004-05-07 | Martin Stjernholm | |
|
b303da | 2004-03-03 | Henrik Grubbström (Grubba) | | mapping(string:mixed)|int(-1..0)|Stdio.File find_file(string path,
RequestID id);
|
48d26d | 2004-05-10 | Henrik Grubbström (Grubba) | | mapping(string:mixed) recurse_delete_files(string path,
RequestID id);
|
cdaab0 | 2004-05-10 | Martin Stjernholm | | mapping(string:mixed) make_collection(string path, RequestID id);
|
dfc1ad | 2004-05-13 | Henrik Grubbström (Grubba) | | mapping(string:mixed) recurse_copy_files(string source, string destination,
PropertyBehavior behavior,
|
cdaab0 | 2004-05-10 | Martin Stjernholm | | Overwrite overwrite, RequestID id);
|
7d1c8e | 2004-05-13 | Henrik Grubbström (Grubba) | | mapping(string:mixed) recurse_move_files(string source, string destination,
PropertyBehavior behavior,
Overwrite overwrite, RequestID id);
|
a89693 | 2001-01-03 | Per Hedbor | | }
|
0cb4c4 | 2004-03-15 | Martin Stjernholm | | class PatchPropertyCommand
{
constant command = "";
string property_name;
|
df0424 | 2004-03-16 | Henrik Grubbström (Grubba) | | mapping(string:mixed) execute(PropertySet context);
|
0cb4c4 | 2004-03-15 | Martin Stjernholm | | }
|
a89693 | 2001-01-03 | Per Hedbor | | class _roxen
{
mapping(string:object) variables;
|
228471 | 2004-04-25 | Henrik Grubbström (Grubba) | | constant real_version = "";
|
a89693 | 2001-01-03 | Per Hedbor | | object locale;
int start_time;
array(Configuration) configurations;
mixed query(string a);
void store(string a, mapping b, int c, object d);
mapping(string:mixed) retrieve(string a, object b);
void remove(string a, object b);
string version();
void dump(string a);
void nwrite(string a, int|void b, int|void c, void|mixed ... d);
int main(int a, array(string) b);
}
|
3e3bab | 2001-01-19 | Per Hedbor | |
class AuthModule
|
7f66d8 | 2001-08-24 | Martin Nilsson | |
|
3e3bab | 2001-01-19 | Per Hedbor | |
{
inherit RoxenModule;
constant module_type = MODULE_AUTH;
constant thread_safe=1;
constant name = "method name";
|
3342dd | 2001-01-19 | Per Hedbor | | User authenticate( RequestID id, UserDB db );
|
3e3bab | 2001-01-19 | Per Hedbor | |
|
3342dd | 2001-01-19 | Per Hedbor | | mapping authenticate_throw( RequestID id, string realm, UserDB db );
|
3e3bab | 2001-01-19 | Per Hedbor | |
}
|
e08221 | 2001-08-28 | Per Hedbor | | static mapping(string:function(void:void)) user_sql_inited = ([]);
|
a66538 | 2001-01-29 | Per Hedbor | | static Sql.Sql user_mysql;
|
69fa3e | 2001-01-30 | Per Hedbor | | static void init_user_sql(string table)
|
3342dd | 2001-01-19 | Per Hedbor | | {
|
e08221 | 2001-08-28 | Per Hedbor | | string db = all_constants()->REPLICATE?"replicate":"local";
|
69fa3e | 2001-01-30 | Per Hedbor | | if( !user_mysql )
|
e08221 | 2001-08-28 | Per Hedbor | | user_mysql = master()->resolv("DBManager.get")( db );
|
c58039 | 2001-08-13 | Per Hedbor | | if(catch(user_mysql->query( "SELECT module FROM "+
table+" WHERE module=''")))
{
|
69fa3e | 2001-01-30 | Per Hedbor | | user_mysql->query( "CREATE TABLE "+table+" "
" (module varchar(30) NOT NULL, "
|
3342dd | 2001-01-19 | Per Hedbor | | " name varchar(30) NOT NULL, "
|
69fa3e | 2001-01-30 | Per Hedbor | | " user varchar(30) NOT NULL, "
" value blob, "
" raw int not null, "
" INDEX foo (module,name,user))" );
|
e08221 | 2001-08-28 | Per Hedbor | | master()->resolv("DBManager.is_module_table")( 0, db, table,
"Contains metadata about users. "
|
c58039 | 2001-08-13 | Per Hedbor | | "Userdatabases can store information here "
"at the request of other modules, or they "
"can keep their own state in this table" );
}
|
e08221 | 2001-08-28 | Per Hedbor | | user_sql_inited[ table ]=
lambda(){user_mysql = master()->resolv("DBManager.get")( db );};
|
3342dd | 2001-01-19 | Per Hedbor | | }
|
7f66d8 | 2001-08-24 | Martin Nilsson | |
|
3342dd | 2001-01-19 | Per Hedbor | | class Group( UserDB database )
|
3e3bab | 2001-01-19 | Per Hedbor | | {
string name();
|
3342dd | 2001-01-19 | Per Hedbor | |
|
6533f2 | 2001-08-23 | Martin Nilsson | |
|
9b9432 | 2001-01-29 | Per Hedbor | | array(string) members()
|
3342dd | 2001-01-19 | Per Hedbor | |
|
318185 | 2001-10-09 | Per Hedbor | |
|
3342dd | 2001-01-19 | Per Hedbor | | {
array res = ({});
User uid;
int id = gid();
foreach( database->list_users(), string u )
|
318185 | 2001-10-09 | Per Hedbor | | if( (uid = database->find_user( u )) &&
((uid->gid() == id) || has_value(uid->groups(), name())))
|
9b9432 | 2001-01-29 | Per Hedbor | | res += ({ u });
|
3342dd | 2001-01-19 | Per Hedbor | | return res;
}
int gid();
|
318185 | 2001-10-09 | Per Hedbor | |
int set_name( string new_name ) { return 0; }
int set_gid( int new_gid ) { return 0; }
int set_members( array(string) members ) { return 0; }
|
3342dd | 2001-01-19 | Per Hedbor | | }
|
e08221 | 2001-08-28 | Per Hedbor | | #ifdef THREADS
|
61e1cd | 2001-09-05 | Martin Nilsson | | static Thread.Mutex mutex = Thread.Mutex();
|
e08221 | 2001-08-28 | Per Hedbor | | #endif
|
7f66d8 | 2001-08-24 | Martin Nilsson | |
|
3342dd | 2001-01-19 | Per Hedbor | | class User( UserDB database )
{
|
69fa3e | 2001-01-30 | Per Hedbor | | static string table;
|
3342dd | 2001-01-19 | Per Hedbor | | string name();
|
6533f2 | 2001-08-23 | Martin Nilsson | |
|
3e3bab | 2001-01-19 | Per Hedbor | | string real_name();
|
3342dd | 2001-01-19 | Per Hedbor | |
|
0d1bcb | 2001-08-30 | Henrik Grubbström (Grubba) | | int password_authenticate(string password)
|
3342dd | 2001-01-19 | Per Hedbor | |
{
|
0d1bcb | 2001-08-30 | Henrik Grubbström (Grubba) | | string c = crypted_password();
return !sizeof(c) || crypt(password, c);
|
3342dd | 2001-01-19 | Per Hedbor | | }
int uid();
|
6533f2 | 2001-08-23 | Martin Nilsson | |
|
3342dd | 2001-01-19 | Per Hedbor | | int gid();
|
6533f2 | 2001-08-23 | Martin Nilsson | |
|
3342dd | 2001-01-19 | Per Hedbor | | string shell();
string gecos()
{
return real_name();
}
string homedir();
string crypted_password() { return "x"; }
|
9b9432 | 2001-01-29 | Per Hedbor | | array(string) groups()
|
e3f466 | 2001-01-19 | Per Hedbor | |
{
return ({});
}
|
3342dd | 2001-01-19 | Per Hedbor | |
|
1d5c89 | 2001-01-19 | Per Hedbor | | int set_name(string name) {}
int set_real_name(string rname) {}
int set_uid(int uid) {}
int set_gid(int gid) {}
int set_shell(string shell) {}
int set_gecos(string gecos) {}
int set_homedir(string hodir) {}
int set_crypted_password(string passwd) {}
int set_password(string passwd) {}
|
3342dd | 2001-01-19 | Per Hedbor | |
array compat_userinfo( )
{
return ({name(),crypted_password(),uid(),gid(),gecos(),homedir(),shell()});
}
|
3e3bab | 2001-01-19 | Per Hedbor | |
|
69fa3e | 2001-01-30 | Per Hedbor | |
#define INIT_SQL() do{ \
if(!table) table = replace(database->my_configuration()->name," ","_")+"_user_variables"; \
|
e08221 | 2001-08-28 | Per Hedbor | | if(!user_sql_inited[ table ] )init_user_sql( table );else user_sql_inited[ table ](); \
|
69fa3e | 2001-01-30 | Per Hedbor | | } while( 0 )
|
e08221 | 2001-08-28 | Per Hedbor | | #ifdef THREADS
#define LOCK() mixed ___key = mutex->lock()
#else
#define LOCK()
#endif
|
69fa3e | 2001-01-30 | Per Hedbor | | static string module_name( RoxenModule module )
{
if( !module )
return "'0'";
else
return replace("'"+user_mysql->quote(module->sname())+"'","%","%%");
}
|
3342dd | 2001-01-19 | Per Hedbor | |
|
1d5c89 | 2001-01-19 | Per Hedbor | | mixed set_var( RoxenModule module, string index, mixed value )
|
3342dd | 2001-01-19 | Per Hedbor | |
|
e3f466 | 2001-01-19 | Per Hedbor | |
|
3342dd | 2001-01-19 | Per Hedbor | |
|
69fa3e | 2001-01-30 | Per Hedbor | |
|
3342dd | 2001-01-19 | Per Hedbor | |
{
delete_var( module, index );
|
69fa3e | 2001-01-30 | Per Hedbor | | mixed oval = value;
|
e08221 | 2001-08-28 | Per Hedbor | | LOCK();
|
69fa3e | 2001-01-30 | Per Hedbor | | INIT_SQL();
|
3342dd | 2001-01-19 | Per Hedbor | | int encoded;
|
69fa3e | 2001-01-30 | Per Hedbor | |
|
3342dd | 2001-01-19 | Per Hedbor | | if( stringp( value ) )
value = string_to_utf8( value );
else
{
value = encode_value( value );
encoded = 1;
}
|
e08221 | 2001-08-28 | Per Hedbor | |
|
3342dd | 2001-01-19 | Per Hedbor | | user_mysql->query(
|
69fa3e | 2001-01-30 | Per Hedbor | | "INSERT INTO "+table+" (module,name,user,value,raw) "
"VALUES ("+module_name( module )+", %s, %s, %s, %d)",
index, name(), value, encoded
|
3342dd | 2001-01-19 | Per Hedbor | | );
|
69fa3e | 2001-01-30 | Per Hedbor | | return oval;
|
3342dd | 2001-01-19 | Per Hedbor | | }
mixed get_var( RoxenModule module, string index )
{
array rows;
|
e08221 | 2001-08-28 | Per Hedbor | | LOCK();
|
69fa3e | 2001-01-30 | Per Hedbor | | INIT_SQL();
rows = user_mysql->query( "SELECT * FROM "+table+
|
e08221 | 2001-08-28 | Per Hedbor | | " WHERE module="+module_name( module )
+" AND name=%s AND user=%s",
|
3342dd | 2001-01-19 | Per Hedbor | | index, name() );
if( !sizeof( rows ) )
return 0;
mapping m = rows[0];
|
69fa3e | 2001-01-30 | Per Hedbor | |
|
3342dd | 2001-01-19 | Per Hedbor | | if( (int)m->raw )
return decode_value( m->value );
return utf8_to_string( m->value );
}
void delete_var( RoxenModule module, string index )
{
|
e08221 | 2001-08-28 | Per Hedbor | | LOCK();
|
69fa3e | 2001-01-30 | Per Hedbor | | INIT_SQL();
user_mysql->query( "DELETE FROM "+table+" WHERE (module="+
module_name( module )+
" AND name=%s AND user=%s)", index, name() );
|
3342dd | 2001-01-19 | Per Hedbor | | }
|
69fa3e | 2001-01-30 | Per Hedbor | | #undef INIT_SQL
|
e08221 | 2001-08-28 | Per Hedbor | | #undef LOCK
|
3e3bab | 2001-01-19 | Per Hedbor | | }
class UserDB
|
7f66d8 | 2001-08-24 | Martin Nilsson | |
|
3e3bab | 2001-01-19 | Per Hedbor | |
{
inherit RoxenModule;
constant module_type = MODULE_USERDB;
|
8ea201 | 2001-01-29 | Per Hedbor | | constant thread_safe=1;
|
3e3bab | 2001-01-19 | Per Hedbor | |
|
e3f466 | 2001-01-19 | Per Hedbor | | constant name = "db name";
|
99a70c | 2001-08-30 | Henrik Grubbström (Grubba) | | User find_user( string s, RequestID|void id );
|
3e3bab | 2001-01-19 | Per Hedbor | |
|
bd5d4d | 2003-12-15 | Henrik Grubbström (Grubba) | | User find_user_from_uid( int uid, RequestID|void id )
|
3342dd | 2001-01-19 | Per Hedbor | |
{
|
bd5d4d | 2003-12-15 | Henrik Grubbström (Grubba) | | User user;
|
3342dd | 2001-01-19 | Per Hedbor | | foreach( list_users(), string u )
|
bd5d4d | 2003-12-15 | Henrik Grubbström (Grubba) | | if( (user = find_user( u )) && (user->uid() == uid) )
return user;
|
3342dd | 2001-01-19 | Per Hedbor | | }
|
bd5d4d | 2003-12-15 | Henrik Grubbström (Grubba) | | Group find_group( string group, RequestID|void id )
|
3342dd | 2001-01-19 | Per Hedbor | |
{
}
|
bd5d4d | 2003-12-15 | Henrik Grubbström (Grubba) | | Group find_group_from_gid( int gid, RequestID|void id )
|
3342dd | 2001-01-19 | Per Hedbor | |
{
|
bd5d4d | 2003-12-15 | Henrik Grubbström (Grubba) | | Group group;
|
3342dd | 2001-01-19 | Per Hedbor | | foreach( list_groups(), string u )
|
bd5d4d | 2003-12-15 | Henrik Grubbström (Grubba) | | if( (group = find_group( u )) && (group->gid() == gid) )
return group;
|
3342dd | 2001-01-19 | Per Hedbor | | }
|
bd5d4d | 2003-12-15 | Henrik Grubbström (Grubba) | | array(string) list_groups( RequestID|void id )
|
3342dd | 2001-01-19 | Per Hedbor | |
{
return ({});
}
|
bd5d4d | 2003-12-15 | Henrik Grubbström (Grubba) | | array(string) list_users( RequestID|void id );
|
3e3bab | 2001-01-19 | Per Hedbor | |
|
3342dd | 2001-01-19 | Per Hedbor | | User create_user( string s )
|
788f08 | 2001-10-09 | Henrik Grubbström (Grubba) | |
|
3e3bab | 2001-01-19 | Per Hedbor | |
|
3342dd | 2001-01-19 | Per Hedbor | |
|
69fa3e | 2001-01-30 | Per Hedbor | | {
return 0;
}
|
318185 | 2001-10-09 | Per Hedbor | |
Group create_group( string s )
|
788f08 | 2001-10-09 | Henrik Grubbström (Grubba) | |
|
318185 | 2001-10-09 | Per Hedbor | |
{
return 0;
}
|
3e3bab | 2001-01-19 | Per Hedbor | | }
|