/* * Take a line of input and process it, return TRUE if profanity is to * continue, FALSE otherwise */ gboolean process_input(char *inp) { log_debug("Input received: %s", inp); gboolean result = FALSE; g_strstrip(inp); // add line to history if something typed if (strlen(inp) > 0) { cmd_history_append(inp); } // just carry on if no input if (strlen(inp) == 0) { result = TRUE; // handle command if input starts with a '/' } else if (inp[0] == '/') { char *inp_cpy = strdup(inp); char *command = strtok(inp_cpy, " "); result = cmd_execute(command, inp); free(inp_cpy); // call a default handler if input didn't start with '/' } else { result = cmd_execute_default(inp); } ui_input_clear(); roster_reset_search_attempts(); return result; }
void prof_run(const int disable_tls, char *log_level, char *account_name) { _init(disable_tls, log_level); _connect_default(account_name); ui_update(); char *line = NULL; gboolean cmd_result = TRUE; log_info("Starting main event loop"); while(cmd_result) { while(!line) { _check_autoaway(); line = ui_readline(); #ifdef HAVE_LIBOTR otr_poll(); #endif notify_remind(); jabber_process_events(); ui_update(); } cmd_result = cmd_process_input(line); ui_input_clear(); FREE_SET_NULL(line); } }