コード例 #1
0
ファイル: tidy.c プロジェクト: CooCoooo/php-src
/* {{{ proto array tidy_get_config()
   Get current Tidy configuration */
static PHP_FUNCTION(tidy_get_config)
{
	TidyIterator itOpt;
	char *opt_name;
	void *opt_value;
	TidyOptionType optt;

	TIDY_FETCH_OBJECT;

	itOpt = tidyGetOptionList(obj->ptdoc->doc);

	array_init(return_value);

	while (itOpt) {
		TidyOption opt = tidyGetNextOption(obj->ptdoc->doc, &itOpt);

		opt_name = (char *)tidyOptGetName(opt);
		opt_value = php_tidy_get_opt_val(obj->ptdoc, opt, &optt);
		switch (optt) {
			case TidyString:
				add_assoc_str(return_value, opt_name, (zend_string*)opt_value);
				break;

			case TidyInteger:
				add_assoc_long(return_value, opt_name, (zend_long)opt_value);
				break;

			case TidyBoolean:
				add_assoc_bool(return_value, opt_name, opt_value ? 1 : 0);
				break;
		}
	}

	return;
}
コード例 #2
0
ファイル: tidy.c プロジェクト: donaldlee2008/libtidy
static void ForEachOption( TidyDoc tdoc, OptionFunc OptionPrint )
{
    TidyIterator pos = tidyGetOptionList( tdoc );

    while ( pos )
    {
        TidyOption topt = tidyGetNextOption( tdoc, &pos );
        OptionDesc d;

        GetOption( tdoc, topt, &d );
        (*OptionPrint)( tdoc, topt, &d );
    }
}
コード例 #3
0
ファイル: tidy.c プロジェクト: donaldlee2008/libtidy
static
void getSortedOption( TidyDoc tdoc, AllOption_t *tOption )
{
    TidyIterator pos = tidyGetOptionList( tdoc );
    uint i = 0;

    while ( pos )
    {
        TidyOption topt = tidyGetNextOption( tdoc, &pos );
        tOption->topt[i] = topt;
        ++i;
    }
    tOption->topt[i] = NULL; /* sentinel */

    qsort(tOption->topt,
          /* Do not sort the sentinel: hence `-1' */
          sizeof(tOption->topt)/sizeof(tOption->topt[0])-1,
          sizeof(tOption->topt[0]),
          cmpOpt);
}
コード例 #4
0
ファイル: test-get-options.c プロジェクト: geoffmcl/tidy-test
int main (int argc, char **argv)
{
    TidyIterator pos;
    TidyDoc tdoc;
    int count;
    count = 0;

    tdoc = tidyCreate();    
    pos = tidyGetOptionList( tdoc );
    test (pos != 0, & count, "got a tdoc");
    while (1) {
        TidyOption to;
        TidyOptionType tot;
        const char * name;
        const char * option_default;
        int option_default_int;
        Bool option_default_bool;
        to = tidyGetNextOption(tdoc, &pos);
        if (to == 0) {
            break;
        }
        name = tidyOptGetName(to);
        test(name != 0, &count, "name is not null");
        tot = tidyOptGetType(to);
        if (name) {
            test(is_short_ascii_no_ws(name), &count, "name looks OK");
            printf("# %s %d\n", name, tot);
        }
        switch (tot) {
        case TidyString:
            test(1, &count, "got a good opt type");
            option_default = tidyOptGetDefault(to);
            //null seems to be allowed.
            //test (option_default != 0, & count, "string default is not null");
            if (option_default) {
                test(is_short_ascii_no_ws(option_default), &count,
                    "looks like a reasonable default string");
                printf("# %s default value is '%s'.\n", name, option_default);
            }
            break;
        case TidyInteger:
            test(1, &count, "got a good opt type");
            option_default_int = tidyOptGetDefaultInt(to);
            test(abs(option_default_int) < crazy_number, &count,
                "default number doesn't look strange");
            printf("# Integer type default value %d\n", option_default_int);
            break;
        case TidyBoolean:
            test(1, &count, "got a good opt type");
            option_default_bool = tidyOptGetDefaultInt(to);
            test(option_default_bool == 0 || option_default_bool == 1,
                &count, "boolean default is 0 or 1");
            printf("# boolean = %d\n", option_default_bool);
            break;
        default:
            test(0, &count, "got a good opt type");
            printf("# Unknown value for option type %d.\n", tot);
        }
    }
    // TAP plan
    printf ("1..%d\n", count);
    printf("\nTest used libtidy version %s, dated %s\n", tidyLibraryVersion(), tidyReleaseDate());
    if (argc > 1) {
        printf("\n Note this `test-get-options` app v.%s, date %s, does not take any commands!\n", TT_VERSION, TT_DATE);
        show_help();
        return 1;
    }

    return 0;
}