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.7 2001/01/29 05:40:30 per Exp $"; |
|
|
|
|
|
|
|
LocaleString module_name = LOCALE(1,"Tamaroxchi"); |
|
|
|
|
|
constant module_type = MODULE_ZERO; |
|
|
|
|
LocaleString module_doc_locale = LOCALE(2,"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(LocaleString:function(RequestID:void)) query_action_buttons(RequestID id) |
|
|
|
|
|
|
|
|
|
|
{ |
return ([ LOCALE(3,"Scratch me!") : scratch_me ]); |
} |
|
void scratch_me() |
|
{ |
if(itching) |
{ |
itching = 0; |
report_notice(LOCALE(4,"Aah, that's good.\n")); |
} else |
report_warning(LOCALE(5,"Ouch!\n")); |
} |
|
LocaleString info( Configuration conf ) |
|
|
|
|
|
|
|
{ |
string mp = query_internal_location(); |
|
return sprintf(LOCALE(6,"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(7,"Sorry, we don't accept that value.")+"\n"; |
} |
} |
|
void start(int occasion, Configuration conf) |
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
report_notice(LOCALE(8,"Wow, I feel good!")+"\n"); |
} |
|
void stop() |
|
|
|
|
|
{ |
report_notice(LOCALE(9,"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(10,"Feelin' fine."); |
case 1: how_much = LOCALE(11,"a bit"); break; |
case 2: how_much = LOCALE(12,"noticeably"); break; |
case 3: how_much = LOCALE(13,"quite a bit"); break; |
case 4: how_much = LOCALE(14,"really much"); break; |
case 5: how_much = LOCALE(15,"a lot"); break; |
case 6: how_much = LOCALE(16,"unbearably"); break; |
default: how_much = LOCALE(17,"more than any sane person could stand"); |
} |
return sprintf(LOCALE(18,"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()); |
} |
|
|