Exemplo n.º 1
0
Arquivo: macro.c Projeto: xrg/RPM
void
rpmInitMacros(rpmMacroContext mc, const char * macrofiles)
{
    ARGV_t pattern, globs = NULL;

    if (macrofiles == NULL)
	return;

    argvSplit(&globs, macrofiles, ":");
    for (pattern = globs; *pattern; pattern++) {
	ARGV_t path, files = NULL;
    
	/* Glob expand the macro file path element, expanding ~ to $HOME. */
	if (rpmGlob(*pattern, NULL, &files) != 0) {
	    continue;
	}

	/* Read macros from each file. */
	for (path = files; *path; path++) {
	    if (rpmFileHasSuffix(*path, ".rpmnew") || 
		rpmFileHasSuffix(*path, ".rpmsave") ||
		rpmFileHasSuffix(*path, ".rpmorig")) {
		continue;
	    }
	    (void) rpmLoadMacroFile(mc, *path);
	}
	argvFree(files);
    }
    argvFree(globs);

    /* Reload cmdline macros */
    rpmLoadMacros(rpmCLIMacroContext, RMIL_CMDLINE);
}
Exemplo n.º 2
0
Arquivo: rpmlua.c Projeto: Tojaj/rpm
static int rpm_load(lua_State *L)
{
    const char *str = luaL_checkstring(L, 1);
    int rc = rpmLoadMacroFile(NULL, str);
    lua_pushnumber(L, rc);
    return 1;
}
Exemplo n.º 3
0
/*@modifies L, fileSystem, internalState @*/
{
    if (!lua_isstring(L, 1)) {
        (void)luaL_argerror(L, 1, "filename expected");
    } else {
        rpmlua lua = (rpmlua)getdata(L, "lua");
        const char *filename = lua_tostring(L, 1);
        (void)rpmluaRunScriptFile(lua, filename);
    }
    return 0;
}

extern int _max_load_depth;	/* Maximum load nesting depth. */
static int rpm_load(lua_State *L)
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies L, rpmGlobalMacroContext, fileSystem, internalState @*/
{
    if (!lua_isstring(L, 1)) {
        (void)luaL_argerror(L, 1, "filename expected");
    } else {
        const char *filename = lua_tostring(L, 1);
        /*@-globs@*/
        (void)rpmLoadMacroFile(NULL, filename, _max_load_depth);
        /*@=globs@*/
    }
    return 0;
}