static void init_extensions(void) { conflate_register_mgmt_cb("client_stats", "Retrieve stats from moxi", on_conflate_get_stats); conflate_register_mgmt_cb("reset_stats", "Reset moxi stats", on_conflate_reset_stats); conflate_register_mgmt_cb("ping_test", "Perform a ping test", on_conflate_ping_test); }
int main(int argc, char **argv) { if (argc < 3) { fprintf(stderr, "Usage: bot <jid> <pass> [host]\n"); exit(EX_USAGE); } /* Initialize callbacks for provided functionality. * * These callbacks are global and thus initialized once for your * entire application. */ conflate_register_mgmt_cb("client_stats", "Retrieves stats from the agent", process_stats); conflate_register_mgmt_cb("reset_stats", "Reset stats on the agent", process_reset_stats); conflate_register_mgmt_cb("ping_test", "Perform a ping test", process_ping_test); conflate_register_mgmt_cb("alarm", "Create an alarm", process_alarm_create); /* Perform default configuration initialization. */ conflate_config_t conf; init_conflate(&conf); /* Specify application-specific configuration parameters. */ conf.jid = argv[1]; conf.pass = argv[2]; conf.host = (argc == 4 ? argv[3] : NULL); conf.software = "conflate sample bot"; conf.version = "1.0"; conf.save_path = "/tmp/conflate.db"; conf.log = conflate_stderr_logger; conf.userdata = "something awesome"; conf.new_config = display_config; /* Begin the connection. */ if(!start_conflate(conf)) { fprintf(stderr, "Couldn't initialize libconflate.\n"); exit(1); } /* Typically, your application would go about its business here. Since this is just a demo, the caller has nothing else to do, so we wait forever. */ pause(); }
void conflate_init_commands(void) { if (commands_initialized) { return; } conflate_register_mgmt_cb("set_private", "Set a private value on the agent.", process_set_private); conflate_register_mgmt_cb("get_private", "Get a private value from the agent.", process_get_private); conflate_register_mgmt_cb("rm_private", "Delete a private value from the agent.", process_delete_private); conflate_register_mgmt_cb("serverlist", "Configure a server list.", process_serverlist); commands_initialized = true; }