/* {{{ proto bool pspell_add_to_session(int pspell, string word) Adds a word to the current session */ static PHP_FUNCTION(pspell_add_to_session) { size_t word_len; zend_long scin; char *word; PspellManager *manager; if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &scin, &word, &word_len) == FAILURE) { return; } PSPELL_FETCH_MANAGER; /*If the word is empty, we have to return; otherwise we'll segfault! ouch!*/ if (word_len == 0) { RETURN_FALSE; } pspell_manager_add_to_session(manager, word); if (pspell_manager_error_number(manager) == 0) { RETURN_TRUE; } else { php_error_docref(NULL, E_WARNING, "pspell_add_to_session() gave error: %s", pspell_manager_error_message(manager)); RETURN_FALSE; } }
/* {{{ proto array pspell_suggest(int pspell, string word) Returns array of suggestions */ static PHP_FUNCTION(pspell_suggest) { zend_long scin; char *word; size_t word_len; PspellManager *manager; const PspellWordList *wl; const char *sug; if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &scin, &word, &word_len) == FAILURE) { return; } PSPELL_FETCH_MANAGER; array_init(return_value); wl = pspell_manager_suggest(manager, word); if (wl) { PspellStringEmulation *els = pspell_word_list_elements(wl); while ((sug = pspell_string_emulation_next(els)) != 0) { add_next_index_string(return_value,(char *)sug); } delete_pspell_string_emulation(els); } else { php_error_docref(NULL, E_WARNING, "PSPELL had a problem. details: %s", pspell_manager_error_message(manager)); RETURN_FALSE; } }
/* {{{ proto bool pspell_clear_session(int pspell) Clears the current session */ static PHP_FUNCTION(pspell_clear_session) { zend_long scin; PspellManager *manager; if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &scin) == FAILURE) { return; } PSPELL_FETCH_MANAGER; pspell_manager_clear_session(manager); if (pspell_manager_error_number(manager) == 0) { RETURN_TRUE; } else { php_error_docref(NULL, E_WARNING, "pspell_clear_session() gave error: %s", pspell_manager_error_message(manager)); RETURN_FALSE; } }
/* {{{ proto bool pspell_store_replacement(int pspell, string misspell, string correct) Notify the dictionary of a user-selected replacement */ static PHP_FUNCTION(pspell_store_replacement) { size_t miss_len, corr_len; zend_long scin; char *miss, *corr; PspellManager *manager; if (zend_parse_parameters(ZEND_NUM_ARGS(), "lss", &scin, &miss, &miss_len, &corr, &corr_len) == FAILURE) { return; } PSPELL_FETCH_MANAGER; pspell_manager_store_replacement(manager, miss, corr); if (pspell_manager_error_number(manager) == 0) { RETURN_TRUE; } else { php_error_docref(NULL, E_WARNING, "pspell_store_replacement() gave error: %s", pspell_manager_error_message(manager)); RETURN_FALSE; } }
static int aspell_dict_check (EnchantDict * me, const char *const word, size_t len) { PspellManager *manager; int val; char *normalizedWord; manager = (PspellManager *) me->user_data; normalizedWord = g_utf8_normalize (word, len, G_NORMALIZE_NFC); val = pspell_manager_check (manager, normalizedWord, strlen(normalizedWord)); g_free(normalizedWord); if (val == 0) return 1; else if (val > 0) return 0; else { enchant_dict_set_error (me, pspell_manager_error_message (manager)); return -1; } }