void wd_msg_handler(MVI_GENERIC_MSG_HEADER_T *Incoming) { logger_detailed("********** Incoming->modname: %s ************", modname[Incoming->moduleID]); switch(Incoming->subType) { case MVI_MSG_BARK: UpdateBarkList(Incoming->moduleID); break; case MVI_MSG_REBOOT: system("reboot"); break; case MVI_MSG_HIBERNATE: hibernate = Incoming->data; if(hibernate == HIBERNATE_OFF) { logger_info("Set Hibernate_mode: %s and reset module timer", hibernate==HIBERNATE_ON?"ON":"OFF"); register_modules(); //Reset all timer } break; default: logger_info("%s: Unknown message type %d",__FUNCTION__, Incoming->subType); break; } }
// In fact, the main is a register function int main(int argc, const char *argv[]) { apr_status_t rv; apr_pool_t *mp; apr_hash_t *ht; struct proto_function *ppfun; apr_initialize(); apr_pool_create(&mp, NULL); ht = apr_hash_make(mp); // now register the module register_modules(&pfun, ht, mp); if (pfun.event == HELLO_EVENT) { ppfun = apr_hash_get(ht, "HELLO_EVENT", APR_HASH_KEY_STRING); if (ppfun != NULL) { ppfun->hello(); } } apr_pool_destroy(mp); apr_terminate(); return 0; }
void initialize() { save_stack_info(); initialize_util_module(); initialize_numerics_module(); initialize_sexpr_module(); initialize_kernel_module(); initialize_inductive_module(); initialize_quotient_module(); init_default_print_fn(); initialize_library_module(); initialize_tactic_module(); initialize_definitional_module(); initialize_frontend_lean_module(); register_modules(); }
void watchdog_main_task() { MVI_GENERIC_MSG_HEADER_T wd_msg; int msgid = create_msg(MVI_WD_MSGQ_KEY); if(msgid < 0) { logger_info("Failed to open WatchDog message"); exit(0); } register_modules(); while(1) { recv_msg(msgid, (void *) &wd_msg, sizeof(MVI_GENERIC_MSG_HEADER_T), 5); wd_msg_handler((MVI_GENERIC_MSG_HEADER_T *) &wd_msg); usleep(10000); wd_action(); } }
/** @brief Initializes Lua */ void LuaContext::initialize() { l = luaL_newstate(); //lua_atpanic(l, l_panic); luaL_openlibs(l); //Associate this LuaContext object with the lua_State pointer lua_contexts[l] = this; //Table to keep track of all userdata lua_newtable(l); lua_newtable(l); lua_pushstring(l, "v"); lua_setfield(l, -2, "__mode"); lua_setmetatable(l, -2); lua_setfield(l, LUA_REGISTRYINDEX, "kq.all_userdata"); //Allow userdata to be indexable lua_newtable(l); lua_setfield(l, LUA_REGISTRYINDEX, "kq.userdata_tables"); //Create the kq table that will contain the whole Kirp's Quest API lua_newtable(l); lua_setglobal(l, "kq"); //Register the C++ functions and types accessible by Lua register_modules(); //Make require() able to load Lua files even from the data.kq archive lua_getglobal(l, "kq"); lua_pushcfunction(l, l_loader); lua_setfield(l, -2, "loader"); luaL_dostring(l, "table.insert(package.loaders, 2, kq.loader)"); lua_pushnil(l); lua_setfield(l, -2, "loader"); lua_pop(l, 1); //Execute the main file do_file_if_exists(l, "main"); main_on_started(); }