/* * MODULE_URL.pike: Skeleton module for Roxen. * * Written by: Bill Welliver * version 1.0 of 31 July 1997 * * * */ /* * * Load all of the headers and inherited procedures. * */ #include inherit "module"; inherit "roxenlib"; // Inheriting roxenlib may not be nessecary for all modules. // See server/base_server/roxenlib.pike for provided functions. /* * * register_module() is required. * * return elements: * * [1]: Module type (see module.h) may be bitwise or'd (|) for hybrid modules. * [2]: Module name. * [3]: Documentation for module. * [4]: Reserved for future use. * [5]: 0 to allow multiple copies per vserver, 1 to allow only 1 per vserver. * */ array register_module(){ return( { MODULE_URL, "sample url module", "This is a sample skeleton module of type url.", 0, 0|1 } ); } /* * * create() sets up module configuration variables * */ void create(){ /* * * defvar() defines configurable variables. * * arguments: * * [1]: variable name * [2]: default value for variable * [3]: longer variable name * [4]: variable type (see module.h for types) * [5]: documentation for variable * [6]: optional, not used. * * */ defvar( "varname", "value", "long variable name", VARIABLE_TYPE, "documentation string for variable", ({ "choice1", "choice2", "choice3" }) ); } /* * * check_variable(): check validity of config variables... * * check conf interface variables for sanity. * * variable is the name of the variable we're checking * set_to is the value being tested * */ string|void check_variable(string variable, mixed set_to){ // find out what variable we're checking... if(variable=="variable1"){ // find out if it's a value we'll accept... if so, then just return if(set_to=="whatevervalueweaccept") return; // if it's not, return an error message. else return ("Sorry, we don't accept that value...\n"); } } /* * * start(): set up shop... * * do anything required before we are able to service requests * */ void start(){ } /* * * stop(): close up shop... * * tidy up before the module is terminated * */ void stop(){ } /* * * status(): how's the module doing? * * return a string suitable for inclusion in a
tag. * * */ void status(){ return ("Everything's A-OK!\n"); } /* * * info(): what's this module used for? * * return a string that describes this module. * if absent, Roxen will use element 3 of register_module(). * * */ string info(){ return ("Module that doesn't do anything.\n"); } /* * * remap_url(): remap the url * * return request_id or a mapping to a new url. * many of the http_*() functions in roxenlib can be used to return. * * */ object|mapping remap_url(object request_id){ string url; url="http://www.roxen.com"; return (http_redirect(url, request_id); }