int parse_and_print_to_stdout(const char * operation) { if (NULL == operation) { skip_line(stdin); return -1; } if (0 == strcmp(OP_INSERT, operation)) { if (0 != parse_insert(stdin, word_buffer, MAX_WORD_LEN)) return -1; int word_num = trie_insert(word_buffer); if (word_num < 0) return -1; printf("word number: %d\n", word_num); } if (0 == strcmp(OP_PREV, operation)) { int number, start, end; if (0 != parse_prev(stdin, &number, &start, &end)) return -1; int word_num = trie_prev(number, start, end); if (word_num < 0) return -1; printf("word number: %d\n", word_num); } if (0 == strcmp(OP_DELETE, operation)) { int number; if (0 != parse_delete(stdin, &number)) return -1; int word_num = trie_delete(number); if (word_num < 0) return -1; printf("deleted: %d\n", number); } if (0 == strcmp(OP_FIND, operation)) { if (0 != parse_find(stdin, word_buffer, MAX_WORD_LEN)) return -1; int find_result = trie_find(word_buffer, strlen(word_buffer)); if (find_result < 0) return -1; puts(find_result == 0 ? "YES" : "NO"); } if (0 == strcmp(OP_CLEAR, operation)) { if (0 != parse_clear(stdin)) return -1; if (0 != trie_clear()) return -1; puts("cleared"); } return 0; }
int set_contains_l(intset_l_t *set, val_t val, int transactional) { if (transactional == 2) return parse_find(set, val); else return lockc_find(set, val); }