MCPcopy Index your code
hub / github.com/NetHack/NetHack / process_savefile

Function process_savefile

util/sfctool.c:296–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294/* ======================================================================== */
295
296static int
297process_savefile(const char *srcfnam, enum saveformats srcstyle,
298 char *dstfnam, enum saveformats cvtstyle, boolean unconvert)
299{
300 NHFILE *nhfp[2]; /* one for UNCONVERTED, one for CONVERTED */
301 int srcidx = unconvert ? CONVERTED : UNCONVERTED,
302 dstidx = unconvert ? UNCONVERTED : CONVERTED,
303 sfstatus = 0, i;
304 char indicator, file_csc_count;
305 extern struct version_info vers_info;
306 extern uchar cscbuf[];
307 /* nh_uncompress(fq_save); */
308 const char *dmfile;
309
310 if ((nhfp[srcidx] = open_srcfile(srcfnam, srcstyle)) == 0)
311 return 0;
312 sfstatus = validate(nhfp[srcidx], srcfnam, FALSE);
313 dmfile = what_datamodel_is_this(0,
314 cscbuf[1], /* short */
315 cscbuf[2], /* int */
316 cscbuf[3], /* long */
317 cscbuf[4], /* long long */
318 cscbuf[5]); /* ptr */
319 if (sfstatus > SF_UPTODATE
320 && ((sfstatus <= SF_CRITICAL_BYTE_COUNT_MISMATCH) || !unconvert)) {
321 if (sfstatus == SF_OUTDATED) {
322 fprintf(stderr,
323 "The %s savefile is outdated with respect to this %d.%d.%d EDITLEVEL %ld "
324 "%s%s%s.\n",
325 briefname(srcfnam),
326 VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL,
327 (long) EDITLEVEL,
328 thisdatamodel ? thisdatamodel : "",
329 thisdatamodel ? " " : "",
330 "sfctool");
331 return 0;
332 } else {
333 fprintf(stderr,
334 "The %s savefile %s%s%s not compatible with this %s%s %s utility.\n",
335 briefname(srcfnam),
336 dmfile ? "is a " : "",
337 dmfile ? dmfile : "",
338 dmfile ? " savefile, thus" : " is",
339 thisdatamodel ? thisdatamodel : "",
340 thisdatamodel ? " " : "",
341 "sfctool");
342 return 0;
343 }
344 }
345 if (sfstatus >= SF_DM_IL32LLP64_ON_ILP32LL64) {
346 renidx = sfstatus - SF_DM_IL32LLP64_ON_ILP32LL64;
347 } else if (sfstatus == SF_UPTODATE) {
348 renidx = -2;
349 }
350 if ((nhfp[dstidx] = create_dstfile(dstfnam, cvtstyle)) == 0) {
351 close_nhfile(nhfp[dstidx]);
352 nh_compress(unconverted_filename);
353 return 0;

Callers 1

mainFunction · 0.85

Calls 14

open_srcfileFunction · 0.85
validateFunction · 0.85
what_datamodel_is_thisFunction · 0.85
fprintfFunction · 0.85
briefnameFunction · 0.85
create_dstfileFunction · 0.85
close_nhfileFunction · 0.85
nh_compressFunction · 0.85
style_to_textFunction · 0.85
rewind_nhfileFunction · 0.85
store_critical_bytesFunction · 0.85
get_plname_from_fileFunction · 0.85

Tested by

no test coverage detected