summaryrefslogtreecommitdiff
path: root/lib/ZMQ/FFI/ZMQ4/Raw.pm
blob: f287b12c94253110ae2a107d0a651a66d84279ec (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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
package ZMQ::FFI::ZMQ4::Raw;
$ZMQ::FFI::ZMQ4::Raw::VERSION = '1.18';
use FFI::Platypus;

sub load {
    my ($soname) = @_;

    my $ffi    = FFI::Platypus->new( lib => $soname // 'libzmq.so' );
    my $target = caller;

    $ffi->attach(
        # void *zmq_ctx_new()
        ['zmq_ctx_new' => "${target}::zmq_ctx_new"]
			 => [] => 'pointer'
    );

    $ffi->attach(
        # int zmq_ctx_get(void *context, int option_name)
        ['zmq_ctx_get' => "${target}::zmq_ctx_get"]
			 => ['pointer', 'int'] => 'int'
    );

    $ffi->attach(
        # int zmq_ctx_set(void *context, int option_name, int option_value)
        ['zmq_ctx_set' => "${target}::zmq_ctx_set"]
			 => ['pointer', 'int', 'int'] => 'int'
    );

    $ffi->attach(
        # void *zmq_socket(void *context, int type)
        ['zmq_socket' => "${target}::zmq_socket"]
			 => ['pointer', 'int'] => 'pointer'
    );

    $ffi->attach(
        # int zmq_proxy(const void *front, const void *back, const void *cap)
        ['zmq_proxy' => "${target}::zmq_proxy"]
			 => ['pointer', 'pointer', 'pointer'] => 'int'
    );

    $ffi->attach(
        # int zmq_ctx_term (void *context)
        ['zmq_ctx_term' => "${target}::zmq_ctx_term"]
			 => ['pointer'] => 'int'
    );

    $ffi->attach(
        # int zmq_send(void *socket, void *buf, size_t len, int flags)
        ['zmq_send' => "${target}::zmq_send"]
            => ['pointer', 'string', 'size_t', 'int'] => 'int'
    );

    $ffi->attach(
        # int zmq_msg_recv(zmq_msg_t *msg, void *socket, int flags)
        ['zmq_msg_recv' => "${target}::zmq_msg_recv"]
            => ['pointer', 'pointer', 'int'] => 'int'
    );

    $ffi->attach(
        # int zmq_unbind(void *socket, const char *endpoint)
        ['zmq_unbind' => "${target}::zmq_unbind"]
            => ['pointer', 'string'] => 'int'
    );

    $ffi->attach(
        # int zmq_disconnect(void *socket, const char *endpoint)
        ['zmq_disconnect' => "${target}::zmq_disconnect"]
            => ['pointer', 'string'] => 'int'
    );

    $ffi->attach(
        # int zmq_connect(void *socket, const char *endpoint)
        ['zmq_connect' => "${target}::zmq_connect"]
            => ['pointer', 'string'] => 'int'
    );

    $ffi->attach(
        # int zmq_bind(void *socket, const char *endpoint)
        ['zmq_bind' => "${target}::zmq_bind"]
            => ['pointer', 'string'] => 'int'
    );

    $ffi->attach(
        # int zmq_msg_init(zmq_msg_t *msg)
        ['zmq_msg_init' => "${target}::zmq_msg_init"]
            => ['pointer'] => 'int'
    );

    $ffi->attach(
        # int zmq_msg_init_size(zmq_msg_t *msg, size_t size)
        ['zmq_msg_init_size' => "${target}::zmq_msg_init_size"]
            => ['pointer', 'int'] => 'int'
    );

    $ffi->attach(
        # size_t zmq_msg_size(zmq_msg_t *msg)
        ['zmq_msg_size' => "${target}::zmq_msg_size"]
            => ['pointer'] => 'int'
    );

    $ffi->attach(
        # void *zmq_msg_data(zmq_msg_t *msg)
        ['zmq_msg_data' => "${target}::zmq_msg_data"]
            => ['pointer'] => 'pointer'
    );

    $ffi->attach(
        # int zmq_msg_close(zmq_msg_t *msg)
        ['zmq_msg_close' => "${target}::zmq_msg_close"]
            => ['pointer'] => 'int'
    );

    $ffi->attach(
        # int zmq_close(void *socket)
        ['zmq_close' => "${target}::zmq_close"]
            => ['pointer'] => 'int'
    );

    $ffi->attach(
        # const char *zmq_strerror(int errnum)
        ['zmq_strerror' => "${target}::zmq_strerror"]
            => ['int'] => 'string'
    );

    $ffi->attach(
        # int zmq_errno(void)
        ['zmq_errno' => "${target}::zmq_errno"]
            => [] => 'int'
    );

    $ffi->attach(
        # int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key);
        ['zmq_curve_keypair' => "${target}::zmq_curve_keypair"]
            => ['opaque', 'opaque'] => 'int'
    );
    
    $ffi->attach(
        # char *zmq_z85_encode (char *dest, const uint8_t *data, size_t size);
        ['zmq_z85_encode' => "${target}::zmq_z85_encode"]
            => ['opaque', 'string', 'size_t'] => 'pointer'
    );
    
    $ffi->attach(
        # uint8_t *zmq_z85_decode (uint8_t *dest, const char *string);
        ['zmq_z85_decode' => "${target}::zmq_z85_decode"]
            => ['opaque', 'string'] => 'pointer'
    );

    $ffi->attach(
        # int zmq_socket_monitor (void *socket, char *endpoint, int events);
        ['zmq_socket_monitor' => "${target}::zmq_socket_monitor"]
            => ['pointer', 'string', 'int'] => 'int'
    );
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

ZMQ::FFI::ZMQ4::Raw

=head1 VERSION

version 1.18

=head1 AUTHOR

Dylan Cali <calid1984@gmail.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Dylan Cali.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut