-
Notifications
You must be signed in to change notification settings - Fork 1
/
Raw.xs
85 lines (63 loc) · 1.74 KB
/
Raw.xs
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
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include <archive.h>
#include <archive_entry.h>
#include "constants.h"
#ifndef la_int64_t
#define la_int64_t __LA_INT64_T
#endif
typedef struct
{
struct archive *ar;
int reading;
} archive_raw_reader;
typedef struct
{
struct archive *ar;
} archive_raw_diskwriter;
typedef struct
{
struct archive_entry *e;
archive_raw_reader *reader;
} archive_raw_entry;
typedef struct
{
struct archive *m;
} archive_raw_match;
typedef archive_raw_diskwriter *DiskWriter;
typedef archive_raw_entry *Entry;
typedef archive_raw_match *Match;
typedef archive_raw_reader *Reader;
#ifndef MUTABLE_GV
#define MUTABLE_GV(p) ((GV *)MUTABLE_PTR(p))
#endif
#define ARCHIVE_NEW_OBJ(rv, package, sv) \
STMT_START { \
(rv) = sv_setref_pv (newSV(0), package, sv); \
} STMT_END
STATIC void *archive_sv_to_ptr (const char *type, SV *sv, const char *file, int line)
{
SV *full_type = sv_2mortal (newSVpvf ("Archive::Raw::%s", type));
if (!(sv_isobject (sv) && sv_derived_from (sv, SvPV_nolen (full_type))))
croak("Argument is not of type %s @ (%s:%d)\n",
SvPV_nolen (full_type), file, line);
return INT2PTR (void *, SvIV ((SV *) SvRV (sv)));
}
#define ARCHIVE_SV_TO_PTR(type, sv) \
archive_sv_to_ptr(#type, sv, __FILE__, __LINE__)
#define archive_check_error(e, ar, method) \
if (e < ARCHIVE_OK) \
croak ("%s error: %s (%d)", #method, archive_error_string (ar), e);
MODULE = Archive::Raw PACKAGE = Archive::Raw
int
libarchive_version()
CODE:
RETVAL = archive_version_number();
OUTPUT: RETVAL
INCLUDE: const-xs-constants.inc
INCLUDE: xs/DiskWriter.xs
INCLUDE: xs/Entry.xs
INCLUDE: xs/Match.xs
INCLUDE: xs/Reader.xs