/** * Free a goto list, appending the states that do not match the state argument * to the list at states. Returns AC_SUCCESS if successful or AC_FAILURE * otherwise. */ ac_error_code ac_goto_list_free(ac_list* self, ac_list* states, ac_state* state) { ac_goto_list_free_data free_data = { states, state }; return ac_list_free(self, ac_goto_list_free_item, &free_data); }
void user_complete(int row, const char *prompt, char *name, size_t size) { if (name && size) *name = '\0'; ac_list *acl = user_build_ac_list(); if (!acl) return; screen_move(row, 0); autocomplete(acl, prompt, name, size); ac_list_free(acl); }
/* Test-stub */ int main (int argc, char *argv[]) { char *complete_qry = NULL; GList *matches = NULL; /* Arguments check */ if (argc != 2) { /* Automatic test-stub */ printf ("Test case: completion_qry = 'ac'\n"); complete_qry = strdup("ac"); matches = ac_list_get (complete_qry); ac_list_print (matches, complete_qry); matches = ac_list_free (matches); free (complete_qry); printf ("Test case: completion_qry = '/et'\n"); complete_qry = strdup("/et"); matches = ac_list_get (complete_qry); ac_list_print (matches, complete_qry); matches = ac_list_free (matches); free (complete_qry); printf ("Test case: completion_qry = '../'\n"); complete_qry = strdup("../"); matches = ac_list_get (complete_qry); ac_list_print (matches, complete_qry); matches = ac_list_free (matches); free (complete_qry); } else { /* Test-stub with commandline arguments */ printf ("Test case: completion_qry = '%s'\n", argv[1]); matches = ac_list_get (argv[1]); ac_list_print (matches, argv[1]); matches = ac_list_free (matches); } return (0); }
/** * Free the state queue. */ void ac_state_queue_free(ac_list* self) { (void) ac_list_free(self, ac_list_free_keep_item, NULL); }
/** * Free the output list, calling object_free on the associated object of * each output item. */ void ac_output_list_free(ac_list* self, ac_free_function object_free) { (void) ac_list_free(self, ac_output_list_free_item, object_free); }