Back to index

php5  5.3.10
Defines | Functions | Variables
php_enchant.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define phpext_enchant_ptr   &enchant_module_entry
#define PHP_ENCHANT_VERSION   "1.1.0"
#define PHP_ENCHANT_API
#define ENCHANT_G(v)   (enchant_globals.v)

Functions

 PHP_MINIT_FUNCTION (enchant)
 PHP_MSHUTDOWN_FUNCTION (enchant)
 PHP_MINFO_FUNCTION (enchant)
 PHP_FUNCTION (enchant_broker_init)
 PHP_FUNCTION (enchant_broker_free)
 PHP_FUNCTION (enchant_broker_get_error)
 PHP_FUNCTION (enchant_broker_set_dict_path)
 PHP_FUNCTION (enchant_broker_get_dict_path)
 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)
 PHP_FUNCTION (enchant_broker_dict_exists)
 PHP_FUNCTION (enchant_broker_set_ordering)
 PHP_FUNCTION (enchant_broker_describe)
 PHP_FUNCTION (enchant_dict_check)
 PHP_FUNCTION (enchant_dict_suggest)
 PHP_FUNCTION (enchant_dict_add_to_personal)
 PHP_FUNCTION (enchant_dict_add_to_session)
 PHP_FUNCTION (enchant_dict_is_in_session)
 PHP_FUNCTION (enchant_dict_store_replacement)
 PHP_FUNCTION (enchant_dict_get_error)
 PHP_FUNCTION (enchant_dict_describe)
 PHP_FUNCTION (enchant_dict_quick_check)

Variables

zend_module_entry enchant_module_entry

Define Documentation

#define ENCHANT_G (   v)    (enchant_globals.v)

Definition at line 69 of file php_enchant.h.

#define PHP_ENCHANT_API

Definition at line 32 of file php_enchant.h.

#define PHP_ENCHANT_VERSION   "1.1.0"

Definition at line 27 of file php_enchant.h.

Definition at line 25 of file php_enchant.h.


Function Documentation

PHP_FUNCTION ( enchant_broker_init  )

Definition at line 355 of file enchant.c.

{
       enchant_broker *broker;
       EnchantBroker *pbroker;

       if (ZEND_NUM_ARGS()) {
              ZEND_WRONG_PARAM_COUNT();
       }

       pbroker = enchant_broker_init();

       if (pbroker) {
              broker = (enchant_broker *) emalloc(sizeof(enchant_broker));
              broker->pbroker = pbroker;
              broker->dict = NULL;
              broker->dictcnt = 0;
              broker->rsrc_id = ZEND_REGISTER_RESOURCE(return_value, broker, le_enchant_broker);
       } else {
              RETURN_FALSE;
       }
}
PHP_FUNCTION ( enchant_broker_free  )

Definition at line 380 of file enchant.c.

{
       zval *broker;
       enchant_broker *pbroker;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &broker) == FAILURE) {
              RETURN_FALSE;
       }
       PHP_ENCHANT_GET_BROKER;

       zend_list_delete(Z_RESVAL_P(broker));
       RETURN_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_broker_get_error  )

Definition at line 397 of file enchant.c.

{
       zval *broker;
       enchant_broker *pbroker;
       char *msg;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &broker) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_BROKER;

       msg = enchant_broker_get_error(pbroker->pbroker);
       if (msg) {
              RETURN_STRING((char *)msg, 1);
       }
       RETURN_FALSE;
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_broker_set_dict_path  )

Definition at line 494 of file enchant.c.

PHP_FUNCTION ( enchant_broker_get_dict_path  )

Definition at line 503 of file enchant.c.

PHP_FUNCTION ( enchant_broker_list_dicts  )

Definition at line 512 of file enchant.c.

{
       zval *broker;
       enchant_broker *pbroker;

       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);
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_broker_request_dict  )

Definition at line 530 of file enchant.c.

{
       zval *broker;
       enchant_broker *pbroker;
       enchant_dict *dict;
       EnchantDict *d;
       char *tag;
       int taglen;
       int pos;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &broker, &tag, &taglen) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_BROKER;

       d = enchant_broker_request_dict(pbroker->pbroker, (const char *)tag);
       if (d) {
              if (pbroker->dictcnt) {
                     pbroker->dict = (enchant_dict **)erealloc(pbroker->dict, sizeof(enchant_dict *) * pbroker->dictcnt);
                     pos = pbroker->dictcnt++;
              } else {
                     pbroker->dict = (enchant_dict **)emalloc(sizeof(enchant_dict *));
                     pos = 0;
                     pbroker->dictcnt++;
              }

              dict = pbroker->dict[pos] = (enchant_dict *)emalloc(sizeof(enchant_dict));
              dict->id = pos;
              dict->pbroker = pbroker;
              dict->pdict = d;
              dict->prev = pos ? pbroker->dict[pos-1] : NULL;
              dict->next = NULL;
              pbroker->dict[pos] = dict;

              if (pos) {
                     pbroker->dict[pos-1]->next = dict;
              }

              dict->rsrc_id = ZEND_REGISTER_RESOURCE(return_value, dict, le_enchant_dict);
              zend_list_addref(pbroker->rsrc_id);
       } else {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_broker_request_pwl_dict  )

