MCPcopy Create free account
hub / github.com/NetHack/NetHack / plname_from_file

Function plname_from_file

src/files.c:1356–1391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1354#if defined(SELECTSAVED)
1355
1356char *
1357plname_from_file(
1358 const char *filename,
1359 boolean without_wait_synch_per_file)
1360{
1361 NHFILE *nhfp;
1362 unsigned ln;
1363 char *result = 0;
1364 int sfstatus = 0;
1365
1366 Strcpy(gs.SAVEF, filename);
1367#ifdef COMPRESS_EXTENSION
1368 {
1369 /* if COMPRESS_EXTENSION is present, strip it off */
1370 int sln = (int) strlen(gs.SAVEF),
1371 xln = (int) strlen(COMPRESS_EXTENSION);
1372
1373 if (sln > xln && !strcmp(&gs.SAVEF[sln - xln], COMPRESS_EXTENSION))
1374 gs.SAVEF[sln - xln] = '\0';
1375 }
1376#endif
1377 nh_uncompress(gs.SAVEF);
1378 if ((nhfp = open_savefile()) != 0) {
1379 if ((sfstatus = validate(nhfp, filename,
1380 without_wait_synch_per_file)) == SF_UPTODATE) {
1381 /* room for "name+role+race+gend+algn X" where the space before
1382 X is actually NUL and X is playmode: one of '-', 'X', or 'D' */
1383 ln = (unsigned) PL_NSIZ_PLUS;
1384 result = memset((genericptr_t) alloc(ln), '\0', ln);
1385 get_plname_from_file(nhfp, result, FALSE);
1386 }
1387 close_nhfile(nhfp);
1388 }
1389 nh_compress(gs.SAVEF);
1390 return result; /* file's plname[]+playmode value */
1391}
1392#endif /* defined(SELECTSAVED) */
1393
1394#define SUPPRESS_WAITSYNCH_PERFILE TRUE

Callers 2

vms_get_saved_gamesFunction · 0.85
get_saved_gamesFunction · 0.85

Calls 7

nh_uncompressFunction · 0.85
open_savefileFunction · 0.85
validateFunction · 0.85
get_plname_from_fileFunction · 0.85
close_nhfileFunction · 0.85
nh_compressFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected