MCPcopy Create free account
hub / github.com/TASEmulators/fceux / cfg_NewToOld

Function cfg_NewToOld

src/drivers/common/config.cpp:280–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280void cfg_NewToOld(CFGSTRUCT *cfgst)
281{
282 int x=0;
283
284 while(cfgst[x].ptr)
285 {
286 //structure contains another embedded structure. recurse.
287 if(!cfgst[x].name) {
288 cfg_NewToOld((CFGSTRUCT*)cfgst[x].ptr);
289 x++;
290 continue;
291 }
292
293 //if the key was not found, skip it
294 if(cfgmap.find(std::string(cfgst[x].name)) == cfgmap.end())
295 {
296 x++;
297 continue;
298 }
299
300 if(cfgst[x].len)
301 {
302 //binary data
303 if(!StringToBytes(cfgmap[cfgst[x].name],cfgst[x].ptr,cfgst[x].len))
304 FCEUD_PrintError("Config error: error parsing parameter");
305 }
306 else
307 {
308 //string data
309 if(*(char*)cfgst[x].ptr)
310 free(cfgst[x].ptr);
311 std::string& str = cfgmap[cfgst[x].name];
312 if(str == "")
313 *(char**)cfgst[x].ptr = 0;
314 else
315 *(char**)cfgst[x].ptr = strdup(cfgmap[cfgst[x].name].c_str());
316 }
317
318 x++;
319 }
320}
321
322//saves the old fceu98 format
323void SaveFCEUConfig_old(const char *filename, const CFGSTRUCT *cfgst)

Callers 1

LoadFCEUConfigFunction · 0.85

Calls 2

StringToBytesFunction · 0.85
FCEUD_PrintErrorFunction · 0.50

Tested by

no test coverage detected