/*/* Here is a Pike script (not a Caudium module). This script is less than 20 lines (comments and blank lines excluded) and will randomly return one file to the web browser from a list of files. This script was kindly provided by Xavier Beaudouin */ // first we need to inherit from caudiumlib in order to get // the parse, http_redirect functions and id object // recognized. inherit "caudiumlib"; // we declare an array of files array (string)files; // an ASCII text containing the name of a file // on the real filesystem. // Each file name in this file will be // randomly return (the files name have to be on // a separate line). #define FILELIST "/list" #define BASEDIR "/" // this function is the constructor, it will be loaded first void create () { // the array of strings 'files' will contain // all the files we serve provided the file // FILELIST list each file name on one line. files = Stdio.read_bytes(FILELIST)/"\n"; } // if no_reload return 1, Caudium will cache the // result of this script for maximum performances // and will not execute it a second time. // As a result, If you give the argument // ?reload=1 to your script, Caudium will // reload it. // This is useful to use cache for average // content delivery unless you are doing // developpement int no_reload(object id) { if(!id->variables->reload) return 1; return 0; } // As this is a simple pike script (CGI like), this function // will be called by Caudium and should return a string that // will be display to the client's browser. // It can also return a mapping containing all the HTTP response // (headers + text) mapping parse(object id) { // We randomly return one of the file we list in the FILELIST file // (relative to BASEDIR directory). // http_redirect will send a HTTP 301 header telling the browser // where to get randomly selected file. return BASEDIR + files[random(sizeof(files))]; }*/ int main() { write("hello world\n"); return 0; }