| 294 | /* ======================================================================== */ |
| 295 | |
| 296 | static int |
| 297 | process_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; |
no test coverage detected