blob: bf5c2bbfc40ea26cd9751e6709f0db4d31e17b16 (
plain)
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
|
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <proxy.h>
void XS_pack_charPtrPtr( SV * arg, char ** array, int count) {
int i;
AV * avref;
avref = (AV*)sv_2mortal((SV*)newAV());
for (i=0; i<count; i++) {
av_push(avref, newSVpv(array[i], strlen(array[i])));
}
SvSetSV( arg, newRV((SV*)avref));
}
/* http://www.perlmonks.org/?node_id=680842 */
static char **
XS_unpack_charPtrPtr (SV *arg) {
char **ret;
AV *av;
I32 i;
if (!arg || !SvOK (arg) || !SvROK (arg) || SvTYPE (SvRV (arg)) != SVt_PVAV)
croak ("array reference expected");
av = (AV *)SvRV (arg);
ret = malloc ((av_len (av) + 1 + 1) * sizeof (char *));
if (!ret)
croak ("malloc failed");
for (i = 0; i <= av_len (av); i++) {
SV **elem = av_fetch (av, i, 0);
if (!elem || !*elem) {
free (ret);
croak ("missing element in list");
}
ret[i] = SvPV_nolen (*elem);
}
ret[i] = NULL;
return ret;
}
MODULE = Net::Libproxy PACKAGE = Net::Libproxy
PROTOTYPES: DISABLE
pxProxyFactory *
proxy_factory_new()
PREINIT:
pxProxyFactory *pf;
CODE:
pf = px_proxy_factory_new();
RETVAL = pf;
OUTPUT:
RETVAL
char **
proxy_factory_get_proxies(pf, url)
pxProxyFactory * pf
char * url
PREINIT:
char ** array;
int count_charPtrPtr;
int i;
CODE:
array = px_proxy_factory_get_proxies(pf, url);
RETVAL = array;
i = 0;
while( array[i] != NULL ) {
i++;
}
count_charPtrPtr = i;
OUTPUT:
RETVAL
void
proxy_factory_free_proxies(proxies)
char ** proxies
CODE:
px_proxy_factory_free_proxies(proxies);
MODULE = Net::Libproxy PACKAGE = Net::Libproxy::ProxyFactoryPtr
void
DESTROY(pf)
pxProxyFactory * pf
CODE:
printf("Net::Libproxy::DESTROY\n");
px_proxy_factory_free(pf);
|