Roxen.git / server / base_server / module.pike

version» Context lines:

Roxen.git/server/base_server/module.pike: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>      mapping (string:mixed *) variables=([]);      object this = this_object();   int module_type;   string fix_cvs(string from)   {    from = replace(from, ({ "$", "Id: "," Exp $" }), ({"","",""}));
Roxen.git/server/base_server/module.pike:52:      void start(void|int num) {}   string status() {}      string info()   {    return (this->register_module()[2]);   }      // 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))    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))
Roxen.git/server/base_server/module.pike:75:    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:    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    && arrayp(misc)    && (sizeof(misc)>=3)    && functionp(misc[0])    && functionp(misc[1])    && functionp(misc[2]))    error("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: -  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:    value = ({});    break;       case TYPE_MODULE:    /* No default possible */    value = 0;    break;       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+="/";    break;       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:    value=!!value;    break;       case TYPE_ERROR:    break;       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 );    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;    if((type&~VAR_TYPE_MASK) & VAR_EXPERT)
Roxen.git/server/base_server/module.pike:186:    variables[var][ VAR_CONFIGURABLE ]= !not_in_config;    else if(functionp(not_in_config))    variables[var][ VAR_CONFIGURABLE ]= not_in_config;    variables[var][ VAR_MISC ]=misc;    variables[var][ VAR_SHORTNAME ]= var;   }         // 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 )   {    // Check if `value' is O.K. to store in the variable `s'. If so,    // return 0, otherwise return a string, describing the error.       return 0;   }