Update fstapi.c to the latest version
This commit is contained in:
parent
52b136d8a8
commit
ab6ae797b3
69
vpi/fstapi.c
69
vpi/fstapi.c
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2009-2015 Tony Bybell.
|
||||
* Copyright (c) 2009-2018 Tony Bybell.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
|
@ -128,6 +128,7 @@ void **JenkinsIns(void *base_i, const unsigned char *mem, uint32_t length, uint3
|
|||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#define FST_APIMESS "FSTAPI | "
|
||||
|
||||
/***********************/
|
||||
/*** ***/
|
||||
|
|
@ -193,7 +194,7 @@ if(nam) /* cppcheck warning fix: nam is always defined, so this is not needed */
|
|||
dwRetVal = GetTempPath(MAX_PATH, lpTempPathBuffer);
|
||||
if((dwRetVal > MAX_PATH) || (dwRetVal == 0))
|
||||
{
|
||||
fprintf(stderr, "GetTempPath() failed in "__FILE__" line %d, exiting.\n", __LINE__);
|
||||
fprintf(stderr, FST_APIMESS"GetTempPath() failed in "__FILE__" line %d, exiting.\n", __LINE__);
|
||||
exit(255);
|
||||
}
|
||||
else
|
||||
|
|
@ -201,7 +202,7 @@ if(nam) /* cppcheck warning fix: nam is always defined, so this is not needed */
|
|||
uRetVal = GetTempFileName(lpTempPathBuffer, TEXT("FSTW"), 0, szTempFileName);
|
||||
if (uRetVal == 0)
|
||||
{
|
||||
fprintf(stderr, "GetTempFileName() failed in "__FILE__" line %d, exiting.\n", __LINE__);
|
||||
fprintf(stderr, FST_APIMESS"GetTempFileName() failed in "__FILE__" line %d, exiting.\n", __LINE__);
|
||||
exit(255);
|
||||
}
|
||||
else
|
||||
|
|
@ -803,7 +804,7 @@ if(rc<0)
|
|||
{
|
||||
xc->fseek_failed = 1;
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "Seek to #%"PRId64" (whence = %d) failed!\n", offset, whence);
|
||||
fprintf(stderr, FST_APIMESS"Seek to #%"PRId64" (whence = %d) failed!\n", offset, whence);
|
||||
perror("Why");
|
||||
#endif
|
||||
}
|
||||
|
|
@ -1663,7 +1664,7 @@ if(zerocnt)
|
|||
/* fpos += */ fstWriterVarint(f, (zerocnt << 1)); /* scan-build */
|
||||
}
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "value chains: %d\n", cnt);
|
||||
fprintf(stderr, FST_APIMESS"value chains: %d\n", cnt);
|
||||
#endif
|
||||
|
||||
xc->vchg_mem[0] = '!';
|
||||
|
|
@ -1738,7 +1739,7 @@ if(xc->dump_size_limit)
|
|||
xc2->size_limit_locked = 1;
|
||||
xc2->is_initial_time = 1; /* to trick emit value and emit time change */
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "<< dump file size limit reached, stopping dumping >>\n");
|
||||
fprintf(stderr, FST_APIMESS"<< dump file size limit reached, stopping dumping >>\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -2478,7 +2479,7 @@ if(xc)
|
|||
#ifndef FST_WRITER_PARALLEL
|
||||
if(xc->parallel_enabled)
|
||||
{
|
||||
fprintf(stderr, "ERROR: fstWriterSetParallelMode(), FST_WRITER_PARALLEL not enabled during compile, exiting.\n");
|
||||
fprintf(stderr, FST_APIMESS"fstWriterSetParallelMode(), FST_WRITER_PARALLEL not enabled during compile, exiting.\n");
|
||||
exit(255);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -2760,7 +2761,7 @@ if((xc) && (handle <= xc->maxhandle))
|
|||
xc->vchg_mem = realloc(xc->vchg_mem, xc->vchg_alloc_siz);
|
||||
if(!xc->vchg_mem)
|
||||
{
|
||||
fprintf(stderr, "FATAL ERROR, could not realloc() in fstWriterEmitValueChange, exiting.\n");
|
||||
fprintf(stderr, FST_APIMESS"Could not realloc() in fstWriterEmitValueChange, exiting.\n");
|
||||
exit(255);
|
||||
}
|
||||
}
|
||||
|
|
@ -2874,7 +2875,7 @@ if((xc) && (handle <= xc->maxhandle))
|
|||
xc->vchg_mem = realloc(xc->vchg_mem, xc->vchg_alloc_siz);
|
||||
if(!xc->vchg_mem)
|
||||
{
|
||||
fprintf(stderr, "FATAL ERROR, could not realloc() in fstWriterEmitVariableLengthValueChange, exiting.\n");
|
||||
fprintf(stderr, FST_APIMESS"Could not realloc() in fstWriterEmitVariableLengthValueChange, exiting.\n");
|
||||
exit(255);
|
||||
}
|
||||
}
|
||||
|
|
@ -3119,7 +3120,7 @@ if(rc<0)
|
|||
{
|
||||
xc->fseek_failed = 1;
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "Seek to #%"PRId64" (whence = %d) failed!\n", offset, whence);
|
||||
fprintf(stderr, FST_APIMESS"Seek to #%"PRId64" (whence = %d) failed!\n", offset, whence);
|
||||
perror("Why");
|
||||
#endif
|
||||
}
|
||||
|
|
@ -3748,6 +3749,10 @@ if(!xc->fh)
|
|||
else /* FST_BL_SKIP */
|
||||
{
|
||||
pass_status = 0;
|
||||
if(xc->fh)
|
||||
{
|
||||
fclose(xc->fh); xc->fh = NULL; /* needed in case .hier file is missing and there are no hier sections */
|
||||
}
|
||||
}
|
||||
|
||||
free(mem);
|
||||
|
|
@ -4435,7 +4440,7 @@ if(gzread_pass_status)
|
|||
|
||||
if(rc != Z_OK)
|
||||
{
|
||||
printf("geom uncompress rc = %d\n", rc);
|
||||
fprintf(stderr, FST_APIMESS"fstReaderInit(), geom uncompress rc = %d, exiting.\n", rc);
|
||||
exit(255);
|
||||
}
|
||||
|
||||
|
|
@ -4726,7 +4731,7 @@ for(;;)
|
|||
if((sectype == EOF) || (sectype == FST_BL_SKIP))
|
||||
{
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "<< EOF >>\n");
|
||||
fprintf(stderr, FST_APIMESS"<< EOF >>\n");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
|
@ -4765,9 +4770,9 @@ for(;;)
|
|||
mem_required_for_traversal = fstReaderUint64(xc->f);
|
||||
mem_for_traversal = malloc(mem_required_for_traversal + 66); /* add in potential fastlz overhead */
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "sec: %u seclen: %d begtim: %d endtim: %d\n",
|
||||
fprintf(stderr, FST_APIMESS"sec: %u seclen: %d begtim: %d endtim: %d\n",
|
||||
secnum, (int)seclen, (int)beg_tim, (int)end_tim);
|
||||
fprintf(stderr, "\tmem_required_for_traversal: %d\n", (int)mem_required_for_traversal);
|
||||
fprintf(stderr, FST_APIMESS"mem_required_for_traversal: %d\n", (int)mem_required_for_traversal);
|
||||
#endif
|
||||
/* process time block */
|
||||
{
|
||||
|
|
@ -4785,7 +4790,7 @@ for(;;)
|
|||
tsec_clen = fstReaderUint64(xc->f);
|
||||
tsec_nitems = fstReaderUint64(xc->f);
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "\ttime section unc: %d, com: %d (%d items)\n",
|
||||
fprintf(stderr, FST_APIMESS"time section unc: %d, com: %d (%d items)\n",
|
||||
(int)tsec_uclen, (int)tsec_clen, (int)tsec_nitems);
|
||||
#endif
|
||||
if(tsec_clen > seclen) break; /* corrupted tsec_clen: by definition it can't be larger than size of section */
|
||||
|
|
@ -4805,7 +4810,7 @@ for(;;)
|
|||
|
||||
if(rc != Z_OK)
|
||||
{
|
||||
printf("tsec uncompress rc = %d\n", rc);
|
||||
fprintf(stderr, FST_APIMESS"fstReaderIterBlocks2(), tsec uncompress rc = %d, exiting.\n", rc);
|
||||
exit(255);
|
||||
}
|
||||
|
||||
|
|
@ -4881,7 +4886,7 @@ for(;;)
|
|||
rc = uncompress(mu, &destlen, mc, sourcelen);
|
||||
if(rc != Z_OK)
|
||||
{
|
||||
printf("rc: %d\n", rc);
|
||||
fprintf(stderr, FST_APIMESS"fstReaderIterBlocks2(), frame uncompress rc: %d, exiting.\n", rc);
|
||||
exit(255);
|
||||
}
|
||||
free(mc);
|
||||
|
|
@ -5044,9 +5049,9 @@ for(;;)
|
|||
packtype = fgetc(xc->f);
|
||||
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "\tframe_uclen: %d, frame_clen: %d, frame_maxhandle: %d\n",
|
||||
fprintf(stderr, FST_APIMESS"frame_uclen: %d, frame_clen: %d, frame_maxhandle: %d\n",
|
||||
(int)frame_uclen, (int)frame_clen, (int)frame_maxhandle);
|
||||
fprintf(stderr, "\tvc_maxhandle: %d, packtype: %c\n", (int)vc_maxhandle, packtype);
|
||||
fprintf(stderr, FST_APIMESS"vc_maxhandle: %d, packtype: %c\n", (int)vc_maxhandle, packtype);
|
||||
#endif
|
||||
|
||||
indx_pntr = blkpos + seclen - 24 -tsec_clen -8;
|
||||
|
|
@ -5054,7 +5059,7 @@ for(;;)
|
|||
chain_clen = fstReaderUint64(xc->f);
|
||||
indx_pos = indx_pntr - chain_clen;
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "\tindx_pos: %d (%d bytes)\n", (int)indx_pos, (int)chain_clen);
|
||||
fprintf(stderr, FST_APIMESS"indx_pos: %d (%d bytes)\n", (int)indx_pos, (int)chain_clen);
|
||||
#endif
|
||||
chain_cmem = malloc(chain_clen);
|
||||
if(!chain_cmem) goto block_err;
|
||||
|
|
@ -5173,7 +5178,7 @@ for(;;)
|
|||
}
|
||||
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "\tdecompressed chain idx len: %"PRIu32"\n", idx);
|
||||
fprintf(stderr, FST_APIMESS"decompressed chain idx len: %"PRIu32"\n", idx);
|
||||
#endif
|
||||
|
||||
mc_mem_len = 16384;
|
||||
|
|
@ -5241,7 +5246,7 @@ for(;;)
|
|||
|
||||
if(rc != Z_OK)
|
||||
{
|
||||
printf("\tfac: %d clen: %d (rc=%d)\n", (int)i, (int)val, rc);
|
||||
fprintf(stderr, FST_APIMESS"fstReaderIterBlocks2(), fac: %d clen: %d (rc=%d), exiting.\n", (int)i, (int)val, rc);
|
||||
exit(255);
|
||||
}
|
||||
|
||||
|
|
@ -5793,9 +5798,9 @@ mem_required_for_traversal =
|
|||
fstReaderUint64(xc->f);
|
||||
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "rvat sec: %u seclen: %d begtim: %d endtim: %d\n",
|
||||
fprintf(stderr, FST_APIMESS"rvat sec: %u seclen: %d begtim: %d endtim: %d\n",
|
||||
secnum, (int)seclen, (int)beg_tim, (int)end_tim);
|
||||
fprintf(stderr, "\tmem_required_for_traversal: %d\n", (int)mem_required_for_traversal);
|
||||
fprintf(stderr, FST_APIMESS"mem_required_for_traversal: %d\n", (int)mem_required_for_traversal);
|
||||
#endif
|
||||
|
||||
/* process time block */
|
||||
|
|
@ -5814,7 +5819,7 @@ tsec_uclen = fstReaderUint64(xc->f);
|
|||
tsec_clen = fstReaderUint64(xc->f);
|
||||
tsec_nitems = fstReaderUint64(xc->f);
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "\ttime section unc: %d, com: %d (%d items)\n",
|
||||
fprintf(stderr, FST_APIMESS"time section unc: %d, com: %d (%d items)\n",
|
||||
(int)tsec_uclen, (int)tsec_clen, (int)tsec_nitems);
|
||||
#endif
|
||||
ucdata = malloc(tsec_uclen);
|
||||
|
|
@ -5831,7 +5836,7 @@ if(tsec_uclen != tsec_clen)
|
|||
|
||||
if(rc != Z_OK)
|
||||
{
|
||||
printf("tsec uncompress rc = %d\n", rc);
|
||||
fprintf(stderr, FST_APIMESS"fstReaderGetValueFromHandleAtTime(), tsec uncompress rc = %d, exiting.\n", rc);
|
||||
exit(255);
|
||||
}
|
||||
|
||||
|
|
@ -5879,7 +5884,7 @@ if(frame_uclen == frame_clen)
|
|||
rc = uncompress(xc->rvat_frame_data, &destlen, mc, sourcelen);
|
||||
if(rc != Z_OK)
|
||||
{
|
||||
printf("decompress rc: %d\n", rc);
|
||||
fprintf(stderr, FST_APIMESS"fstReaderGetValueFromHandleAtTime(), frame decompress rc: %d, exiting.\n", rc);
|
||||
exit(255);
|
||||
}
|
||||
free(mc);
|
||||
|
|
@ -5890,9 +5895,9 @@ xc->rvat_vc_start = ftello(xc->f); /* points to '!' character */
|
|||
xc->rvat_packtype = fgetc(xc->f);
|
||||
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "\tframe_uclen: %d, frame_clen: %d, frame_maxhandle: %d\n",
|
||||
fprintf(stderr, FST_APIMESS"frame_uclen: %d, frame_clen: %d, frame_maxhandle: %d\n",
|
||||
(int)frame_uclen, (int)frame_clen, (int)xc->rvat_frame_maxhandle);
|
||||
fprintf(stderr, "\tvc_maxhandle: %d\n", (int)xc->rvat_vc_maxhandle);
|
||||
fprintf(stderr, FST_APIMESS"vc_maxhandle: %d\n", (int)xc->rvat_vc_maxhandle);
|
||||
#endif
|
||||
|
||||
indx_pntr = blkpos + seclen - 24 -tsec_clen -8;
|
||||
|
|
@ -5900,7 +5905,7 @@ fstReaderFseeko(xc, xc->f, indx_pntr, SEEK_SET);
|
|||
chain_clen = fstReaderUint64(xc->f);
|
||||
indx_pos = indx_pntr - chain_clen;
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "\tindx_pos: %d (%d bytes)\n", (int)indx_pos, (int)chain_clen);
|
||||
fprintf(stderr, FST_APIMESS"indx_pos: %d (%d bytes)\n", (int)indx_pos, (int)chain_clen);
|
||||
#endif
|
||||
chain_cmem = malloc(chain_clen);
|
||||
fstReaderFseeko(xc, xc->f, indx_pos, SEEK_SET);
|
||||
|
|
@ -6011,7 +6016,7 @@ for(i=0;i<idx;i++)
|
|||
}
|
||||
|
||||
#ifdef FST_DEBUG
|
||||
fprintf(stderr, "\tdecompressed chain idx len: %"PRIu32"\n", idx);
|
||||
fprintf(stderr, FST_APIMESS"decompressed chain idx len: %"PRIu32"\n", idx);
|
||||
#endif
|
||||
|
||||
xc->rvat_data_valid = 1;
|
||||
|
|
@ -6071,7 +6076,7 @@ if(!xc->rvat_chain_mem)
|
|||
|
||||
if(rc != Z_OK)
|
||||
{
|
||||
printf("\tclen: %d (rc=%d)\n", (int)xc->rvat_chain_len, rc);
|
||||
fprintf(stderr, FST_APIMESS"fstReaderGetValueFromHandleAtTime(), rvat decompress clen: %d (rc=%d), exiting.\n", (int)xc->rvat_chain_len, rc);
|
||||
exit(255);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue