#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#include <inttypes.h>
#include <zlib.h>
Go to the source code of this file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
00131 {
00132 LXT2_RD_ENC_0,
00133 LXT2_RD_ENC_1,
00134 LXT2_RD_ENC_INV,
00135 LXT2_RD_ENC_LSH0,
00136 LXT2_RD_ENC_LSH1,
00137 LXT2_RD_ENC_RSH0,
00138 LXT2_RD_ENC_RSH1,
00139
00140 LXT2_RD_ENC_ADD1,
00141 LXT2_RD_ENC_ADD2,
00142 LXT2_RD_ENC_ADD3,
00143 LXT2_RD_ENC_ADD4,
00144
00145 LXT2_RD_ENC_SUB1,
00146 LXT2_RD_ENC_SUB2,
00147 LXT2_RD_ENC_SUB3,
00148 LXT2_RD_ENC_SUB4,
00149
00150 LXT2_RD_ENC_X,
00151 LXT2_RD_ENC_Z,
00152
00153 LXT2_RD_ENC_BLACKOUT,
00154
00155 LXT2_RD_DICT_START
00156 };
|
|
|
01125 { PROFILE(LXT2_RD_CLOSE);
01126
01127 if( lt ) {
01128
01129 struct lxt2_rd_block* b;
01130 struct lxt2_rd_block* bt;
01131 unsigned int i;
01132
01133 if( lt->value != NULL ) {
01134 for( i=0; i<lt->numfacs; i++ ) {
01135 free_safe( lt->value[i], (strlen( lt->value[i] ) + 1) );
01136 lt->value[i] = NULL;
01137 }
01138 free_safe( lt->value, (lt->numfacs * sizeof( char* )) );
01139 lt->value = NULL;
01140 }
01141
01142 free_safe( lt->process_mask, ((lt->numfacs / 8) + 1) );
01143 free_safe( lt->process_mask_compressed, ((lt->numfacs / LXT2_RD_PARTIAL_SIZE) + 1) );
01144 free_safe( lt->rows, (lt->numfacs * sizeof( lxtint32_t )) );
01145 free_safe( lt->msb, (lt->numfacs * sizeof( lxtint32_t )) );
01146 free_safe( lt->lsb, (lt->numfacs * sizeof( lxtint32_t )) );
01147 free_safe( lt->flags, (lt->numfacs * sizeof( lxtint32_t )) );
01148 free_safe( lt->len, (lt->numfacs * sizeof( lxtint32_t )) );
01149 free_safe( lt->next_radix, (lt->numfacs * sizeof( void* )) );
01150
01151 lt->process_mask = NULL;
01152 lt->process_mask_compressed = NULL;
01153 lt->rows = NULL;
01154 lt->msb = NULL;
01155 lt->lsb = NULL;
01156 lt->flags = NULL;
01157 lt->len = NULL;
01158 lt->next_radix = NULL;
01159
01160 free_safe( lt->zfacnames, lt->zfacname_predec_size );
01161 lt->zfacnames = NULL;
01162
01163 if( lt->faccache ) {
01164
01165 free_safe( lt->faccache->bufprev, (lt->longestname + 1) );
01166 free_safe( lt->faccache->bufcurr, (lt->longestname + 1) );
01167
01168 lt->faccache->bufprev = NULL;
01169 lt->faccache->bufcurr = NULL;
01170
01171 free_safe( lt->faccache, sizeof( struct lxt2_rd_facname_cache ) );
01172 lt->faccache = NULL;
01173
01174 }
01175
01176 free_safe( lt->fac_map, lt->numfacs * sizeof( granmsk_t ) );
01177 lt->fac_map = NULL;
01178 free_safe( lt->fac_curpos, lt->numfacs * sizeof( char* ) );
01179 lt->fac_curpos = NULL;
01180
01181 b = lt->block_head;
01182 while( b ) {
01183
01184 bt = b->next;
01185
01186 free_safe( b->mem, b->uncompressed_siz );
01187 free_safe( b->string_pointers, (b->num_dict_entries * sizeof( char* )) );
01188 free_safe( b->string_lens, (b->num_dict_entries * sizeof( unsigned int)) );
01189
01190 b->mem = NULL;
01191 b->string_pointers = NULL;
01192 b->string_lens = NULL;
01193
01194 free_safe( b, sizeof( struct lxt2_rd_block ) );
01195
01196 b = bt;
01197
01198 }
01199
01200 lt->block_head = lt->block_curr = NULL;
01201
01202 #ifdef HAVE_LIBZ
01203 if( lt->zhandle ) {
01204 unsigned int rv = gzclose( lt->zhandle );
01205 assert( rv == Z_OK );
01206 lt->zhandle = NULL;
01207 }
01208 #endif
01209
01210 if( lt->handle ) {
01211 unsigned int rv = fclose( lt->handle );
01212 assert( rv == 0 );
01213 lt->handle = NULL;
01214 }
01215
01216 free_safe( lt, sizeof( struct lxt2_rd_trace ) );
01217
01218 }
01219
01220 PROFILE_END;
01221
01222 }
|
|
||||||||||||
|
01482 {
01483
01484 int rc = 0;
01485
01486 if( lt ) {
01487
01488 lt->process_mask_dirty = 1;
01489
01490 if( facidx < lt->numfacs) {
01491 int idx = facidx / 8;
01492 int bitpos = facidx & 7;
01493 /*@-shiftnegative@*/
01494 lt->process_mask[idx] &= ~(1 << bitpos);
01495 /*@=shiftnegative@*/
01496 }
01497
01498 rc = 1;
01499
01500 }
01501
01502 return( rc );
01503
01504 }
|
|
|
01520 {
01521
01522 int rc = 0;
01523
01524 if( lt ) {
01525 lt->process_mask_dirty = 1;
01526 memset( lt->process_mask, 0x00, ((lt->numfacs + 7) / 8) );
01527 rc = 1;
01528 }
01529
01530 return( rc );
01531
01532 }
|
|
||||||||||||
|
01314 {
01315
01316 if( lt && (facidx < lt->numfacs) ) {
01317
01318 while( lt->flags[facidx] & LXT2_RD_SYM_F_ALIAS ) {
01319 facidx = lt->rows[facidx]; /* iterate to next alias */
01320 }
01321
01322 return( facidx );
01323
01324 } else {
01325
01326 return( ~((lxtint32_t)0) );
01327
01328 }
01329
01330 }
|
|
|
01547 {
01548
01549 return( lt->block_mem_consumed );
01550
01551 }
|
|
|
01341 {
01342
01343 return( lt ? lt->end : LXT2_RD_GRAN_0VAL );
01344
01345 }
|
|
||||||||||||
|
|
|
||||||||||||
|
01242 {
01243
01244 if( lt && (facidx < lt->numfacs) ) {
01245 lt->geometry.rows = lt->rows[facidx];
01246 lt->geometry.msb = lt->msb[facidx];
01247 lt->geometry.lsb = lt->lsb[facidx];
01248 lt->geometry.flags = lt->flags[facidx];
01249 lt->geometry.len = lt->len[facidx];
01250 return( <->geometry );
01251 } else {
01252 return( NULL );
01253 }
01254
01255 }
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
01439 {
01440
01441 if( lt ) {
01442
01443 if( facidx < lt->numfacs ) {
01444 int process_idx = facidx / 8;
01445 int process_bit = facidx & 7;
01446 /*@-shiftnegative@*/
01447 return( (lt->process_mask[process_idx] & (1 << process_bit)) != 0 );
01448 /*@=shiftnegative@*/
01449 }
01450
01451 }
01452
01453 return( 0 );
01454
01455 }
|
|
||||||||||||
|
|
|
||||||||||||
|
01361 { PROFILE(LXT2_RD_GET_FACNAME);
01362
01363 char* pnt;
01364 unsigned int clone, j;
01365
01366 if( lt ) {
01367
01368 if( (facidx == (lt->faccache->old_facidx + 1)) || !facidx ) {
01369
01370 if( !facidx ) {
01371 lt->faccache->n = lt->zfacnames;
01372 lt->faccache->bufcurr[0] = 0;
01373 lt->faccache->bufprev[0] = 0;
01374 }
01375
01376 if( facidx != lt->numfacs ) {
01377
01378 pnt = lt->faccache->bufcurr;
01379 lt->faccache->bufcurr = lt->faccache->bufprev;
01380 lt->faccache->bufprev = pnt;
01381
01382 clone = lxt2_rd_get_16( lt->faccache->n, 0 );
01383 lt->faccache->n += 2;
01384 pnt = lt->faccache->bufcurr;
01385
01386 for( j=0; j<clone; j++ ) {
01387 *(pnt++) = lt->faccache->bufprev[j];
01388 }
01389
01390 while( (*(pnt++) = lxt2_rd_get_byte( lt->faccache->n++, 0 )) );
01391
01392 lt->faccache->old_facidx = facidx;
01393
01394 return( lt->faccache->bufcurr );
01395
01396 } else {
01397
01398 return( NULL ); /* no more left */
01399
01400 }
01401
01402 } else {
01403
01404 if( facidx < lt->numfacs ) {
01405
01406 int strt;
01407
01408 if( facidx == lt->faccache->old_facidx ) {
01409 return( lt->faccache->bufcurr );
01410 }
01411
01412 if( facidx > (lt->faccache->old_facidx + 1) ) {
01413 strt = lt->faccache->old_facidx + 1;
01414 } else {
01415 strt = 0;
01416 }
01417
01418 for( j=strt; j<facidx; j++ ) {
01419 (void)lxt2_rd_get_facname( lt, j );
01420 }
01421
01422 return( lxt2_rd_get_facname( lt, j ) );
01423
01424 }
01425
01426 }
01427
01428 }
01429
01430 PROFILE_END;
01431
01432 return( NULL );
01433
01434 }
|
|
|
01565 {
01566
01567 int blk = 0;
01568
01569 if( lt ) {
01570
01571 struct lxt2_rd_block* b = lt->block_head;
01572
01573 while( b ) {
01574 if( !b->short_read_ignore && !b->exclude_block ) {
01575 blk++;
01576 }
01577 b = b->next;
01578 }
01579
01580 }
01581
01582 return( blk );
01583
01584 }
|
|
|
01556 {
01557
01558 return( lt->numblocks );
01559
01560 }
|
|
|
01229 {
01230
01231 return( lt ? lt->numfacs : 0 );
01232
01233 }
|
|
|
01335 {
01336
01337 return( lt ? lt->start : LXT2_RD_GRAN_0VAL );
01338
01339 }
|
|
|
01347 {
01348
01349 return( lt ? lt->timescale : 0 );
01350
01351 }
|
|
|
01814 {
01815
01816 if( lt ) {
01817 return( lt->user_callback_data_pointer );
01818 } else {
01819 return( NULL );
01820 }
01821
01822 }
|
|
|
00829 { PROFILE(LXT2_RD_INIT);
00830
00831 struct lxt2_rd_trace* lt = (struct lxt2_rd_trace*)calloc_safe( 1, sizeof( struct lxt2_rd_trace ) );
00832 unsigned int i;
00833
00834 if( !(lt->handle = fopen( name, "rb" )) ) {
00835
00836 lxt2_rd_close( lt );
00837 lt = NULL;
00838
00839 } else {
00840
00841 lxtint16_t id = 0, version = 0;
00842 lxtint16_t foo;
00843 unsigned int rv;
00844
00845 /* Cutoff after this number of bytes and force flush */
00846 lt->block_mem_max = LXT2_RD_MAX_BLOCK_MEM_USAGE;
00847
00848 /* Keeps gzip from acting weird in tandem with fopen */
00849 rv = setvbuf( lt->handle, (char*)NULL, _IONBF, 0 );
00850 assert( rv == 0 );
00851
00852 (void)fread( &id, 2, 1, lt->handle );
00853 (void)fread( &version, 2, 1, lt->handle );
00854 (void)fread( <->granule_size, 1, 1, lt->handle );
00855
00856 if( (foo = lxt2_rd_get_16( &id, 0 )) != LXT2_RD_HDRID ) {
00857
00858 print_output( "File specified with -lxt is not an LXT formatted dumpfile", FATAL, __FILE__, __LINE__ );
00859 lxt2_rd_close( lt );
00860 lt = NULL;
00861
00862 } else if( (version = lxt2_rd_get_16( &version, 0 )) > LXT2_RD_VERSION ) {
00863
00864 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT dumpfile is version %u which is not supported by Covered", (unsigned int)version );
00865 assert( rv < USER_MSG_LENGTH );
00866 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00867 lxt2_rd_close( lt );
00868 lt = NULL;
00869
00870 } else if( lt->granule_size > LXT2_RD_GRANULE_SIZE ) {
00871
00872 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT dumpfile contains granule size of %u (>%d) which is not supported by Covered",
00873 (unsigned int)lt->granule_size, LXT2_RD_GRANULE_SIZE );
00874 assert( rv < USER_MSG_LENGTH );
00875 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00876 lxt2_rd_close( lt );
00877 lt = NULL;
00878
00879 } else {
00880
00881 unsigned int rc;
00882 char* m;
00883 off_t pos, fend;
00884 unsigned int t;
00885 struct lxt2_rd_block* b;
00886 unsigned int rv;
00887
00888 (void)fread( <->numfacs, 4, 1, lt->handle );
00889 lt->numfacs = lxt2_rd_get_32( <->numfacs, 0 );
00890
00891 (void)fread( <->numfacbytes, 4, 1, lt->handle );
00892 lt->numfacbytes = lxt2_rd_get_32( <->numfacbytes, 0 );
00893
00894 (void)fread( <->longestname, 4, 1, lt->handle );
00895 lt->longestname = lxt2_rd_get_32( <->longestname, 0 );
00896
00897 (void)fread( <->zfacnamesize, 4, 1, lt->handle );
00898 lt->zfacnamesize = lxt2_rd_get_32( <->zfacnamesize, 0 );
00899
00900 (void)fread( <->zfacname_predec_size, 4, 1, lt->handle );
00901 lt->zfacname_predec_size = lxt2_rd_get_32( <->zfacname_predec_size, 0 );
00902
00903 (void)fread( <->zfacgeometrysize, 4, 1, lt->handle );
00904 lt->zfacgeometrysize = lxt2_rd_get_32( <->zfacgeometrysize, 0 );
00905
00906 (void)fread( <->timescale, 1, 1, lt->handle ); /* No swap necessary */
00907
00908 #ifdef DEBUG_MODE
00909 if( debug_mode ) {
00910 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT: %d facilities", lt->numfacs );
00911 assert( rv < USER_MSG_LENGTH );
00912 print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00913 }
00914 #endif
00915
00916 pos = ftello( lt->handle );
00917
00918 lt->process_mask = calloc_safe( 1, ((lt->numfacs / 8) + 1) );
00919 lt->process_mask_compressed = calloc_safe( 1, ((lt->numfacs / LXT2_RD_PARTIAL_SIZE) + 1) );
00920
00921 /* Open and read the name section of the file that is compressed */
00922 lt->zhandle = gzdopen( dup( fileno( lt->handle ) ), "rb" );
00923 m = (char*)malloc_safe_nolimit( lt->zfacname_predec_size );
00924 rc = gzread( lt->zhandle, m, lt->zfacname_predec_size );
00925 rv = gzclose( lt->zhandle );
00926 assert( rv == Z_OK );
00927 lt->zhandle = NULL;
00928
00929 if( rc != lt->zfacname_predec_size ) {
00930 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT: Name section mangled %u (actual) vs %u (expected)", rc, (unsigned int)lt->zfacname_predec_size );
00931 assert( rv < USER_MSG_LENGTH );
00932 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00933 free_safe( m, lt->zfacname_predec_size );
00934 lxt2_rd_close( lt );
00935 lt = NULL;
00936 return( lt );
00937 }
00938
00939 lt->zfacnames = m;
00940
00941 lt->faccache = calloc_safe( 1, sizeof( struct lxt2_rd_facname_cache ) );
00942 lt->faccache->old_facidx = lt->numfacs; /* Causes lxt2_rd_get_facname to initialize its unroll ptr as this is always invalid */
00943 lt->faccache->bufcurr = malloc_safe_nolimit( lt->longestname + 1 );
00944 lt->faccache->bufprev = malloc_safe_nolimit( lt->longestname + 1 );
00945
00946 fseeko( lt->handle, (pos = (pos + lt->zfacnamesize)), SEEK_SET );
00947 lt->zhandle = gzdopen( dup( fileno( lt->handle ) ), "rb" );
00948
00949 t = lt->numfacs * 4 * sizeof( lxtint32_t );
00950 m = (char*)malloc_safe_nolimit( t );
00951 rc = gzread( lt->zhandle, m, t );
00952 rv = gzclose( lt->zhandle );
00953 assert( rv == Z_OK );
00954 lt->zhandle = NULL;
00955
00956 if( rc != t ) {
00957 unsigned int rv;
00958 #ifdef DEBUG_MODE
00959 if( debug_mode ) {
00960 rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT: Geometry section mangled %d (actual) vs %d (expected)", rc, t );
00961 assert( rv < USER_MSG_LENGTH );
00962 print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00963 }
00964 #endif
00965 rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT: No LXT dumpfile information available in file %s", name );
00966 assert( rv < USER_MSG_LENGTH );
00967 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00968 free_safe( m, t );
00969 lxt2_rd_close( lt );
00970 lt = NULL;
00971 return( lt );
00972 }
00973
00974 pos = pos + lt->zfacgeometrysize;
00975
00976 lt->rows = malloc_safe_nolimit( lt->numfacs * sizeof( lxtint32_t ) );
00977 lt->msb = malloc_safe_nolimit( lt->numfacs * sizeof( lxtint32_t ) );
00978 lt->lsb = malloc_safe_nolimit( lt->numfacs * sizeof( lxtint32_t ) );
00979 lt->flags = malloc_safe_nolimit( lt->numfacs * sizeof( lxtint32_t ) );
00980 lt->len = malloc_safe_nolimit( lt->numfacs * sizeof( lxtint32_t ) );
00981 lt->value = malloc_safe_nolimit( lt->numfacs * sizeof( char* ) );
00982 lt->next_radix = malloc_safe_nolimit( lt->numfacs * sizeof( void* ) );
00983
00984 for( i=0; i<lt->numfacs; i++ ) {
00985 unsigned int j;
00986 lt->rows[i] = lxt2_rd_get_32( m + i * 16, 0 );
00987 lt->msb[i] = lxt2_rd_get_32( m + i * 16, 4 );
00988 lt->lsb[i] = lxt2_rd_get_32( m + i * 16, 8 );
00989 lt->flags[i] = lxt2_rd_get_32( m + i * 16, 12 );
00990
00991 if( !(lt->flags[i] & LXT2_RD_SYM_F_INTEGER) ) {
00992 lt->len[i] = (lt->msb[i] <= lt->lsb[i]) ? (lt->lsb[i] - lt->msb[i] + 1) : (lt->msb[i] - lt->lsb[i] + 1);
00993 } else {
00994 lt->len[i] = 32;
00995 }
00996 lt->value[i] = calloc_safe( (lt->len[i] + 1), sizeof( char ) );
00997 for( j=0; j<lt->len[i]; j++ ) {
00998 lt->value[i][j] = 'a';
00999 }
01000 lt->value[i][j] = '\0';
01001 }
01002
01003 for( lt->numrealfacs=0; lt->numrealfacs<lt->numfacs; lt->numrealfacs++ ) {
01004 if( lt->flags[lt->numrealfacs] & LXT2_RD_SYM_F_ALIAS ) {
01005 break;
01006 }
01007 }
01008
01009 if( lt->numrealfacs > lt->numfacs ) {
01010 lt->numrealfacs = lt->numfacs;
01011 }
01012
01013 lt->prev_time = ~(LXT2_RD_GRAN_0VAL);
01014 free_safe( m, t );
01015
01016 lt->fac_map = malloc_safe_nolimit( lt->numfacs * sizeof( granmsk_t ) );
01017 lt->fac_curpos = malloc_safe_nolimit( lt->numfacs * sizeof( char* ) );
01018
01019 for( ; ; ) {
01020
01021 fseeko( lt->handle, 0L, SEEK_END );
01022 fend = ftello( lt->handle );
01023
01024 if( pos >= fend ) {
01025 break;
01026 }
01027
01028 fseeko( lt->handle, pos, SEEK_SET );
01029
01030 b = calloc_safe( 1, sizeof( struct lxt2_rd_block ) );
01031
01032 (void)fread( &b->uncompressed_siz, 4, 1, lt->handle );
01033 b->uncompressed_siz = lxt2_rd_get_32( &b->uncompressed_siz, 0 );
01034
01035 (void)fread( &b->compressed_siz, 4, 1, lt->handle );
01036 b->compressed_siz = lxt2_rd_get_32( &b->compressed_siz, 0 );
01037
01038 (void)fread( &b->start, 8, 1, lt->handle );
01039 b->start = lxt2_rd_get_64( &b->start, 0 );
01040
01041 (void)fread( &b->end, 8, 1, lt->handle );
01042 b->end = lxt2_rd_get_64( &b->end, 0 );
01043
01044 pos = ftello( lt->handle );
01045 fseeko( lt->handle, pos, SEEK_SET );
01046
01047 if( pos >= fend ) {
01048 free_safe( b, 0 ); /* TBD */
01049 break;
01050 }
01051
01052 /* Mark startpos for later in case we purge it from memory */
01053 b->filepos = pos;
01054
01055 if( b->uncompressed_siz && b->compressed_siz && b->end ) {
01056 fseeko(lt->handle, b->compressed_siz, SEEK_CUR);
01057 lt->numblocks++;
01058 if( lt->block_curr ) {
01059 lt->block_curr->next = b;
01060 lt->block_curr = b;
01061 lt->end = b->end;
01062 } else {
01063 lt->block_head = lt->block_curr = b;
01064 lt->start = b->start;
01065 lt->end = b->end;
01066 }
01067 } else {
01068 free_safe( b, 0 ); /* TBD */
01069 break;
01070 }
01071
01072 pos += b->compressed_siz;
01073
01074 }
01075
01076 if( lt->numblocks ) {
01077
01078 #ifdef DEBUG_MODE
01079 if( debug_mode ) {
01080 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT: Read %d block header%s OK", lt->numblocks, ((lt->numblocks != 1) ? "s" : "") );
01081 assert( rv < USER_MSG_LENGTH );
01082 print_output( user_msg, DEBUG, __FILE__, __LINE__ );
01083
01084 rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT: Start time = "LXT2_RD_LLD"", lt->start );
01085 assert( rv < USER_MSG_LENGTH );
01086 print_output( user_msg, DEBUG, __FILE__, __LINE__ );
01087
01088 rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT: End time = "LXT2_RD_LLD"", lt->end );
01089 assert( rv < USER_MSG_LENGTH );
01090 print_output( user_msg, DEBUG, __FILE__, __LINE__ );
01091 }
01092 #endif
01093
01094 lt->value_change_callback = lxt2_rd_null_callback;
01095
01096 } else {
01097
01098 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "No blocks exist in LXT dumpfile %s", name );
01099 assert( rv < USER_MSG_LENGTH );
01100 print_output( user_msg, FATAL, __FILE__, __LINE__ );
01101 lxt2_rd_close( lt );
01102 lt = NULL;
01103
01104 }
01105
01106 }
01107
01108 }
01109
01110 PROFILE_END;
01111
01112 return( lt );
01113
01114 }
|
|
||||||||||||||||
|
01607 { PROFILE(LXT2_RD_ITER_BLOCKS);
01608
01609 struct lxt2_rd_block* b;
01610 int blk = 0;
01611 int blkfinal = 0;
01612 int processed = 0;
01613 struct lxt2_rd_block* bcutoff = NULL;
01614 struct lxt2_rd_block* bfinal = NULL;
01615 int striped_kill = 0;
01616 unsigned int real_uncompressed_siz = 0;
01617 unsigned char gzid[2];
01618
01619 if( lt ) {
01620
01621 lt->value_change_callback = value_change_callback ? value_change_callback : lxt2_rd_null_callback;
01622 lt->user_callback_data_pointer = user_callback_data_pointer;
01623
01624 b = lt->block_head;
01625 blk = 0;
01626
01627 while( b ) {
01628
01629 if( !b->mem && !b->short_read_ignore && !b->exclude_block ) {
01630
01631 int rc;
01632
01633 if( processed < 5 ) {
01634 int gate = (processed == 4) && b->next;
01635 #ifdef DEBUG_MODE
01636 if( debug_mode ) {
01637 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT block [%d] processing "LXT2_RD_LLD" / "LXT2_RD_LLD"%s",
01638 blk, b->start, b->end, (gate ? " ..." : "") );
01639 assert( rv < USER_MSG_LENGTH );
01640 print_output( user_msg, DEBUG, __FILE__, __LINE__ );
01641 }
01642 #endif
01643 if( gate ) {
01644 bcutoff = b;
01645 }
01646 }
01647
01648 processed++;
01649
01650 fseeko( lt->handle, b->filepos, SEEK_SET );
01651 gzid[0] = gzid[1] = 0;
01652 (void)fread( &gzid, 2, 1, lt->handle );
01653 fseeko( lt->handle, b->filepos, SEEK_SET );
01654
01655 if( (striped_kill = (gzid[0] != 0x1f) || (gzid[1] != 0x8b)) ) {
01656
01657 lxtint32_t clen, unclen, iter = 0;
01658 unsigned char* pnt;
01659 off_t fspos = b->filepos;
01660 unsigned int rc;
01661 unsigned char* zbuff = NULL;
01662 unsigned int zlen = 0;
01663 struct z_stream_s strm;
01664
01665 real_uncompressed_siz = b->uncompressed_siz;
01666 pnt = b->mem = (unsigned char*)malloc_safe_nolimit( b->uncompressed_siz );
01667 b->uncompressed_siz = 0;
01668
01669 lxt2_rd_regenerate_process_mask( lt );
01670
01671 while( iter != 0xFFFFFFFF ) {
01672
01673 clen = unclen = iter = 0;
01674
01675 (void)fread( &clen, 4, 1, lt->handle );
01676 clen = lxt2_rd_get_32( &clen, 0 );
01677
01678 (void)fread( &unclen, 4, 1, lt->handle );
01679 unclen = lxt2_rd_get_32( &unclen, 0 );
01680
01681 (void)fread( &iter, 4, 1, lt->handle );
01682 iter = lxt2_rd_get_32( &iter, 0 );
01683
01684 fspos += 12;
01685
01686 if( (iter == 0xFFFFFFFF) || lt->process_mask_compressed[iter/LXT2_RD_PARTIAL_SIZE] ) {
01687
01688 if( clen > zlen ) {
01689 free_safe( zbuff, 0 ); /* TBD */
01690 zbuff = (unsigned char*)malloc_safe_nolimit( zlen = (clen * 2) );
01691 }
01692
01693 (void)fread( zbuff, clen, 1, lt->handle );
01694
01695 strm.avail_in = clen - 10;
01696 strm.avail_out = unclen;
01697 strm.total_in = strm.total_out = 0;
01698 strm.zalloc = NULL;
01699 strm.zfree = NULL;
01700 strm.opaque = NULL;
01701 strm.next_in = zbuff + 10;
01702 strm.next_out = pnt;
01703
01704 rc = inflateInit2( &strm, -MAX_WBITS );
01705
01706 while (Z_OK == (rc = inflate( &strm, Z_NO_FLUSH )) );
01707
01708 rc = inflateEnd( &strm );
01709
01710 if( strm.total_out != unclen ) {
01711 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT: Short read on subblock %lu vs %u (expected), ignoring...",
01712 strm.total_out, (unsigned int)unclen );
01713 assert( rv < USER_MSG_LENGTH );
01714 print_output( user_msg, WARNING, __FILE__, __LINE__ );
01715 free_safe( b->mem, 0 ); /* TBD */
01716 b->mem = NULL;
01717 b->short_read_ignore = 1;
01718 b->uncompressed_siz = real_uncompressed_siz;
01719 break;
01720 }
01721
01722 b->uncompressed_siz += strm.total_out;
01723 pnt += strm.total_out;
01724 fspos += clen;
01725
01726 } else {
01727
01728 fspos += clen;
01729 fseeko( lt->handle, fspos, SEEK_SET );
01730
01731 }
01732
01733 }
01734
01735 free_safe( zbuff, 0 ); /* TBD */
01736
01737 } else {
01738
01739 unsigned int rv;
01740 b->mem = malloc_safe_nolimit( b->uncompressed_siz );
01741 lt->zhandle = gzdopen( dup( fileno( lt->handle ) ), "rb" );
01742 rc = gzread( lt->zhandle, b->mem, b->uncompressed_siz );
01743 rv = gzclose( lt->zhandle );
01744 assert( rv == Z_OK );
01745 lt->zhandle = NULL;
01746
01747 if( rc != b->uncompressed_siz ) {
01748 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT: Short read on block %d vs %u (expected), ignoring...", rc, (unsigned int)b->uncompressed_siz );
01749 assert( rv < USER_MSG_LENGTH );
01750 print_output( user_msg, WARNING, __FILE__, __LINE__ );
01751 free_safe( b->mem, 0 ); /* TBD */
01752 b->mem = NULL;
01753 b->short_read_ignore = 1;
01754 } else {
01755 lt->block_mem_consumed += b->uncompressed_siz;
01756 }
01757
01758 }
01759
01760 bfinal = b;
01761 blkfinal = blk;
01762
01763 }
01764
01765 if( b->mem ) {
01766
01767 Try {
01768 (void)lxt2_rd_process_block( lt, b );
01769 } Catch_anonymous {
01770 free_safe( b->mem, 0 ); /* TBD */
01771 Throw 0;
01772 }
01773
01774 if( striped_kill ) {
01775 free_safe( b->mem, 0 ); /* TBD */
01776 b->mem = NULL;
01777 b->uncompressed_siz = real_uncompressed_siz;
01778 } else if( lt->numblocks > 1 ) { /* no sense freeing up the single block case */
01779 if( lt->block_mem_consumed > lt->block_mem_max ) {
01780 lt->block_mem_consumed -= b->uncompressed_siz;
01781 free_safe( b->mem, 0 ); /* TBD */
01782 b->mem = NULL;
01783 }
01784 }
01785
01786 }
01787
01788 blk++;
01789 b = b->next;
01790
01791 }
01792
01793 }
01794
01795 #ifdef DEBUG_MODE
01796 if( debug_mode ) {
01797 if( bcutoff && (bfinal != bcutoff) ) {
01798 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "LXT: Block [%d] processed "LXT2_RD_LLD" / "LXT2_RD_LLD"", blkfinal, bfinal->start, bfinal->end );
01799 assert( rv < USER_MSG_LENGTH );
01800 print_output( user_msg, DEBUG, __FILE__, __LINE__ );
01801 }
01802 }
01803 #endif
01804
01805 return( blk );
01806
01807 }
|
|
||||||||||||||||
|
01833 { PROFILE(LXT2_RD_LIMIT_TIME_RANGE);
01834
01835 lxtint64_t tmp_time;
01836 int blk = 0;
01837
01838 if( lt ) {
01839
01840 struct lxt2_rd_block* b = lt->block_head;
01841 struct lxt2_rd_block* bprev = NULL;
01842 int state = 0;
01843
01844 if( strt_time > end_time ) {
01845 tmp_time = strt_time;
01846 strt_time = end_time;
01847 end_time = tmp_time;
01848 }
01849
01850 while( b ) {
01851
01852 switch( state ) {
01853 case 0 :
01854 if( b->end >= strt_time ) {
01855 state = 1;
01856 if( (b->start > strt_time) && bprev ) {
01857 bprev->exclude_block = 0;
01858 blk++;
01859 }
01860 }
01861 break;
01862 case 1 :
01863 if( b->start > end_time ) {
01864 state = 2;
01865 }
01866 break;
01867 default: break;
01868 }
01869
01870 if( (state == 1) && !b->short_read_ignore ) {
01871 b->exclude_block = 0;
01872 blk++;
01873 } else {
01874 b->exclude_block = 1;
01875 }
01876
01877 bprev = b;
01878 b = b->next;
01879
01880 }
01881
01882 }
01883
01884 PROFILE_END;
01885
01886 return( blk );
01887
01888 }
|
|
||||||||||||
|
01457 {
01458
01459 int rc = 0;
01460
01461 if( lt ) {
01462
01463 lt->process_mask_dirty = 1;
01464
01465 if( facidx < lt->numfacs ) {
01466 int idx = facidx / 8;
01467 int bitpos = facidx & 7;
01468 /*@-shiftnegative@*/
01469 lt->process_mask[idx] |= (1 << bitpos);
01470 /*@=shiftnegative@*/
01471 }
01472
01473 rc = 1;
01474
01475 }
01476
01477 return( rc );
01478
01479 }
|
|
|
01506 {
01507
01508 int rc = 0;
01509
01510 if( lt ) {
01511 lt->process_mask_dirty = 1;
01512 memset( lt->process_mask, 0xff, ((lt->numfacs + 7) / 8) );
01513 rc = 1;
01514 }
01515
01516 return( rc );
01517
01518 }
|
|
||||||||||||
|
01537 {
01538
01539 lxtint64_t rc = lt->block_mem_max;
01540
01541 lt->block_mem_max = block_mem_max;
01542
01543 return( rc );
01544
01545 }
|
|
|
01897 { PROFILE(LXT2_RD_UNLIMIT_TIME_RANGE);
01898
01899 int blk = 0;
01900
01901 if( lt ) {
01902
01903 struct lxt2_rd_block *b = lt->block_head;
01904
01905 while( b ) {
01906 b->exclude_block = 0;
01907 if( !b->short_read_ignore ) {
01908 blk++;
01909 }
01910 b = b->next;
01911 }
01912
01913 }
01914
01915 PROFILE_END;
01916
01917 return( blk );
01918
01919 }
|
1.3.4