Roxen.git / server / base_server / module.pike

version» Context lines:

Roxen.git/server/base_server/module.pike:1: - /* $Id: module.pike,v 1.45 1999/08/07 16:24:35 nilsson Exp $ */ + /* $Id: module.pike,v 1.46 1999/09/05 02:20:05 per Exp $ */      #include <module.h>      #define TRACE_ENTER(A,B) do{if(id->misc->trace_enter)id->misc->trace_enter((A),(B));}while(0)   #define TRACE_LEAVE(A) do{if(id->misc->trace_leave)id->misc->trace_leave((A));}while(0)      mapping (string:mixed *) variables=([]);      object this = this_object();   int module_type;
Roxen.git/server/base_server/module.pike:97:    }    return(f());    }    void create(int mode_, function f_)    {    mode = mode_;    f = f_;    }   };    + constant reg_s_loc = Locale.Roxen.standard.register_module_doc; +    // Define a variable, with more than a little error checking...   void defvar(string|void var, mixed|void value, string|void name,    int|void type, string|void doc_str, mixed|void misc,    int|function|void not_in_config)   { -  + #if defined(MODULE_DEBUG)    if(!strlen(var))    error("No name for variable!\n"); -  +    // if(var[0]=='_' && previous_object() != roxen)   // error("Variable names beginning with '_' are reserved for"   // " internal usage.\n"); -  +     if (!stringp(name)) -  name = var; +  error("The variable "+var+"has no name.\n");       if((search(name, "\"") != -1))    error("Please do not use \" in variable names");       if (!stringp(doc_str))    doc_str = "No documentation";       switch (type & VAR_TYPE_MASK)    {    case TYPE_NODE:
Roxen.git/server/base_server/module.pike:246:    case TYPE_PORTS:    case TYPE_FONT:    // FIXME: Add checks for these.    break;       default:    report_error(sprintf("%s:\nIllegal type (%s) in defvar.\n",    roxen->filename(this), type));    break;    } + #endif +  // Locale stuff. +  reg_s_loc( this_object(), var, name, doc_str );    -  -  // Locale stuff! -  // Här blir vi farliga... -  Locale.Roxen.standard -  ->register_module_doc( this_object(), var, name, doc_str ); -  -  +     variables[var]=allocate( VAR_SIZE ); -  if(!variables[var]) -  error("Out of memory in defvar.\n"); +     variables[var][ VAR_VALUE ]=value;    variables[var][ VAR_TYPE ]=type&VAR_TYPE_MASK;    variables[var][ VAR_DOC_STR ]=doc_str;    variables[var][ VAR_NAME ]=name;       type &= ~VAR_TYPE_MASK; // Probably not needed, but...    type &= (VAR_EXPERT | VAR_MORE);    if (functionp(not_in_config)) {    if (type) {    variables[var][ VAR_CONFIGURABLE ] = ConfigurableWrapper(type, not_in_config)->check;
Roxen.git/server/base_server/module.pike:280:    } else if (type) {    variables[var][ VAR_CONFIGURABLE ] = type;    } else if(intp(not_in_config)) {    variables[var][ VAR_CONFIGURABLE ] = !not_in_config;    }       variables[var][ VAR_MISC ]=misc;    variables[var][ VAR_SHORTNAME ]= var;   }    + static mapping locs = ([]);   void deflocaledoc( string locale, string variable,    string name, string doc, mapping|void translate )   { -  if(!Locale.Roxen[locale]) +  if(!locs[locale] ) +  locs[locale] = Locale.Roxen[locale]->register_module_doc; +  if(!locs[locale])    report_debug("Invalid locale: "+locale+". Ignoring.\n");    else -  Locale.Roxen[locale] -  ->register_module_doc( this_object(), variable, name, doc, translate ); +  locs[locale]( this_object(), variable, name, doc, translate );   }      // Convenience function, define an invisible variable, this variable   // will be saved, but it won't be visible in the configuration interface.   void definvisvar(string name, int value, int type, array|void misc)   {    defvar(name, value, "", type, "", misc, 1);   }      string check_variable( string s, mixed value )