- add enchant_broker_list_dicts

This commit is contained in:
Pierre Joye 2006-03-21 18:10:45 +00:00
parent 0040af1960
commit 96f0a94e63
3 changed files with 47 additions and 2 deletions

View file

@ -68,6 +68,7 @@ function_entry enchant_functions[] = {
PHP_FE(enchant_broker_init, NULL)
PHP_FE(enchant_broker_free, NULL)
PHP_FE(enchant_broker_get_error, NULL)
PHP_FE(enchant_broker_list_dicts, NULL)
PHP_FE(enchant_broker_request_dict, NULL)
PHP_FE(enchant_broker_request_pwl_dict, NULL)
PHP_FE(enchant_broker_free_dict, NULL)
@ -152,6 +153,28 @@ describe_dict_fn (const char * const lang,
}
/* }}} */
static void php_enchant_list_dicts_fn( const char * const lang_tag,
const char * const provider_name, const char * const provider_desc,
const char * const provider_file, void * ud) /* {{{ */
{
zval *zdesc = (zval *) ud;
zval *tmp_array;
MAKE_STD_ZVAL(tmp_array);
array_init(tmp_array);
add_assoc_string(tmp_array, "lang_tag", (char *)lang_tag, 1);
add_assoc_string(tmp_array, "provider_name", (char *)provider_name, 1);
add_assoc_string(tmp_array, "provider_desc", (char *)provider_desc, 1);
add_assoc_string(tmp_array, "provider_file", (char *)provider_file, 1);
if (Z_TYPE_P(zdesc) != IS_ARRAY) {
array_init(zdesc);
}
add_next_index_zval(zdesc, tmp_array);
}
/* }}} */
static void php_enchant_broker_free(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
{
if (rsrc->ptr) {
@ -323,6 +346,26 @@ PHP_FUNCTION(enchant_broker_get_error)
}
/* }}} */
/* {{{ proto string enchant_broker_list_dicts(resource broker)
Returns the last error of the broker */
PHP_FUNCTION(enchant_broker_list_dicts)
{
zval *broker;
enchant_broker *pbroker;
EnchantDictDescribeFn describetozval = php_enchant_list_dicts_fn;
char *msg;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &broker) == FAILURE) {
RETURN_FALSE;
}
PHP_ENCHANT_GET_BROKER;
enchant_broker_list_dicts(pbroker->pbroker, php_enchant_list_dicts_fn, (void *)return_value);
}
/* }}} */
/* {{{ proto resource enchant_broker_request_dict(resource broker, string tag)
create a new dictionary using tag, the non-empty language tag you wish to request
a dictionary for ("en_US", "de_DE", ...) */

View file

@ -8,7 +8,7 @@ API for many spell libraries:
- aspell/pspell (intended to replace ispell)
- hspell (hebrew)
- ispell
- myspell (OpenOffice project, mozilla)
- myspell/hunspell (OpenOffice project, mozilla)
- uspell (primarily Yiddish, Hebrew, and Eastern European languages)
A plugin system allows to add custom spell support.
see www.abisource.com/enchant/
@ -35,7 +35,8 @@ see www.abisource.com/enchant/
<api>stable</api>
</stability>
<license uri="http://www.php.net/license">PHP</license>
<notes>- fix compilation warnings
<notes>- add enchant_broker_list_dicts to get a list of available dictionnaries
- fix compilation warnings
- add examples
- add tests</notes>
<contents>

View file

@ -44,6 +44,7 @@ PHP_MINFO_FUNCTION(enchant);
PHP_FUNCTION(enchant_broker_init);
PHP_FUNCTION(enchant_broker_free);
PHP_FUNCTION(enchant_broker_get_error);
PHP_FUNCTION(enchant_broker_list_dicts);
PHP_FUNCTION(enchant_broker_request_dict);
PHP_FUNCTION(enchant_broker_request_pwl_dict);
PHP_FUNCTION(enchant_broker_free_dict);