示例#1
0
int main(int argc, char **argv)
{
    process_args(argc, argv);
    if (to_process == NULL)
        usage();

    lily_options *options = lily_new_default_options();
    if (gc_threshold != 0)
        options->gc_threshold = gc_threshold;

    options->argc = argc;
    options->argv = argv;

    lily_parse_state *parser = lily_new_parse_state(options);
    lily_lex_mode mode = (do_tags ? lm_tags : lm_no_tags);

    int result;
    if (is_file == 1)
        result = lily_parse_file(parser, mode, to_process);
    else
        result = lily_parse_string(parser, "[cli]", mode, to_process);

    if (result == 0) {
        fputs(lily_build_error_message(parser), stderr);
        exit(EXIT_FAILURE);
    }

    lily_free_parse_state(parser);
    lily_free(options);
    exit(EXIT_SUCCESS);
}
示例#2
0
int main(int argc, char **argv)
{
    int argc_offset;
    process_args(argc, argv, &argc_offset);
    if (to_process == NULL)
        usage();

    lily_options *options = lily_new_options();
    if (gc_start != -1)
        lily_op_gc_start(options, gc_start);
    if (gc_multiplier != -1)
        lily_op_gc_multiplier(options, gc_multiplier);

    lily_op_argv(options, argc - argc_offset, argv + argc_offset);

    lily_state *state = lily_new_state(options);

    int result;

    if (do_tags) {
        if (is_file == 1)
            result = lily_render_file(state, to_process);
        else
            result = lily_render_string(state, "[cli]", to_process);
    }
    else {
        if (is_file == 1)
            result = lily_parse_file(state, to_process);
        else
            result = lily_parse_string(state, "[cli]", to_process);
    }

    if (result == 0) {
        fputs(lily_get_error(state), stderr);
        exit(EXIT_FAILURE);
    }

    lily_free_state(state);
    exit(EXIT_SUCCESS);
}
示例#3
0
文件: mod_lily.c 项目: akavi/lily
static int lily_handler(request_rec *r)
{
    if (strcmp(r->handler, "lily"))
        return DECLINED;

    r->content_type = "text/html";

    lily_options *options = lily_new_default_options();
    options->data = r;
    options->html_sender = (lily_html_sender) ap_rputs;

    lily_parse_state *parser = lily_new_parse_state(options);
    lily_register_package(parser, "server", apache_server_dynaload_table,
            lily_apache_server_loader);

    lily_parse_file(parser, lm_tags, r->filename);

    lily_free_parse_state(parser);
    lily_free_options(options);

    return OK;
}