3 extern int32_t xar_arcmod_extract(xar_t x
, xar_file_t f
, const char *file
, char *buffer
, size_t len
);
5 /* xar_extract_tobuffer
6 * x: archive to extract from
7 * buffer: buffer to extract to
8 * size: On return, this will contain the size of the memory pointed to by buffer
9 * Returns 0 on success, -1 on failure.
10 * Summary: This is the entry point for extraction to a buffer.
11 * On success, a buffer is allocated with the contents of the file
12 * specified. The caller is responsible for freeing the returend buffer.
13 * Example: xar_extract_tobuffer(x, "foo/bar/blah",&buffer)
15 int32_t xar_extract_tobuffersz(xar_t x
, xar_file_t f
, char **buffer
, size_t *size
) {
16 const char *sizestring
= NULL
;
19 if(0 != xar_prop_get(f
,"data/size",&sizestring
)){
20 if(0 != xar_prop_get(f
, "type", &sizestring
))
22 if(strcmp(sizestring
, "file") == 0) {
29 *size
= strtoull(sizestring
, (char **)NULL
, 10);
30 *buffer
= malloc(*size
);
36 ret
= xar_arcmod_extract(x
,f
,NULL
,*buffer
,*size
);