// // E_Include // // The normal include function. cfg_include is insufficient since it // looks in the current working directory unless provided a full path. // This function interprets paths relative to the current file when // called from a physical input file, and uses the argument as a lump // name otherwise. // int E_Include(cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv) { char *currentpath = NULL; char *filename = NULL; size_t len = 0; int lumpnum = -1; if(argc != 1) { cfg_error(cfg, "wrong number of args to include()\n"); return 1; } if(!cfg->filename) { cfg_error(cfg, "include: cfg_t filename is undefined\n"); return 1; } // 02/09/05: support both files and lumps in this function, but // only one or the other depending on the calling context switch(cfg_lexer_source_type(cfg)) { case -1: // physical file len = M_StringAlloca(¤tpath, 1, 2, cfg->filename); M_GetFilePath(cfg->filename, currentpath, len); filename = M_SafeFilePath(currentpath, argv[0]); return E_OpenAndCheckInclude(cfg, filename, -1); default: // data source if(strlen(argv[0]) > 8) { cfg_error(cfg, "include: %s is not a valid lump name\n", argv[0]); return 1; } // haleyjd 03/19/10: // find a lump of the requested name in the same data source only if((lumpnum = E_FindLumpInclude(cfg, argv[0])) < 0) { cfg_error(cfg, "include: %s not found\n", argv[0]); return 1; } return E_OpenAndCheckInclude(cfg, argv[0], lumpnum); } }
void G_LoadDefaults(void) { char *temp = NULL; size_t len; DWFILE dwfile, *file = &dwfile; len = M_StringAlloca(&temp, 1, 18, usergamepath); // haleyjd 11/23/06: use basegamepath // haleyjd 08/29/09: allow use_doom_config override if(GameModeInfo->type == Game_DOOM && use_doom_config) psnprintf(temp, len, "%s/doom/keys.csc", userpath); else psnprintf(temp, len, "%s/keys.csc", usergamepath); cfg_file = estrdup(temp); if(access(cfg_file, R_OK)) { C_Printf("keys.csc not found, using defaults\n"); D_OpenLump(file, W_GetNumForName("KEYDEFS")); } else D_OpenFile(file, cfg_file, "r"); if(!D_IsOpen(file)) I_Error("G_LoadDefaults: couldn't open default key bindings\n"); // haleyjd 03/08/06: test for zero length if(!D_IsLump(file) && D_FileLength(file) == 0) { // try the lump because the file is zero-length... C_Printf("keys.csc is zero length, trying KEYDEFS\n"); D_Fclose(file); D_OpenLump(file, W_GetNumForName("KEYDEFS")); if(!D_IsOpen(file) || D_FileLength(file) == 0) I_Error("G_LoadDefaults: KEYDEFS lump is empty\n"); } C_RunScript(file); D_Fclose(file); }