]> granicus.if.org Git - php/commitdiff
Added two new functions to set the dict-dir and data-dir options.
authorBrian France <bfrance@php.net>
Wed, 11 Feb 2004 18:50:16 +0000 (18:50 +0000)
committerBrian France <bfrance@php.net>
Wed, 11 Feb 2004 18:50:16 +0000 (18:50 +0000)
ext/pspell/php_pspell.h
ext/pspell/pspell.c

index 519a9f70ec4db3899e8da374990c90bbb91bac6e..2111fdecc1757308fee1a93db502afa5d9ac12bf 100644 (file)
@@ -41,6 +41,8 @@ PHP_FUNCTION(pspell_config_runtogether);
 PHP_FUNCTION(pspell_config_mode);
 PHP_FUNCTION(pspell_config_ignore);
 PHP_FUNCTION(pspell_config_personal);
+PHP_FUNCTION(pspell_config_dict_dir);
+PHP_FUNCTION(pspell_config_data_dir);
 PHP_FUNCTION(pspell_config_repl);
 PHP_FUNCTION(pspell_config_save_repl);
 #else
index 8673e844dcf6b4d103e2489a4afbab68c11b017e..e29eccd3220f832e9219aba2b6b4a12796f04220 100644 (file)
@@ -68,6 +68,8 @@ function_entry pspell_functions[] = {
        PHP_FE(pspell_config_mode,              NULL)
        PHP_FE(pspell_config_ignore,            NULL)
        PHP_FE(pspell_config_personal,          NULL)
+       PHP_FE(pspell_config_dict_dir,          NULL)
+       PHP_FE(pspell_config_data_dir,          NULL)
        PHP_FE(pspell_config_repl,              NULL)
        PHP_FE(pspell_config_save_repl,         NULL)
        {NULL, NULL, NULL} 
@@ -803,18 +805,15 @@ PHP_FUNCTION(pspell_config_ignore)
 }
 /* }}} */
 
-/* {{{ proto bool pspell_config_personal(int conf, string personal)
-   Use a personal dictionary for this config */
-PHP_FUNCTION(pspell_config_personal)
-{
+static int pspell_config_path( INTERNAL_FUNCTION_PARAMETERS, char *option ) {
        int type;
-       zval **sccin, **personal;
+       zval **sccin, **value;
        int argc;
 
        PspellConfig *config;
        
        argc = ZEND_NUM_ARGS();
-       if (argc != 2 || zend_get_parameters_ex(argc,&sccin,&personal) == FAILURE) {
+       if (argc != 2 || zend_get_parameters_ex(argc,&sccin,&value) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
 
@@ -825,20 +824,45 @@ PHP_FUNCTION(pspell_config_personal)
                RETURN_FALSE;
        }
 
-       convert_to_string_ex(personal);
+       convert_to_string_ex(value);
 
-       if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(personal), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
+       if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(value), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
                RETURN_FALSE;
        }
 
-       if (php_check_open_basedir(Z_STRVAL_PP(personal) TSRMLS_CC)) {
+       if (php_check_open_basedir(Z_STRVAL_PP(value) TSRMLS_CC)) {
                RETURN_FALSE;
        }
 
-       pspell_config_replace(config, "personal", Z_STRVAL_PP(personal));
+       pspell_config_replace(config, option, Z_STRVAL_PP(value));
 
        RETURN_TRUE;
 }
+
+/* {{{ proto bool pspell_config_personal(int conf, string personal)
+   Use a personal dictionary for this config */
+PHP_FUNCTION(pspell_config_personal)
+{
+       pspell_config_path( INTERNAL_FUNCTION_PARAM_PASSTHRU, "personal");
+}
+/* }}} */
+
+/* {{{ proto bool pspell_config_dict_dir(int conf, string directory)
+
+   location of the main word list */
+PHP_FUNCTION(pspell_config_dict_dir)
+{
+       pspell_config_path( INTERNAL_FUNCTION_PARAM_PASSTHRU, "dict-dir");
+}
+
+/* }}} */
+
+/* {{{ proto bool pspell_config_data_dir(int conf, string directory)
+    location of language data files */
+PHP_FUNCTION(pspell_config_data_dir)
+{
+       pspell_config_path( INTERNAL_FUNCTION_PARAM_PASSTHRU, "data-dir");
+}
 /* }}} */
 
 /* {{{ proto bool pspell_config_repl(int conf, string repl)