pak

pak.git
git clone git://git.lenczewski.org/pak.git
Log | Files | Refs | README | LICENSE

pak.h (1618B)


      1 #ifndef PAK_H
      2 #define PAK_H
      3 
      4 #include "alloc.h"
      5 #include "list.h"
      6 #include "pakfmt.h"
      7 
      8 static inline size_t
      9 pak_file_size(struct pak const *pak)
     10 {
     11 	size_t index_end = pak->header.index_file_offset + pak->header.index_compressed_length;
     12 	size_t data_end = pak->header.data_file_offset + pak->header.data_compressed_length;
     13 	return (index_end < data_end) ? data_end : index_end;
     14 }
     15 
     16 extern int
     17 pak_read_header(int fd, struct pakfmt_header *out);
     18 
     19 extern int
     20 pak_read_index(int fd, struct arena *arena, struct pakfmt_header const *hdr,
     21 	       uint8_t *buf, size_t len, struct list_node *index);
     22 
     23 extern int
     24 pak_read_archive(int fd, struct arena *arena, struct pakfmt_header const *hdr,
     25 		 char name[PAK_ARCHIVE_NAME_LEN], uint32_t type,
     26 		 struct pak_archive **out);
     27 
     28 extern int
     29 pak_read_archive_data(int fd, struct pakfmt_header const *hdr,
     30 		      struct pakfmt_archive const *archive,
     31 		      uint8_t *buf, size_t len);
     32 
     33 extern int
     34 pak_write(int fd, struct pak const *pak);
     35 
     36 extern int
     37 pak_write_mem(uint8_t *buf, size_t len, struct pak const *pak);
     38 
     39 extern int
     40 pak_read_mem(uint8_t *buf, size_t len, struct arena *arena, struct pak *pak);
     41 
     42 extern void
     43 pak_open(struct pak *pak);
     44 
     45 extern struct pak_archive *
     46 pak_add_archive(struct pak *pak, struct arena *arena,
     47 		char name[static PAK_ARCHIVE_NAME_LEN], uint32_t type,
     48 		enum pak_compression_type compression,
     49 		struct pak_tag *tags, size_t tags_count,
     50 		void *data, size_t compressed_length, size_t uncompressed_length,
     51 		uint32_t uncompressed_crc32c);
     52 
     53 extern void
     54 pak_close(struct pak *pak);
     55 
     56 extern void
     57 pak_debug_dump(struct pak const *pak);
     58 
     59 #endif /* PAK_H */