static int modrequest_load(TCFactory factory,
                           ModRequest *modr, const char *str)
{
    size_t pieces = 0;

    if (factory == NULL || modr == NULL || str == NULL) {
        tc_log_warn(EXE, "wrong parameters for modrequest_load");
        return TC_ERROR;
    }

    modr->rawdata = tc_strsplit(str, ':', &pieces);
    if (modr->rawdata == NULL || pieces != 2) {
        tc_log_warn(EXE, "malformed module string: %s", str);
        return TC_ERROR;
    }
    modr->type = modr->rawdata[0];
    modr->name = modr->rawdata[1];

    modr->module = tc_new_module(factory, modr->type, modr->name, TC_NONE);
    if (modr->module == NULL) {
        tc_log_warn(EXE, "failed creation of module: %s", str);
        return TC_ERROR;
    }
    return TC_OK;
}
Esempio n. 2
0
static int tc_log_debug_init(const char *envname)
{
    const char *envvar = getenv(envname);
    if (envvar) {
        size_t i = 0, n = 0;
        char **tokens = tc_strsplit(envvar, ',', &n);
        int j = 0;

        if (tokens) {
            for (i = 0; i < n; i++) {
                for (j = 0; DebugFlags[j].name != NULL; j++) {
                    if (strcmp(DebugFlags[j].name, tokens[i]) == 0) {
                        TCLog.debug_src |= DebugFlags[j].flag;
                    }
                }
            }

            tc_strfreev(tokens);
        }
    }
    return TC_OK;
}