Roxen.git/
server/
base_server/
module.pike
Branch:
Tag:
Non-build tags
All tags
No tags
1997-06-01
1997-06-01 01:07:20 by Henrik Grubbström (Grubba) <grubba@grubba.org>
0f8c877b98fcf9029b0b30ae6cbbae1af727eb8c (
139
lines) (+
80
/-
59
)
[
Show
|
Annotate
]
Branch:
5.2
Cleaned up errors.
Rev: server/base_server/module.pike:1.15
Rev: server/base_server/roxen.pike:1.64
1:
-
/* $Id: module.pike,v 1.
14
1997/
05
/
31
22:
01:
14
grubba Exp $ */
+
/* $Id: module.pike,v 1.
15
1997/
06
/
01
01:
07:19
grubba Exp $ */
#include <module.h>
59:
} // Define a variable, with more than a little error checking...
-
varargs
int
defvar(string var, mixed value, string name, int type,
+
varargs
void
defvar(string var, mixed value, string name, int type,
string doc_str, mixed misc, int|function not_in_config) { if(!strlen(var))
82:
{ case TYPE_NODE: if(!arrayp(value))
-
error("TYPE_NODE variables should contain a list of variables
to use as
"
-
"subnodes.\n");
+
error("TYPE_NODE variables should contain a list of variables
"
+
"to
use
as
subnodes.\n");
break; case TYPE_CUSTOM: if(!misc
101:
case TYPE_FILE: case TYPE_STRING: case TYPE_LOCATION:
-
if(value && !stringp(value))
-
report_error("Passing illegal value to string type variable.\n");
+
if(value && !stringp(value))
{
+
report_error(
sprintf(
"Passing illegal value
(%t:%O) "
+
"
to string type variable.\n"
,
+
value, value
)
)
;
+
}
break; case TYPE_FLOAT: if(!floatp(value))
-
report_error("Passing illegal value (not float) to floating point "
-
"decimal number variable.\n");
+
report_error(
sprintf(
"Passing illegal value (
%t:%O) "
+
"(
not float) to floating point "
+
"decimal number variable.\n"
, value, value
)
)
;
break; case TYPE_INT: if(!intp(value))
-
report_error("Passing illegal value (not int) to integer number variable.\n");
+
report_error(
sprintf(
"Passing illegal value (
%t:%O) "
+
"(
not int) to integer number variable.\n"
,
+
value, value
)
)
;
break; case TYPE_MODULE_LIST:
126:
case TYPE_DIR_LIST: int i;
-
if(!arrayp(value))
-
report_error("Illegal type to TYPE_DIR_LIST, must be array.\n");
-
for(i=0; i<sizeof(value); i++)
-
if(strlen(value[i]))
-
{
+
if(!arrayp(value))
{
+
report_error(
sprintf(
"Illegal type
%t
to TYPE_DIR_LIST,
"
+
"
must be array.\n"
, 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("Passing illegal value (not string) to directory variable.\n");
+
report_error(
sprintf(
"Passing illegal value (
%t:%O) (
not string)
"
+
"
to directory variable.\n"
, value, value
)
)
;
if(value && strlen(value) && ((string)value)[-1] != '/') value+="/";
148:
case TYPE_INT_LIST: case TYPE_STRING_LIST:
-
if(!misc && value && !arrayp(value))
-
report_error("Passing illegal misc (not array) to multiple choice variable.\n");
-
if(misc && !arrayp(misc))
-
report_error("Passing illegal misc (not array) to multiple choice variable.\n");
-
if(misc && search(misc, value)==-1)
-
report_error("Passing value
passed
not present in the misc array.\n");
+
if(!misc && value && !arrayp(value))
{
+
report_error(
sprintf(
"Passing illegal misc (
%t:%O) (
not array)
"
+
"
to multiple choice variable.\n"
, value, value
)
)
;
+
} else {
+
if(misc && !arrayp(misc))
{
+
report_error(
sprintf(
"Passing illegal misc (
%t:%O) (
not array)
"
+
"
to multiple choice variable.\n"
, misc, misc
)
)
;
+
}
+
if(misc && search(misc, value)==-1)
{
+
report_error(
sprintf(
"Passing value
(%t:%O)
not present
"
+
"
in the misc array.\n"
, value, value
)
)
;
+
}
+
}
break; case TYPE_FLAG:
165:
case TYPE_COLOR: if (!intp(value))
-
report_error("Passing illegal value (not int) to color variable.\n");
+
report_error(
sprintf(
"Passing illegal value (
%t:%O) (
not int)
"
+
"
to color variable.\n"
, value, value
)
)
;
break; default: report_error("Illegal type ("+type+") in defvar.\n");
-
+
break;
} variables[var]=allocate( VAR_SIZE );
193:
// Convenience function, define an invissible variable, this variable // will be saved, but it won't be vissible in the configuration interface.
-
int
definvisvar(string name, int value, int type, array|void misc)
+
void
definvisvar(string name, int value, int type, array|void misc)
{
-
return
defvar(name, value, "", type, "", misc, 1);
+
defvar(name, value, "", type, "", misc, 1);
} string check_variable( string s, mixed value )