// // E_OpenAndCheckInclude // // Performs the following actions: // 1. Caches the indicated file or lump (lump only if lumpnum >= 0). // If the file cannot be opened, the libConfuse error code 1 is // returned. // 2. Calls E_CheckInclude on the cached data. // 3. If there is a hash collision, the data is freed. The libConfuse // "ok" code 0 will be returned. // 4. If there is not a hash collision, the data is included through a // call to cfg_lexer_include. The return value of that function will // be propagated. // static int E_OpenAndCheckInclude(cfg_t *cfg, const char *fn, int lumpnum) { size_t len; char *data; int code = 1; E_EDFLogPrintf("\t\t* Including %s\n", fn); // must open the data source if((data = cfg_lexer_mustopen(cfg, fn, lumpnum, &len))) { // see if we already parsed this data source if(E_CheckInclude(data, len)) code = cfg_lexer_include(cfg, data, fn, lumpnum); else { // we already parsed it, but this is not an error; // we ignore the include and return 0 to indicate success. efree(data); code = 0; } } return code; }
DLLIMPORT int cfg_include(cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv) { opt = NULL; if (argc != 1) { cfg_error(cfg, _("wrong number of arguments to cfg_include()")); return 1; } return cfg_lexer_include(cfg, argv[0]); }