Branch: Tag:

1998-07-07

1998-07-07 17:05:52 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Added support for having config variables that both have a function and VAR_MORE.

Rev: server/base_server/configuration.pike:1.144

1: - string cvs_version = "$Id: configuration.pike,v 1.143 1998/07/04 13:06:29 grubba Exp $"; + string cvs_version = "$Id: configuration.pike,v 1.144 1998/07/07 17:05:52 grubba Exp $";   #include <module.h>   #include <roxen.h>   
82:    m_delete(variables, name);   }    + static class ConfigurableWrapper + { +  int mode; +  function f; +  int check() +  { +  if ((mode & VAR_EXPERT) && +  (!roxen->configuration_interface()->expert_mode)) { +  return 1; +  } +  if ((mode & VAR_MORE) && +  (!roxen->configuration_interface()->more_mode)) { +  return 1; +  } +  return(f()); +  } +  void create(int mode_, function f_) +  { +  mode = mode_; +  f = f_; +  } + }; +    int defvar(string var, mixed value, string name, int type,    string|void doc_str, mixed|void misc,    int|function|void not_in_config)
93:    variables[var][ VAR_NAME ] = name;    variables[var][ VAR_MISC ] = misc;    -  if((type&~VAR_TYPE_MASK) & VAR_EXPERT) -  variables[var][ VAR_CONFIGURABLE ] = VAR_EXPERT; -  else if((type&~VAR_TYPE_MASK) & VAR_MORE) -  variables[var][ VAR_CONFIGURABLE ] = VAR_MORE; -  else -  if(intp(not_in_config)) -  variables[var][ VAR_CONFIGURABLE ]= !not_in_config; -  else if(functionp(not_in_config)) -  variables[var][ VAR_CONFIGURABLE ]= not_in_config; +  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; +  } else { +  variables[var][ VAR_CONFIGURABLE ] = not_in_config; +  } +  } else if (type) { +  variables[var][ VAR_CONFIGURABLE ] = type; +  } else if(intp(not_in_config)) { +  variables[var][ VAR_CONFIGURABLE ] = !not_in_config; +  } +     variables[var][ VAR_SHORTNAME ] = var;   }