static int unload_module(void) { if (check_msgs(vxo_msgs) == -1) return MODULE_LOAD_FAILURE; msgs_unhook_name(inmsg, vxo_exec); stop_msgs(vxo_msgs); msgs_free(vxo_msgs); config_destroy(cfg); table_free(&spots); return unregister_application(app); }
static int unload_module(void) { int res; if (check_msgs(impvbaw_msgs) == -1) return MODULE_LOAD_FAILURE; stop_msgs(impvbaw_msgs); msgs_unhook(&default_msgs, impvbaw_exec); msgs_unhook(impvbaw_msgs, mm_impvbaw_exec); msgs_free(impvbaw_msgs); config_destroy(cfg); table_free(&contracts); table_free(&expiries); table_free(&optns); table_free(&spots); res = unregister_application(app); res |= unregister_application(app2); return res; }
int main(int argc, char *argv[]) { /* We always require a file, will guess a nick if none provided.*/ if(argc < 2) { fprintf(stderr, "%s v%s - a small chat system for multiple users\n", argv[0], VERSION); fprintf(stderr, "usage: %s file [nick]\n", argv[0]); return 1; } if(argv[2] == NULL) { /* If no nick is provided, pick based on the username. */ getlogin_r(nick, MAX_NICK_SIZE); } else { /* Copy from argv and make sure its null-terminated.*/ strncpy(nick, argv[2], MAX_NICK_SIZE); nick[MAX_NICK_SIZE-1] = '\0'; } /* Open the file. Always write at the end. */ ctrl = fopen(argv[1], "a+"); if(ctrl == NULL) { fprintf(stderr, "Unable to open %s!\n", argv[1]); return 1; } /* We don't want to see past messages, as they could be loooooong.*/ fseek(ctrl, 0L, SEEK_END); /* This is now our "last read" position. */ last_read_pos = ftell(ctrl); /* Tell readline to let us know when the user hits enter. */ rl_bind_key(RETURN, handle_enter); /* Setup the fake handler for when readline thinks we're done. */ rl_callback_handler_install(PROMPT, handle_line_fake); /* Done with setup! Now let everyone know the user has arrived. */ write_status("joined"); /* Until we decide to quit, tell readline to grab characters if they're available. */ while(cont) { get_input(); usleep(10000); check_msgs(); usleep(10000); } /* We're quitting now. Say goodbye. */ write_status("left"); /* Clean up for readline now */ rl_unbind_key(RETURN); rl_callback_handler_remove(); /* Being a good citizen. Closing file handles. */ fclose(ctrl); /* Clean up screen. */ rl_set_prompt(""); rl_redisplay(); return 0; }