-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathopk.h
76 lines (65 loc) · 1.99 KB
/
opk.h
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
#ifndef OPK_H
#define OPK_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
# ifdef opk_EXPORTS
# define __api __declspec(dllexport)
# elif !defined(libopk_STATIC)
# define __api __declspec(dllimport)
# else
# define __api
# endif
#elif __GNUC__ >= 4
# define __api __attribute__((visibility ("default")))
#else
# define __api
#endif
#include <stdlib.h>
struct OPK;
__api struct OPK *opk_open(const char *opk_filename);
__api void opk_close(struct OPK *opk);
/* Open the next meta-data file.
* if 'filename' is set, the pointer passed as argument will
* be set to point to a string corresponding to the filename.
* XXX: the pointer will be invalid as soon as opk_close() is called.
*
* Returns:
* -EIO if the file cannot be read,
* -ENOMEM if the buffer cannot be allocated,
* 0 if no more meta-data file can be found,
* 1 otherwise.
*/
__api int opk_open_metadata(struct OPK *opk, const char **filename);
/* Read a key/value pair.
* 'key_chars' and 'val_chars' must be valid pointers. The pointers passed
* as arguments will point to the key and value read. 'key_size' and
* 'val_size' are set to the length of their respective char arrays.
* XXX: the pointers will be invalid as soon as opk_close() is called.
*
* Returns:
* -EIO if the file cannot be read,
* 0 if no more key/value pairs can be found,
* 1 otherwise.
*/
__api int opk_read_pair(struct OPK *opk,
const char **key_chars, size_t *key_size,
const char **val_chars, size_t *val_size);
/* Extract the file with the given filename from the OPK archive.
* The 'data' pointer is set to an allocated buffer containing
* the file's content. The 'size' variable is set to the length
* of the buffer, in bytes.
*
* Returns:
* -ENOENT if the file to extract is not found,
* -ENOMEM if the buffer cannot be allocated,
* -EIO if the file cannot be read,
* 0 otherwise.
*/
__api int opk_extract_file(struct OPK *opk, const char *name,
void **data, size_t *size);
#ifdef __cplusplus
}
#endif
#endif /* OPK_H */