Definition at line 579 of file enchant.c.

{
       zval *broker;
       enchant_broker *pbroker;
       enchant_dict *dict;
       EnchantDict *d;
       char *pwl;
       int pwllen;
       int pos;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &broker, &pwl, &pwllen) == FAILURE) {
              RETURN_FALSE;
       }

       if (strlen(pwl) != pwllen) {
              RETURN_FALSE;
       }

#if PHP_API_VERSION < 20100412
       if ((PG(safe_mode) && (!php_checkuid(pwl, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(pwl TSRMLS_CC)) {
#else
       if (php_check_open_basedir(pwl TSRMLS_CC)) {
#endif
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_BROKER;

       d = enchant_broker_request_pwl_dict(pbroker->pbroker, (const char *)pwl);
       if (d) {
              if (pbroker->dictcnt) {
                     pos = pbroker->dictcnt++;
                     pbroker->dict = (enchant_dict **)erealloc(pbroker->dict, sizeof(enchant_dict *) * pbroker->dictcnt);
              } else {
                     pbroker->dict = (enchant_dict **)emalloc(sizeof(enchant_dict *));
                     pos = 0;
                     pbroker->dictcnt++;
              }
              dict = pbroker->dict[pos] = (enchant_dict *)emalloc(sizeof(enchant_dict));
              dict->id = pos;
              dict->pbroker = pbroker;
              dict->pdict = d;
              dict->prev = pos?pbroker->dict[pos-1]:NULL;
              dict->next = NULL;
              pbroker->dict[pos] = dict;
              if (pos) {
                     pbroker->dict[pos-1]->next = dict;
              }
              dict->rsrc_id = ZEND_REGISTER_RESOURCE(return_value, dict, le_enchant_dict);
       } else {
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_broker_free_dict  )

Definition at line 636 of file enchant.c.

{
       zval *dict;
       enchant_dict *pdict;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &dict) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_DICT;

       zend_list_delete(Z_RESVAL_P(dict));
       RETURN_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_broker_dict_exists  )

Definition at line 654 of file enchant.c.

{
       zval *broker;
       char *tag;
       int taglen;
       enchant_broker * pbroker;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &broker, &tag, &taglen) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_BROKER;

       RETURN_BOOL(enchant_broker_dict_exists(pbroker->pbroker, tag));
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_broker_set_ordering  )

Definition at line 678 of file enchant.c.

{
       zval *broker;
       char *pordering;
       int porderinglen;
       char *ptag;
       int ptaglen;
       enchant_broker * pbroker;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &broker, &ptag, &ptaglen, &pordering, &porderinglen) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_BROKER;

       enchant_broker_set_ordering(pbroker->pbroker, ptag, pordering);
       RETURN_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_broker_describe  )

Definition at line 700 of file enchant.c.

{
       EnchantBrokerDescribeFn describetozval = enumerate_providers_fn;
       zval *broker;
       enchant_broker * pbroker;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &broker) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_BROKER;

       enchant_broker_describe(pbroker->pbroker, describetozval, (void *)return_value);
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_dict_check  )

Definition at line 766 of file enchant.c.

{
       zval *dict;
       char *word;
       int wordlen;
       enchant_dict *pdict;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_DICT;

       RETURN_BOOL(!enchant_dict_check(pdict->pdict, word, wordlen));
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_dict_suggest  )

Definition at line 785 of file enchant.c.

{
       zval *dict;
       char *word;
       int wordlen;
       char **suggs;
       enchant_dict *pdict;
       int n_sugg;
       size_t n_sugg_st;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_DICT;

       suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg_st);
       memcpy(&n_sugg, &n_sugg_st, sizeof(n_sugg));
       if (suggs && n_sugg) {
              int i;

              array_init(return_value);
              for (i = 0; i < n_sugg; i++) {
                     add_next_index_string(return_value, suggs[i], 1);
              }

              enchant_dict_free_suggestions(pdict->pdict, suggs);
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_dict_add_to_personal  )

Definition at line 818 of file enchant.c.

{
       zval *dict;
       char *word;
       int wordlen;
       enchant_dict *pdict;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_DICT;

       enchant_dict_add_to_personal(pdict->pdict, word, wordlen);
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_dict_add_to_session  )

Definition at line 837 of file enchant.c.

{
       zval *dict;
       char *word;
       int wordlen;
       enchant_dict *pdict;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_DICT;

       enchant_dict_add_to_session(pdict->pdict, word, wordlen);
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_dict_is_in_session  )

Definition at line 856 of file enchant.c.

{
       zval *dict;
       char *word;
       int wordlen;
       enchant_dict *pdict;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &dict, &word, &wordlen) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_DICT;

       RETURN_BOOL(enchant_dict_is_in_session(pdict->pdict, word, wordlen));
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_dict_store_replacement  )

