summaryrefslogtreecommitdiffstats
path: root/lzip_index.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-30 08:53:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-30 08:53:49 +0000
commit965a62ddfc3ba4816b5a6af896546b80a037c41b (patch)
treec90836e226b5bc10164689c463c94ec7f54608c7 /lzip_index.h
parentReleasing debian version 1.14-2. (diff)
downloadclzip-965a62ddfc3ba4816b5a6af896546b80a037c41b.tar.xz
clzip-965a62ddfc3ba4816b5a6af896546b80a037c41b.zip
Merging upstream version 1.15~rc1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lzip_index.h')
-rw-r--r--lzip_index.h64
1 files changed, 36 insertions, 28 deletions
diff --git a/lzip_index.h b/lzip_index.h
index e273eaf..480356f 100644
--- a/lzip_index.h
+++ b/lzip_index.h
@@ -20,72 +20,80 @@
#endif
-struct Block
+typedef struct Block
{
long long pos, size; /* pos >= 0, size >= 0, pos + size <= INT64_MAX */
- };
+ } Block;
-static inline void init_block( struct Block * const b,
+static inline void init_block( Block * const b,
const long long p, const long long s )
{ b->pos = p; b->size = s; }
-static inline long long block_end( const struct Block b )
- { return b.pos + b.size; }
+static inline long long block_end( const Block b ) { return b.pos + b.size; }
-struct Member
+typedef struct Member
{
- struct Block dblock, mblock; /* data block, member block */
+ Block dblock, mblock; /* data block, member block */
unsigned dictionary_size;
- };
+ } Member;
-static inline void init_member( struct Member * const m,
- const long long dpos, const long long dsize,
- const long long mpos, const long long msize,
- const unsigned dict_size )
- { init_block( &m->dblock, dpos, dsize ); init_block( &m->mblock, mpos, msize );
- m->dictionary_size = dict_size; }
+static inline void init_member( Member * const m, const long long dpos,
+ const long long dsize, const long long mpos,
+ const long long msize, const unsigned dict_size )
+ { init_block( &m->dblock, dpos, dsize );
+ init_block( &m->mblock, mpos, msize ); m->dictionary_size = dict_size; }
-struct Lzip_index
+typedef struct Lzip_index
{
- struct Member * member_vector;
+ Member * member_vector;
char * error;
long long insize;
long members;
int error_size;
int retval;
unsigned dictionary_size; /* largest dictionary size in the file */
- };
+ } Lzip_index;
-bool Li_init( struct Lzip_index * const li, const int infd,
- const struct Cl_options * const cl_opts );
+bool Li_init( Lzip_index * const li, const int infd,
+ const Cl_options * const cl_opts );
-void Li_free( struct Lzip_index * const li );
+void Li_free( Lzip_index * const li );
-static inline long long Li_udata_size( const struct Lzip_index * const li )
+/* multimember file with empty member(s) */
+static inline bool Li_multi_empty( Lzip_index * const li )
+ {
+ long i;
+ if( li->members > 1 )
+ for( i = 0; i < li->members; ++i )
+ if( li->member_vector[i].dblock.size == 0 ) return true;
+ return false;
+ }
+
+static inline long long Li_udata_size( const Lzip_index * const li )
{
if( li->members <= 0 ) return 0;
return block_end( li->member_vector[li->members-1].dblock );
}
-static inline long long Li_cdata_size( const struct Lzip_index * const li )
+static inline long long Li_cdata_size( const Lzip_index * const li )
{
if( li->members <= 0 ) return 0;
return block_end( li->member_vector[li->members-1].mblock );
}
/* total size including trailing data (if any) */
-static inline long long Li_file_size( const struct Lzip_index * const li )
+static inline long long Li_file_size( const Lzip_index * const li )
{ if( li->insize >= 0 ) return li->insize; else return 0; }
-static inline const struct Block * Li_dblock( const struct Lzip_index * const li,
- const long i )
+static inline const Block * Li_dblock( const Lzip_index * const li,
+ const long i )
{ return &li->member_vector[i].dblock; }
-static inline const struct Block * Li_mblock( const struct Lzip_index * const li,
- const long i )
+static inline const Block * Li_mblock( const Lzip_index * const li,
+ const long i )
{ return &li->member_vector[i].mblock; }
-static inline unsigned Li_dictionary_size( const struct Lzip_index * const li,
+static inline unsigned Li_dictionary_size( const Lzip_index * const li,
const long i )
{ return li->member_vector[i].dictionary_size; }