/* -------------------------------------------------------------------------- Moj pierwszy stagekit.net -------------------------------------------------------------------------- */ #include #include "eng.h" #include "libgen.h" #include "app.h" using namespace std; ausession_t auses[MAX_SESSIONS+1]; /* app user sessions */ /* -------------------------------------------------------------------------- Main single request processing = high level logic Returns OK or internal error code Do NOT set HTTP status here If you want to redirect put something in conn[ci].location -------------------------------------------------------------------------- */ int app_process_req(int ci) { int ret=OK; ALWAYS("Zawsze"); ERR("Powazny blad"); WAR("Ostrzezenie"); INF("Informacja"); DBG("Przydatne przy rozwoju programu"); if ( REQ("") ) { OUT(""); OUT(""); OUT(""); OUT("Stage Kit"); OUT(""); OUT(""); OUT("
"); OUT("

Strona Główna

"); OUT("

Przejdź do Licznika maksymalnej mocy dla danego bezpiecznika:

"); OUT("TUTAJ"); OUT(""); OUT(""); } else if ( REQ("calc") ) { QSVAL strU; // C-type string, np. "150" QSVAL strI; // C-type string, np. "150" QSVAL strP; // C-type string, np. "150" int U; // integer, np. 150 int I; // integer, np. 150 int P; // integer, np. 150 QS("napiecie", strU); QS("natezenie", strI); U = atoi(strU); I = atoi(strI); P = atoi(strP); P = U*I; OUT(""); OUT(""); OUT(""); OUT("Stage Kit"); OUT(""); OUT(""); OUT("
"); OUT("

Licznik maksymalnej mocy dla danego bezpiecznika:

"); OUT("

"); OUT("

"); OUT("Podaj napięcie: "); OUT("
"); OUT("
"); OUT(""); OUT("
"); OUT("
"); OUT("Podaj tolerancję bezpiecznika: "); OUT("
"); OUT("
"); OUT(""); OUT("
"); OUT("
"); OUT(""); OUT("
"); OUT("
"); OUT("

"); OUT("

Maksymalna moc dla tego bezpiecznika wynosi: %s wattów.

", strP); OUT("
"); OUT(""); OUT(""); } return ret; } /* ==================================================================================================================================== */ /* CUSTOM PROCESSING CALLED FROM THE ENGINE */ /* ==================================================================================================================================== */ /* -------------------------------------------------------------------------- App custom init -------------------------------------------------------------------------- */ bool app_init(int argc, char *argv[]) { return TRUE; } /* -------------------------------------------------------------------------- Set global parameters read from conf file -------------------------------------------------------------------------- */ void app_set_param(const char *label, const char *value) { } /* -------------------------------------------------------------------------- New user session custom processing -------------------------------------------------------------------------- */ void app_uses_new(int ci) { } /* -------------------------------------------------------------------------- New logged in user session custom processing -------------------------------------------------------------------------- */ void app_luses_new(int ci) { } /* -------------------------------------------------------------------------- Reset user session -------------------------------------------------------------------------- */ void app_uses_reset(int usi) { } /* -------------------------------------------------------------------------- custom message page can be generated here if return TRUE it means custom page has been generated otherwise generic page will be displayed by the engine -------------------------------------------------------------------------- */ bool app_gen_page_msg(int ci, int msg) { return FALSE; /* use engine generic page */ } /* -------------------------------------------------------------------------- Get error description for user -------------------------------------------------------------------------- */ void app_get_msg_str(int ci, char *dest, int errcode) { } /* -------------------------------------------------------------------------- Process asynchronous call response -------------------------------------------------------------------------- */ void app_async_done(int ci, const char *service, const char *data) { } /* -------------------------------------------------------------------------- App clean-up -------------------------------------------------------------------------- */ void app_done() { }