Definition at line 878 of file enchant.c.

{
       zval *dict;
       char *mis, *cor;
       int mislen, corlen;

       enchant_dict *pdict;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rss", &dict, &mis, &mislen, &cor, &corlen) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_DICT;

       enchant_dict_store_replacement(pdict->pdict, mis, mislen, cor, corlen);
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_dict_get_error  )

Definition at line 898 of file enchant.c.

{
       zval *dict;
       enchant_dict *pdict;
       char *msg;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &dict) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_DICT;

       msg = enchant_dict_get_error(pdict->pdict);
       if (msg) {
              RETURN_STRING((char *)msg, 1);
       }

       RETURN_FALSE;
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_dict_describe  )

Definition at line 921 of file enchant.c.

{
       zval *dict;
       enchant_dict *pdict;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &dict) == FAILURE) {
              RETURN_FALSE;
       }

       PHP_ENCHANT_GET_DICT;

       enchant_dict_describe(pdict->pdict, describe_dict_fn, (void *)return_value);
}

Here is the call graph for this function:

PHP_FUNCTION ( enchant_dict_quick_check  )

Definition at line 719 of file enchant.c.

{
       zval *dict, *sugg = NULL;
       char *word;
       int wordlen;
       enchant_dict *pdict;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|z/", &dict, &word, &wordlen, &sugg) == FAILURE) {
              RETURN_FALSE;
       }

       if (sugg) {
              zval_dtor(sugg);
       }

       PHP_ENCHANT_GET_DICT;

       if (enchant_dict_check(pdict->pdict, word, wordlen) > 0) {
              int n_sugg;
              size_t n_sugg_st;
              char **suggs;

              if (!sugg && ZEND_NUM_ARGS() == 2) {
                     RETURN_FALSE;
              }

              array_init(sugg);

              suggs = enchant_dict_suggest(pdict->pdict, word, wordlen, &n_sugg_st);
              memcpy(&n_sugg, &n_sugg_st, sizeof(n_sugg));
              if (suggs && n_sugg) {
                     int i;
                     for (i = 0; i < n_sugg; i++) {
                            add_next_index_string(sugg, suggs[i], 1);
                     }
                     enchant_dict_free_suggestions(pdict->pdict, suggs);
              }


              RETURN_FALSE;
       }
       RETURN_TRUE;
}

Here is the call graph for this function:

PHP_MINFO_FUNCTION ( enchant  )

Definition at line 316 of file enchant.c.

{
       EnchantBroker *pbroker;

       pbroker = enchant_broker_init();
       php_info_print_table_start();
       php_info_print_table_header(2, "enchant support", "enabled");
       php_info_print_table_row(2, "Version", PHP_ENCHANT_VERSION);
#ifdef ENCHANT_VERSION_STRING
       php_info_print_table_row(2, "Libenchant Version", ENCHANT_VERSION_STRING);
#elif defined(HAVE_ENCHANT_BROKER_SET_PARAM)
       php_info_print_table_row(2, "Libenchant Version", "1.5.0 or later");
#endif
       php_info_print_table_row(2, "Revision", "$Revision: 321634 $");
       php_info_print_table_end();

       php_info_print_table_start();
       enchant_broker_describe(pbroker, __enumerate_providers_fn, NULL);
       php_info_print_table_end();
       enchant_broker_free(pbroker);
}

Here is the call graph for this function:

PHP_MINIT_FUNCTION ( enchant  )

Definition at line 287 of file enchant.c.

Here is the call graph for this function:

PHP_MSHUTDOWN_FUNCTION ( enchant  )

Definition at line 299 of file enchant.c.

{
       return SUCCESS;
}

Variable Documentation

zend_module_entry enchant_module_entry

Definition at line 155 of file enchant.c.