Ejemplo n.º 1
0
int context_add_linkopt(struct context *c, const char *opt)
{
    if (c == NULL)
        return -1;
    if (opt == NULL)
        return -1;

    return stringlist_add(c->link_opts, opt);
}
Ejemplo n.º 2
0
int context_add_compileopt(struct context *c, const char *opt)
{
    if (c == NULL)
        return -1;
    if (opt == NULL)
        return -1;

    return stringlist_add(c->compile_opts, opt);
}
Ejemplo n.º 3
0
int language_add_linkopt(struct language *l, const char *opt)
{
    if (l == NULL)
        return -1;
    if (opt == NULL)
        return -1;
    if (l->link_opts == NULL)
        return -1;

    return stringlist_add(l->link_opts, opt);
}
Ejemplo n.º 4
0
int language_add_compileopt(struct language *l, const char *opt)
{
    if (l == NULL)
        return -1;
    if (opt == NULL)
        return -1;
    if (l->compile_opts == NULL)
        return -1;

    return stringlist_add(l->compile_opts, opt);
}
Ejemplo n.º 5
0
static error_t parse_opt(int key, char *arg, struct argp_state *state)
{
    CONFIGURATION *configuration = state->input;
    switch (key)
    {
    case 'b':
        configuration->backslash_escapes_delimiters = true;
        break;
    case 'd':
        configuration->delimiters = convert_escaped_delimiters(arg);
        break;
    case 'e':
        configuration->allow_empty_tokens = true;
        break;
    case 'E':
        configuration->excludes = make_excludes(arg);
        break;
    case 'f':
        configuration->file = arg;
        break;
    case 'N':
        configuration->empty_string = arg;
        break;
    case 'q':
        set_quote_characters(configuration, arg);
        break;
    case 'S':
        configuration->separator = arg;
        break;
    case 'T':
        configuration->trim_non_alphanumeric = true;
        break;
    case ARGP_KEY_NO_ARGS:
        configuration_delete(configuration);
        argp_usage(state);
         /*NOTREACHED*/
        break;
    case ARGP_KEY_ARG:
        for (int i = state->next - 1; i >= 0 && i < state->argc; ++i)
        {
            stringlist_add(configuration->fields, state->argv[i]);
        }
        state->next = state->argc;
        break;
    default:
        return ARGP_ERR_UNKNOWN;
    }
    return 0;
}
Ejemplo n.º 6
0
void cmd_alias(const char *name, const char *cmd_name, const char *subcmd_name)
{
	struct command *cmd, *alias;
	assert(strchr(name, ' ') == NULL); // not supported
	assert(cmd = cmd_find(cmd_name, command_list));
	assert(!subcmd_name || (cmd->subcommands && (cmd = cmd_find(subcmd_name, cmd->subcommands))));

	alias = malloc(sizeof(struct command));
	memcpy(alias, cmd, sizeof(struct command));
	alias->name = name;
	alias->alias = 1;
	dict_insert(command_list, (char *)alias->name, alias);

	if(!cmd->aliases)
		cmd->aliases = stringlist_create();
	stringlist_add(cmd->aliases, strdup(alias->name));
}
Ejemplo n.º 7
0
void makefile_create_target(struct makefile *m, const char *name)
{
    assert(m->state == MAKEFILE_STATE_NONE);
    m->state = MAKEFILE_STATE_TARGET;

    if (stringlist_include(m->every_target, name)) {
        m->skip_target = true;
    }
    else {
        char *tmp;

        tmp = talloc_strdup(m, name);
        stringlist_add(m->every_target, tmp);
        talloc_unlink(m, tmp);
        fprintf(m->file, "%s:", name);
        m->skip_target = false;
    }
}
Ejemplo n.º 8
0
int context_source_destructor(struct context *c)
{
    struct language *l;
    void *context;
    const char *obj_name;

    assert(c->type == CONTEXT_TYPE_SOURCE);
#ifdef DEBUG
    fprintf(stderr, "context_source_destructor('%s', '%s')\n",
            c->full_path, c->parent->full_path);
#endif

    /* Try to find a language that's compatible with the language already used
     * in this binary, and is compatible with this current source file. */
    l = languagelist_search(c->ll, c->parent->language, c->full_path, c);
    if (l == NULL) {
        fprintf(stderr, "No language found for '%s'\n", c->full_path);

        if ((c->parent == NULL) || (c->parent->language == NULL))
            abort();

        fprintf(stderr, "Parent language is '%s', from '%s'\n",
                c->parent->language->name, c->parent->full_path);
        abort();
    }
    c->parent->language = l;
#ifdef DEBUG
    fprintf(stderr, "\tc->parent->language->name: '%s'\n",
            c->parent->language->name);
#endif

    /* Try and figure out if the grandparent of this code should be a
     * shared or static library. */
    if (l->cares_about_static == true) {
        struct context *lc;

        lc = c;
        while (lc != NULL) {
            if (lc->type == CONTEXT_TYPE_LIBRARY)
                break;

            if (lc->parent == lc) {
                lc = NULL;
                break;
            }

            lc = lc->parent;
        }

        /* It's very possible we ended up with something that
         * _doesn't_ target a library, which is perfectly fine. */
        if (lc != NULL) {
            char *ext;

            ext = strstr(lc->full_path, ".");
            if (ext == NULL)
                abort();
            ext++;

            if (strcmp(ext, lc->language->so_ext_canon) == 0)
                c->shared_target = true;
            else if (strcmp(ext, lc->language->a_ext_canon) == 0)
                c->shared_target = false;
            else
                abort();
        }
    }

    /* We need to allocate some temporary memory */
    context = talloc_new(NULL);

    /* Some languages don't need to be compiled (just linked) so we skip the
     * entire compiling phase. */
    if (language_needs_compile(l, c) == true) {
        /* This is the name that our code will be compiled into.  This must
         * succeed, as we just checked that it's necessary. */
        obj_name = language_objname(l, context, c);
        assert(obj_name != NULL);

        /* This handles half of the whole "--binname --objname" stuff,
         * which is why it's so messy! */
        if (found_binary && c->called_path != NULL) {
            if (strcmp(c->called_path, o->srcname) == 0) {
                printf("%s\n", obj_name);
                talloc_disable_null_tracking();
                exit(0);
            }
        }

        /* If we've already built this dependency, then it's not necessary to
         * add it to the build list again, so skip it. */
        if (!stringlist_include(c->mf->targets, obj_name)) {
            makefile_add_targets(c->mf, obj_name);
            makefile_create_target(c->mf, obj_name);

            makefile_start_deps(c->mf);
            language_deps_vadd_dep(l, c, c->mf);
            makefile_end_deps(c->mf);

            makefile_start_cmds(c->mf);
            language_build_pass_vcmd(l, c);
            makefile_end_cmds(c->mf);

            makefile_add_targets(c->mf, obj_name);
            makefile_add_clean(c->mf, obj_name);
            makefile_add_cleancache(c->mf, c->obj_dir);
        }
    } else {
        /* The "objects" for languages that aren't compiled are really just the
         * included sources. */
        obj_name = talloc_reference(context, c->full_path);
    }

    /* Adds every "extra" (which is defined as any other sources that should be 
     * linked in as a result of this SOURCES += line) to the stack. */
    if (stringlist_include(c->parent->objects, obj_name) == false) {
        language_extras_pass_cs_push_fs(l, c, context, c->s);
        stringlist_add(c->parent->objects, obj_name);
    }

    /* Run some language-specific quirks here */
    language_quirks(l, c, c->mf);

    /* Everything succeeded! */
    TALLOC_FREE(context);
    return 0;
}
Ejemplo n.º 9
0
void makefile_add_distclean(struct makefile *m, const char *name)
{
    stringlist_add(m->targets_distclean, name);
}
Ejemplo n.º 10
0
void makefile_add_cleancache(struct makefile *m, const char *name)
{
    stringlist_add(m->targets_cleancache, name);
}
Ejemplo n.º 11
0
void makefile_add_all(struct makefile *m, const char *name)
{
    stringlist_add(m->targets_all, name);
}
static int body_cb (http_parser *p, const char *buf, size_t len)
{
    http_parser_helper_t* helper = (http_parser_helper_t*) p;
    helper->body = stringlist_add(helper->body, buf, len);
    return 0;
}