-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibex_archive.h
More file actions
executable file
·148 lines (113 loc) · 8.2 KB
/
libex_archive.h
File metadata and controls
executable file
·148 lines (113 loc) · 8.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* -------------------------------------------------------------------------- */
/* (c) ali@balarabe.com [libex_archive.h] */
/* -------------------------------------------------------------------------- */
#if !defined INCLUDED_LIBEX_ARCHIVE_H
#define INCLUDED_LIBEX_ARCHIVE_H
#if !defined LX_USE_ZLIB_COMPRESSION
#define LX_USE_ZLIB_COMPRESSION 1 /* Enable compression with the ZLib lib. */
#endif
#include "libex_array.h"
#include "libex_string_class.h"
/* -------------------------------------------------------------------------- */
LX_NAMESPACE(lx_c)
typedef struct lx_archive_t {
uint8_t* ob; /* lx_archive_t */
}
lx_archive_t, lx_new_archive_t;
typedef struct lx_archive_item_t {
lx_new_chars_t item_name; /* lx_archive_item_t */
uint32_t item_size; /* lx_archive_item_t */
uint8_t* item_data; /* lx_archive_item_t */
}
lx_archive_item_t;
static lx_archive_t lx_null_archive = { NULL };
static lx_archive_item_t lx_null_archive_item = { NULL, 0, NULL };
/* -------------------------------------------------------------------------- */
/* Constructors: */
/* Default Constructor */
LX_PUBLIC lx_new_archive_t lx_Archive_init( void ); /*C*/
/* Constructor: Constructs an archive from a pointer to */
/* an encrypted archive image, and an ANSI character key. */
LX_PUBLIC lx_new_archive_t lx_Archive_initBytes( /*C*/
uint8_t* storage_bytes_, /*-*/
const char* encryption_key_ ); /*-*/
/* Copy Constructor */
LX_PUBLIC lx_new_archive_t lx_Archive_initCopy( /*C*/
const lx_archive_t copy_from_ ); /*-*/
/* -------------------------------------------------------------------------- */
/* Destructor: */
LX_PUBLIC void lx_Archive_free( lx_archive_t* object_ ); /*D*/
/* -------------------------------------------------------------------------- */
/* Methods: Const */
/* returns true if two archives contain the same items. */
LX_PUBLIC lx_bool lx_Archive_equal( /*M*/
const lx_archive_t object_, /*-*/
const lx_archive_t compare_ ); /*-*/
LX_PUBLIC lx_archive_item_t lx_Archive_getItem( /*M*/
const lx_archive_t object_, /*-*/
lx_chars_t item_name_ ); /*-*/
/* Generates and returns a pointer to an encrypted archive image */
LX_PUBLIC const uint8_t* lx_Archive_getStorageBytes( /*M*/
const lx_archive_t object_, /*-*/
const uint32_t key_size_, /*-*/
const uint8_t* encryption_key_ ); /*-*/
/* returns the size of the image in bytes. */
/* Only call it after getting an image pointer with getStorageBytes() */
LX_PUBLIC uint32_t lx_Archive_getStorageSize( /*M*/
const lx_archive_t object_ ); /*-*/
/* returns the named item as a text string. */
LX_PUBLIC lx_new_str_t lx_Archive_getText( /*M*/
const lx_archive_t object_, /*-*/
lx_chars_t item_name_ ); /*-*/
/* returns true if the named item exists in the archive. */
LX_PUBLIC lx_bool lx_Archive_itemExists( /*M*/
const lx_archive_t object_, /*-*/
lx_chars_t item_name_ ); /*-*/
LX_PUBLIC lx_chars_t lx_Archive_report( const lx_archive_t object_ ); /*M*/
/* -------------------------------------------------------------------------- */
/* Methods: Manipulative */
LX_PUBLIC lx_bool lx_Archive_addFolder( /*M*/
lx_archive_t* object_, /*-*/
lx_chars_t path_, /*-*/
lx_chars_t pattern_, /*-*/
lx_chars_t relative_path_ ); /*-*/
LX_PUBLIC const lx_archive_item_t* lx_Archive_addItem( /*M*/
lx_archive_t* object_, /*-*/
lx_chars_t item_name_, /*-*/
const uint32_t item_size_, /*-*/
const uint8_t* item_data_ ); /*-*/
/* Clears the contents of the archive, releasing all allocated memory. */
LX_PUBLIC void lx_Archive_clear( lx_archive_t* object_ ); /*M*/
LX_PUBLIC lx_bool lx_Archive_deleteItem( /*M*/
lx_archive_t* object_, /*-*/
lx_chars_t item_name_ ); /*-*/
LX_PUBLIC lx_bool lx_Archive_loadFromBytes( /*M*/
lx_archive_t* object_, /*-*/
const uint8_t* bytes_, /*-*/
const uint32_t key_size_, /*-*/
const uint8_t* encryption_key_ ); /*-*/
LX_PUBLIC lx_bool lx_Archive_loadFromBytesCharKey( /*M*/
lx_archive_t* object_, /*-*/
const uint8_t* bytes_, /*-*/
const char* encryption_key_ ); /*-*/
LX_PUBLIC lx_bool lx_Archive_loadFromFile( /*M*/
lx_archive_t* object_, /*-*/
lx_chars_t filename_, /*-*/
const uint32_t key_size_, /*-*/
const uint8_t* encryption_key_ ); /*-*/
LX_PUBLIC lx_bool lx_Archive_loadFromFileCharKey( /*M*/
lx_archive_t* object_, /*-*/
lx_chars_t filename_, /*-*/
const char* encryption_key_ ); /*-*/
LX_PUBLIC void lx_Archive_packMemory( lx_archive_t* object_ ); /*M*/
LX_PUBLIC void lx_Archive_removeItems( lx_archive_t* object_ ); /*M*/
LX_PUBLIC lx_bool lx_Archive_saveToFile( /*M*/
const lx_archive_t object_, /*-*/
lx_chars_t filename_, /*-*/
const uint32_t key_size_, /*-*/
const uint8_t* encryption_key_ ); /*-*/
LX_PUBLIC void lx_Archive_setCopy( /*M*/
lx_archive_t* object_, /*-*/
const lx_archive_t copy_from_ ); /*-*/
LX_END_NAMESPACE /*lx_c*/
#endif /*eof*/