Beispiel #1
0
DLL_EXPORT const char *get_symbol(const char *sym)
{
    char *val;
    SYMBOL_TOKEN        *tok;
    tok=get_symbol_token(sym,0);
    if(tok==NULL)
    {
        val=getenv(sym);
        return(val);
    }
    return(tok->val);
}
Beispiel #2
0
char *read_config_header(const char *ccan_dir, bool verbose)
{
	char *fname = path_join(NULL, ccan_dir, "config.h");
	char **lines;
	unsigned int i;
	char *config_header;

	config_header = grab_file(NULL, fname);
	tal_free(fname);

	if (!config_header)
		return NULL;

	lines = tal_strsplit(config_header, config_header, "\n", STR_EMPTY_OK);
	for (i = 0; i < tal_count(lines) - 1; i++) {
		char *sym;
		const char **line = (const char **)&lines[i];

		if (!get_token(line, "#"))
			continue;
		if (!get_token(line, "define"))
			continue;
		sym = get_symbol_token(lines, line);
		if (streq(sym, "CCAN_COMPILER")) {
			compiler = demangle_string(lines[i]);
			if (!compiler)
				errx(1, "%s:%u:could not parse CCAN_COMPILER",
				     fname, i+1);
			if (verbose)
				printf("%s: compiler set to '%s'\n",
				       fname, compiler);
		} else if (streq(sym, "CCAN_CFLAGS")) {
			cflags = demangle_string(lines[i]);
			if (!cflags)
				errx(1, "%s:%u:could not parse CCAN_CFLAGS",
				     fname, i+1);
			if (verbose)
				printf("%s: compiler flags set to '%s'\n",
				       fname, cflags);
		}
	}
	return config_header;
}
Beispiel #3
0
DLL_EXPORT void set_symbol(const char *sym,const char *value)
{
    SYMBOL_TOKEN        *tok;
    tok=get_symbol_token(sym,1);
    if(tok==NULL)
    {
        return;
    }
    if(tok->val!=NULL)
    {
        free(tok->val);
    }
    tok->val=malloc(strlen(value)+1);
    if(tok->val==NULL)
    {
        return;
    }
    strcpy(tok->val,value);
    return;
}