Roxen.git
/
server
/
base_server
/
module.pike
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/base_server/module.pike:1:
-
/* $Id: module.pike,v 1.
60
1999/12/
14
05
:
15
:
01
nilsson Exp $ */
+
/* $Id: module.pike,v 1.
61
1999/12/
28
00
:
35
:
48
nilsson Exp $ */
#include <module.h> #include <request_trace.h> mapping (string:mixed *) variables=([]); RoxenModule this = this_object(); mapping(string:array(int)) error_log=([]); constant is_module = 1; constant module_type = MODULE_PARSER; constant module_name = "Unnamed module";
Roxen.git/server/base_server/module.pike:106:
} constant ConfigurableWrapper = roxen.ConfigurableWrapper; constant reg_s_loc = Locale.Roxen.standard.register_module_doc; // Define a variable, with more than a little error checking... void defvar(string var, mixed value, string name, int type, string|void doc_str, mixed|void misc, int|function|void not_in_config) {
-
#
if
defined(
MODULE_DEBUG
)
+
#
ifdef
MODULE_DEBUG
if(!strlen(var))
-
error
("No name for variable!\n");
+
report_debug
("No name for variable!\n");
// if(var[0]=='_' && previous_object() != roxen)
-
//
error
("Variable names beginning with '_' are reserved for"
+
//
report_debug
("Variable names beginning with '_' are reserved for"
// " internal usage.\n"); if (!stringp(name))
-
error
("The variable "+var+"has no name.\n");
+
report_debug
("The variable "+var+"has no name.\n");
if((search(name, "\"") != -1))
-
error
("Please do not use \" in variable names");
+
report_debug
("Please do not use \" in variable names");
if (!stringp(doc_str)) doc_str = "No documentation"; switch (type & VAR_TYPE_MASK) { case TYPE_NODE: if(!arrayp(value))
-
error
("TYPE_NODE variables should contain a list of variables "
+
report_debug
("TYPE_NODE variables should contain a list of variables "
"to use as subnodes.\n"); break; case TYPE_CUSTOM: if(!misc && arrayp(misc) && (sizeof(misc)>=3) && functionp(misc[0]) && functionp(misc[1]) && functionp(misc[2]))
-
error
("When defining a TYPE_CUSTOM variable, the MISC "
+
report_debug
("When defining a TYPE_CUSTOM variable, the MISC "
"field must be an array of functionpointers: \n" "({describe,describe_form,set_from_form})\n"); break; case TYPE_TEXT_FIELD: case TYPE_FILE: case TYPE_STRING: case TYPE_LOCATION: case TYPE_PASSWORD: if(value && !stringp(value)) {
-
report_
error
(
sprintf(
"%s:\nPassing illegal value (%t:%O) "
+
report_
debug
("%s:\nPassing illegal value (%t:%O) "
"to string type variable.\n",
-
roxen->filename(this), value, value)
)
;
+
roxen->filename(this), value, value);
} break; case TYPE_FLOAT: if(!floatp(value))
-
report_
error
(
sprintf(
"%s:\nPassing illegal value (%t:%O) "
+
report_
debug
("%s:\nPassing illegal value (%t:%O) "
"(not float) to floating point " "decimal number variable.\n",
-
roxen->filename(this), value, value)
)
;
+
roxen->filename(this), value, value);
break; case TYPE_INT: if(!intp(value))
-
report_
error
(
sprintf(
"%s:\nPassing illegal value (%t:%O) "
+
report_
debug
("%s:\nPassing illegal value (%t:%O) "
"(not int) to integer number variable.\n",
-
roxen->filename(this), value, value)
)
;
+
roxen->filename(this), value, value);
break; case TYPE_MODULE_LIST: value = ({}); break; case TYPE_MODULE: /* No default possible */ value = 0; break; case TYPE_DIR_LIST: int i; if(!arrayp(value)) {
-
report_
error
(
sprintf(
"%s:\nIllegal type %t to TYPE_DIR_LIST, "
+
report_
debug
("%s:\nIllegal type %t to TYPE_DIR_LIST, "
"must be array.\n",
-
roxen->filename(this), value)
)
;
+
roxen->filename(this), value);
value = ({ "./" }); } else { for(i=0; i<sizeof(value); i++) { if(strlen(value[i])) { if(value[i][-1] != '/') value[i] += "/"; } else { value[i]="./"; } } } break; case TYPE_DIR: if(value && !stringp(value))
-
report_
error
(
sprintf(
"%s:\nPassing illegal value (%t:%O) (not string) "
+
report_
debug
("%s:\nPassing illegal value (%t:%O) (not string) "
"to directory variable.\n",
-
roxen->filename(this), value, value)
)
;
+
roxen->filename(this), value, value);
if(value && strlen(value) && ((string)value)[-1] != '/') value+="/"; break; case TYPE_INT_LIST: case TYPE_STRING_LIST: if(!misc && value && !arrayp(value)) {
-
report_
error
(
sprintf(
"%s:\nPassing illegal misc (%t:%O) (not array) "
+
report_
debug
("%s:\nPassing illegal misc (%t:%O) (not array) "
"to multiple choice variable.\n",
-
roxen->filename(this), value, value)
)
;
+
roxen->filename(this), value, value);
} else { if(misc && !arrayp(misc)) {
-
report_
error
(
sprintf(
"%s:\nPassing illegal misc (%t:%O) (not array) "
+
report_
debug
("%s:\nPassing illegal misc (%t:%O) (not array) "
"to multiple choice variable.\n",
-
roxen->filename(this), misc, misc)
)
;
+
roxen->filename(this), misc, misc);
} if(misc && value && search(misc, value)==-1) {
-
roxen
_
perror
(
sprintf(
"%s:\nPassing value (%t:%O) not present "
+
report
_
debug
("%s:\nPassing value (%t:%O) not present "
"in the misc array.\n",
-
roxen->filename(this), value, value)
)
;
+
roxen->filename(this), value, value);
} } break; case TYPE_FLAG: value=!!value; break; case TYPE_ERROR: break; case TYPE_COLOR: if (!intp(value))
-
report_
error
(
sprintf(
"%s:\nPassing illegal value (%t:%O) (not int) "
+
report_
debug
("%s:\nPassing illegal value (%t:%O) (not int) "
"to color variable.\n",
-
roxen->filename(this), value, value)
)
;
+
roxen->filename(this), value, value);
break; case TYPE_FILE_LIST: 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)
)
;
+
report_
debug
("%s:\nIllegal type (%s) in defvar.\n",
+
roxen->filename(this), type);
break; } #endif // Locale stuff. reg_s_loc( this_object(), var, name, doc_str ); variables[var]=allocate( VAR_SIZE ); variables[var][ VAR_VALUE ]=value; variables[var][ VAR_TYPE ]=type&VAR_TYPE_MASK; variables[var][ VAR_DOC_STR ]=doc_str;