inherit "module"; |
|
#include <roxen.h> |
|
|
|
|
|
#define LOCALE(X,Y) _DEF_LOCALE("mod_common_api",X,Y) |
|
|
constant cvs_version="$Id: common_api.pike,v 1.4 2000/11/24 16:50:37 per Exp $"; |
|
|
|
|
|
|
|
LocaleString module_name_locale = LOCALE(0,"Tamaroxchi"); |
|
|
|
|
|
constant module_type = MODULE_ZERO; |
|
|
|
|
LocaleString module_doc_locale = LOCALE(0,"This module does nothing, but its " |
"inlined documentation gets imported " |
"into the roxen programmer manual. " |
"You really don't want to add this " |
"module to your virtual server, promise!"); |
|
|
|
|
constant module_unique = 1; |
|
|
|
constant thread_safe = 0; |
|
|
|
|
|
|
|
|
|
|
int itching = 0; |
|
|
|
void create(Configuration|void conf) |
|
|
|
|
|
|
|
|
{ |
|
set_module_creator("Johan Sundström <jhs@roxen.com>"); |
set_module_url("https://jhs.user.roxen.com/examples/common_api.html"); |
} |
|
mapping(string:function(RequestID:void)) query_action_buttons( RequestID id ) |
|
|
|
|
|
|
|
|
|
|
{ |
return ([ LOCALE(0,"Scratch me!") : scratch_me ]); |
} |
|
void scratch_me() |
|
{ |
if(itching) |
{ |
itching = 0; |
report_notice(LOCALE(0,"Aah, that's good.\n")); |
} else |
report_warning(LOCALE(0,"Ouch!\n")); |
} |
|
LocaleString info( Configuration conf ) |
|
|
|
|
|
|
|
{ |
string mp = query_internal_location(); |
|
return sprintf(LOCALE(0,"This string overrides the documentation string " |
"given in module_doc[_locale], but only once the " |
"module is added to a server. The module's internal " |
"mountpoint is found at <tt>%s</tt>"), mp ); |
} |
|
LocaleString check_variable(string variable, mixed set_to) |
|
|
|
|
|
|
|
|
|
{ |
|
if(variable=="variable1") |
{ |
|
if(set_to=="whatevervalueweaccept") |
return 0; |
else |
return LOCALE(0,"Sorry, we don't accept that value.")+"\n"; |
} |
} |
|
void start(int occasion, Configuration conf) |
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
report_notice(LOCALE(0,"Wow, I feel good!")+"\n"); |
} |
|
void stop() |
|
|
|
|
|
{ |
report_notice(LOCALE(0,"Guess that's what I get for all this itching. *sigh*")+"\n"); |
} |
|
string status() |
|
|
|
|
|
|
{ |
string how_much; |
itching += !random(3); |
|
switch(itching) |
{ |
case 0: return LOCALE(0,"Feelin' fine."); |
case 1: how_much = LOCALE(0,"a bit"); break; |
case 2: how_much = LOCALE(0,"noticeably"); break; |
case 3: how_much = LOCALE(0,"quite a bit"); break; |
case 4: how_much = LOCALE(0,"really much"); break; |
case 5: how_much = LOCALE(0,"a lot"); break; |
case 6: how_much = LOCALE(0,"unbearably"); break; |
default: how_much = LOCALE(0,"more than any sane person could stand"); |
} |
return sprintf(LOCALE(0,"I'm itching %s. Please scratch me!"), how_much); |
} |
|
mapping|int|Stdio.File find_internal(string file, RequestID id) |
|
|
|
|
|
|
|
|
|
|
{ |
return Roxen.http_string_answer(status()); |
} |
|
|