ffi-bindings-libfixposix 0.5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/README.md +26 -0
- data/Rakefile +5 -0
- data/lib/libfixposix/ffi.rb +532 -0
- data/lib/libfixposix/version.rb +3 -0
- data/lib/libfixposix.rb +39 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1d8ea6cc207e6b0d01212e65a6c47f87ab9329339077fd85bbfbf4f632071e6d
|
4
|
+
data.tar.gz: 1cee631055711a31ba67fb8ce39eb85b009cf8ae8608ab3cd88760a5fb7d3dde
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e1b9013a6ebf3437837b3cc3a785784ba72c16078df72d7cdc467f165b7b8f29cab084a6456855d0332f7a499ed662f2cf8e036dd6df23d91e6fde870146aaf2
|
7
|
+
data.tar.gz: ec61ab8a845d05fc7bbdc747f1586755829525a765bcd4b7f09e1424354cb095d50bd8ffd3ffb8f1101a5d30e63da5fe827cd44d214ea2e0085f25e3204d3ae3
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# ffi-bindings-libfixposix
|
2
|
+
|
3
|
+
Straightforward ffi bindings for libfixposix. Doesn't include a binary. See ffi-binary-libfixposix for that.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
$ bundle add ffi-bindings-libfixposix
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
+
|
13
|
+
$ gem install ffi-bindings-libfixposix
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```rb
|
18
|
+
require 'libfixposix'
|
19
|
+
```
|
20
|
+
Note that binaries are picked up automatically, they don't need to be manually required. See parent SubSpawn for more information.
|
21
|
+
|
22
|
+
`lfp_foo(...)` is mapped to `LFP.foo(...)` and simple class wrappers are generated too. See ffi.rb (generated) for all methods mapped from C. Use `LFP::INTERFACE_VERSION`, `LFP::SO_VERSION`, and/or `LFP::COMPLETE_VERSION` as appropriate.
|
23
|
+
|
24
|
+
## Development
|
25
|
+
|
26
|
+
See parent SubSpawn readme
|
data/Rakefile
ADDED
@@ -0,0 +1,532 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
module LFP
|
4
|
+
extend FFI::Library
|
5
|
+
ffi_lib LFPFile.local_so
|
6
|
+
INTERFACE_VERSION = "0.5.1"
|
7
|
+
|
8
|
+
# enums
|
9
|
+
enum :memsize_measure_unit, [:octets, 0, :kb, :kib, :mb, :mib, :gb, :gib, :tb, :tib, :pb, :pib, :eb, :eib]
|
10
|
+
enum :flags, [:setsigmask, 1, :setsigdefault, 2, :setpgroup, 4, :resetids, 8, :setcwd, 64, :setsid, 128, :setctty, 256, :usevfork, 512, :setumask, 1024, :setrlimit, 2048]
|
11
|
+
|
12
|
+
# callbacks
|
13
|
+
# typedef void (*lfp_sighandler_t)(int);
|
14
|
+
callback :sighandler, [:int32], :void
|
15
|
+
|
16
|
+
def self.const_missing( sym )
|
17
|
+
value = enum_value( sym )
|
18
|
+
return super unless value
|
19
|
+
value
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
# structs and classes
|
24
|
+
class Rlimit < FFI::Struct
|
25
|
+
|
26
|
+
# main data
|
27
|
+
layout :resource, :int32, # int resource;
|
28
|
+
:rlim_cur, :rlim_t, # struct rlimit rlim; - The current (soft) limit
|
29
|
+
:rlim_max, :rlim_t # struct rlimit rlim; - The hard limit
|
30
|
+
|
31
|
+
def self.const_missing( sym )
|
32
|
+
value = enum_value( sym )
|
33
|
+
return super unless value
|
34
|
+
value
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
class Buildinfo < FFI::Struct
|
40
|
+
|
41
|
+
# main data
|
42
|
+
layout :release, :uint64, # unsigned long int release;
|
43
|
+
:vcsid, [:uint8, 33] # char vcsid[32 + 1];
|
44
|
+
|
45
|
+
def self.const_missing( sym )
|
46
|
+
value = enum_value( sym )
|
47
|
+
return super unless value
|
48
|
+
value
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
class SpawnFileActions
|
54
|
+
SIZEOF = 32
|
55
|
+
def initialize
|
56
|
+
if block_given?
|
57
|
+
ret = nil # ffi doesn't return the result, must save it manually
|
58
|
+
FFI::MemoryPointer.new(:uint8, SIZEOF) do |ptr|
|
59
|
+
@this = ptr
|
60
|
+
ret = yield self
|
61
|
+
end
|
62
|
+
ret
|
63
|
+
else
|
64
|
+
@this = FFI::MemoryPointer.new(:uint8, SIZEOF)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
attr_reader :this
|
68
|
+
alias :to_ptr :this #ffi casting
|
69
|
+
|
70
|
+
# forwarding proxies
|
71
|
+
|
72
|
+
# int (lfp_spawn_file_actions_t *file_actions, int fd)
|
73
|
+
def addclose(*args); LFP.spawn_file_actions_addclose(@this, *args); end
|
74
|
+
|
75
|
+
# int (lfp_spawn_file_actions_t *file_actions, int fd, int newfd)
|
76
|
+
def adddup2(*args); LFP.spawn_file_actions_adddup2(@this, *args); end
|
77
|
+
|
78
|
+
# int (lfp_spawn_file_actions_t *file_actions, int fd)
|
79
|
+
def addkeep(*args); LFP.spawn_file_actions_addkeep(@this, *args); end
|
80
|
+
|
81
|
+
# int (lfp_spawn_file_actions_t *file_actions, int fd, const char *path, unsigned long int oflags, mode_t mode)
|
82
|
+
def addopen(*args); LFP.spawn_file_actions_addopen(@this, *args); end
|
83
|
+
|
84
|
+
# int (lfp_spawn_file_actions_t *file_actions)
|
85
|
+
def destroy(*args); LFP.spawn_file_actions_destroy(@this, *args); end
|
86
|
+
|
87
|
+
# int (lfp_spawn_file_actions_t *file_actions)
|
88
|
+
def init(*args); LFP.spawn_file_actions_init(@this, *args); end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
class Spawnattr
|
93
|
+
SIZEOF = 320
|
94
|
+
def initialize
|
95
|
+
if block_given?
|
96
|
+
ret = nil # ffi doesn't return the result, must save it manually
|
97
|
+
FFI::MemoryPointer.new(:uint8, SIZEOF) do |ptr|
|
98
|
+
@this = ptr
|
99
|
+
ret = yield self
|
100
|
+
end
|
101
|
+
ret
|
102
|
+
else
|
103
|
+
@this = FFI::MemoryPointer.new(:uint8, SIZEOF)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
attr_reader :this
|
107
|
+
alias :to_ptr :this #ffi casting
|
108
|
+
|
109
|
+
# forwarding proxies
|
110
|
+
|
111
|
+
# int (lfp_spawnattr_t *attr)
|
112
|
+
def destroy(*args); LFP.spawnattr_destroy(@this, *args); end
|
113
|
+
|
114
|
+
# int (lfp_spawnattr_t *attr, char **path)
|
115
|
+
def getctty(*args); LFP.spawnattr_getctty(@this, *args); end
|
116
|
+
def ctty(); LFP.spawnattr_getctty(@this); end
|
117
|
+
|
118
|
+
# int (lfp_spawnattr_t *attr, char **path)
|
119
|
+
def getcwd(*args); LFP.spawnattr_getcwd(@this, *args); end
|
120
|
+
def cwd(); LFP.spawnattr_getcwd(@this); end
|
121
|
+
|
122
|
+
# int (lfp_spawnattr_t *attr, unsigned int *flags)
|
123
|
+
def getflags(*args); LFP.spawnattr_getflags(@this, *args); end
|
124
|
+
def flags(); LFP.spawnattr_getflags(@this); end
|
125
|
+
|
126
|
+
# int (lfp_spawnattr_t *attr, pid_t *pgroup)
|
127
|
+
def getpgroup(*args); LFP.spawnattr_getpgroup(@this, *args); end
|
128
|
+
def pgroup(); LFP.spawnattr_getpgroup(@this); end
|
129
|
+
|
130
|
+
# int (lfp_spawnattr_t *attr, lfp_rlimit_t **rlim, size_t *rlim_size)
|
131
|
+
def getrlimit(*args); LFP.spawnattr_getrlimit(@this, *args); end
|
132
|
+
def rlimit(); LFP.spawnattr_getrlimit(@this); end
|
133
|
+
|
134
|
+
# int (lfp_spawnattr_t *attr, struct sigset_t *sigdefault)
|
135
|
+
def getsigdefault(*args); LFP.spawnattr_getsigdefault(@this, *args); end
|
136
|
+
def sigdefault(); LFP.spawnattr_getsigdefault(@this); end
|
137
|
+
|
138
|
+
# int (lfp_spawnattr_t *attr, struct sigset_t *sigmask)
|
139
|
+
def getsigmask(*args); LFP.spawnattr_getsigmask(@this, *args); end
|
140
|
+
def sigmask(); LFP.spawnattr_getsigmask(@this); end
|
141
|
+
|
142
|
+
# int (lfp_spawnattr_t *attr, mode_t *umask)
|
143
|
+
def getumask(*args); LFP.spawnattr_getumask(@this, *args); end
|
144
|
+
def umask(); LFP.spawnattr_getumask(@this); end
|
145
|
+
|
146
|
+
# int (lfp_spawnattr_t *attr)
|
147
|
+
def init(*args); LFP.spawnattr_init(@this, *args); end
|
148
|
+
|
149
|
+
# int (lfp_spawnattr_t *attr, const char *path)
|
150
|
+
def setctty(*args); LFP.spawnattr_setctty(@this, *args); end
|
151
|
+
def ctty=(value); LFP.spawnattr_setctty(@this, value); end
|
152
|
+
|
153
|
+
# int (lfp_spawnattr_t *attr, const char *path)
|
154
|
+
def setcwd(*args); LFP.spawnattr_setcwd(@this, *args); end
|
155
|
+
def cwd=(value); LFP.spawnattr_setcwd(@this, value); end
|
156
|
+
|
157
|
+
# int (lfp_spawnattr_t *attr, const unsigned int flags)
|
158
|
+
def setflags(*args); LFP.spawnattr_setflags(@this, *args); end
|
159
|
+
def flags=(value); LFP.spawnattr_setflags(@this, value); end
|
160
|
+
|
161
|
+
# int (lfp_spawnattr_t *attr, const pid_t pgroup)
|
162
|
+
def setpgroup(*args); LFP.spawnattr_setpgroup(@this, *args); end
|
163
|
+
def pgroup=(value); LFP.spawnattr_setpgroup(@this, value); end
|
164
|
+
|
165
|
+
# int (lfp_spawnattr_t *attr, const lfp_rlimit_t *rlim, size_t rlim_size)
|
166
|
+
def setrlimit(*args); LFP.spawnattr_setrlimit(@this, *args); end
|
167
|
+
def rlimit=(value); LFP.spawnattr_setrlimit(@this, value); end
|
168
|
+
|
169
|
+
# int (lfp_spawnattr_t *attr)
|
170
|
+
def setsid(*args); LFP.spawnattr_setsid(@this, *args); end
|
171
|
+
def sid=(value); LFP.spawnattr_setsid(@this, value); end
|
172
|
+
|
173
|
+
# int (lfp_spawnattr_t *attr, const struct sigset_t *sigdefault)
|
174
|
+
def setsigdefault(*args); LFP.spawnattr_setsigdefault(@this, *args); end
|
175
|
+
def sigdefault=(value); LFP.spawnattr_setsigdefault(@this, value); end
|
176
|
+
|
177
|
+
# int (lfp_spawnattr_t *attr, const struct sigset_t *sigmask)
|
178
|
+
def setsigmask(*args); LFP.spawnattr_setsigmask(@this, *args); end
|
179
|
+
def sigmask=(value); LFP.spawnattr_setsigmask(@this, value); end
|
180
|
+
|
181
|
+
# int (lfp_spawnattr_t *attr, const mode_t umask)
|
182
|
+
def setumask(*args); LFP.spawnattr_setumask(@this, *args); end
|
183
|
+
def umask=(value); LFP.spawnattr_setumask(@this, value); end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
# methods
|
189
|
+
|
190
|
+
# int (int sockfd, struct sockaddr *addr, socklen_t *addrlen, unsigned long int flags)
|
191
|
+
attach_function :accept, :lfp_accept, [:int32, :pointer, :buffer_inout, :uint64], :int32
|
192
|
+
|
193
|
+
# int (struct lfp_buildinfo *v)
|
194
|
+
attach_function :buildinfo, :lfp_buildinfo, [Buildinfo.by_ref], :int32
|
195
|
+
|
196
|
+
# int (void)
|
197
|
+
attach_function :clearenv, :lfp_clearenv, [], :int32
|
198
|
+
|
199
|
+
# int (int clk_id, struct timespec *res)
|
200
|
+
attach_function :clock_getres, :lfp_clock_getres, [:int32, :pointer], :int32
|
201
|
+
|
202
|
+
# int (int clk_id, struct timespec *tp)
|
203
|
+
attach_function :clock_gettime, :lfp_clock_gettime, [:int32, :pointer], :int32
|
204
|
+
|
205
|
+
# int (int clk_id, struct timespec *tp)
|
206
|
+
attach_function :clock_settime, :lfp_clock_settime, [:int32, :pointer], :int32
|
207
|
+
|
208
|
+
# int (struct opaque_ptr *dirp)
|
209
|
+
attach_function :closedir, :lfp_closedir, [:pointer], :int32
|
210
|
+
|
211
|
+
# void (void)
|
212
|
+
attach_function :closelog, :lfp_closelog, [], :void
|
213
|
+
|
214
|
+
# void *(struct cmsghdr *cmsg)
|
215
|
+
attach_function :cmsg_data, :lfp_cmsg_data, [:pointer], :pointer
|
216
|
+
|
217
|
+
# struct cmsghdr *(struct msghdr *msgh)
|
218
|
+
attach_function :cmsg_firsthdr, :lfp_cmsg_firsthdr, [:pointer], :pointer
|
219
|
+
|
220
|
+
# size_t (size_t length)
|
221
|
+
attach_function :cmsg_len, :lfp_cmsg_len, [:size_t], :size_t
|
222
|
+
|
223
|
+
# struct cmsghdr *(struct msghdr *msgh, struct cmsghdr *cmsg)
|
224
|
+
attach_function :cmsg_nxthdr, :lfp_cmsg_nxthdr, [:pointer, :pointer], :pointer
|
225
|
+
|
226
|
+
# size_t (size_t length)
|
227
|
+
attach_function :cmsg_space, :lfp_cmsg_space, [:size_t], :size_t
|
228
|
+
|
229
|
+
# int (const char *pathname, mode_t mode)
|
230
|
+
attach_function :creat, :lfp_creat, [:string, :mode_t], :int32
|
231
|
+
|
232
|
+
# int (void)
|
233
|
+
attach_function :errno, :lfp_errno, [], :int32
|
234
|
+
|
235
|
+
# int (const char *path, char *const argv[], char *const envp[])
|
236
|
+
attach_function :execve, :lfp_execve, [:string, :pointer, :pointer], :int32
|
237
|
+
|
238
|
+
# int (const char *file, char *const argv[], char *const envp[])
|
239
|
+
attach_function :execvpe, :lfp_execvpe, [:string, :pointer, :pointer], :int32
|
240
|
+
|
241
|
+
# void (int fd, struct opaque_ptr *set)
|
242
|
+
attach_function :fd_clr, :lfp_fd_clr, [:int32, :pointer], :void
|
243
|
+
|
244
|
+
# _Bool (int fd, struct opaque_ptr *set)
|
245
|
+
attach_function :fd_isset, :lfp_fd_isset, [:int32, :pointer], :bool
|
246
|
+
|
247
|
+
# void (int fd, struct opaque_ptr *set)
|
248
|
+
attach_function :fd_set, :lfp_fd_set, [:int32, :pointer], :void
|
249
|
+
|
250
|
+
# void (struct opaque_ptr *set)
|
251
|
+
attach_function :fd_zero, :lfp_fd_zero, [:pointer], :void
|
252
|
+
|
253
|
+
# int (int fd, struct stat *buf)
|
254
|
+
attach_function :fstat, :lfp_fstat, [:int32, :pointer], :int32
|
255
|
+
|
256
|
+
# int (int fd, off_t length)
|
257
|
+
attach_function :ftruncate, :lfp_ftruncate, [:int32, :off_t], :int32
|
258
|
+
|
259
|
+
# char **(void)
|
260
|
+
attach_function :get_environ, :lfp_get_environ, [], :pointer
|
261
|
+
|
262
|
+
# char *(char *const envp[])
|
263
|
+
attach_function :getpath, :lfp_getpath, [:pointer], :string
|
264
|
+
|
265
|
+
# int (int socket, uid_t *euid, gid_t *egid)
|
266
|
+
attach_function :getpeereid, :lfp_getpeereid, [:int32, :buffer_inout, :buffer_inout], :int32
|
267
|
+
|
268
|
+
# int (int resource, struct rlimit *rlim)
|
269
|
+
attach_function :getrlimit, :lfp_getrlimit, [:int32, :pointer], :int32
|
270
|
+
|
271
|
+
# int (int fd)
|
272
|
+
attach_function :is_fd_cloexec, :lfp_is_fd_cloexec, [:int32], :int32
|
273
|
+
|
274
|
+
# int (int fd)
|
275
|
+
attach_function :is_fd_nonblock, :lfp_is_fd_nonblock, [:int32], :int32
|
276
|
+
|
277
|
+
# int (int fd)
|
278
|
+
attach_function :is_fd_open, :lfp_is_fd_open, [:int32], :int32
|
279
|
+
|
280
|
+
# _Bool (mode_t mode)
|
281
|
+
attach_function :isblk, :lfp_isblk, [:mode_t], :bool
|
282
|
+
|
283
|
+
# _Bool (mode_t mode)
|
284
|
+
attach_function :ischr, :lfp_ischr, [:mode_t], :bool
|
285
|
+
|
286
|
+
# _Bool (mode_t mode)
|
287
|
+
attach_function :isdir, :lfp_isdir, [:mode_t], :bool
|
288
|
+
|
289
|
+
# _Bool (mode_t mode)
|
290
|
+
attach_function :isfifo, :lfp_isfifo, [:mode_t], :bool
|
291
|
+
|
292
|
+
# _Bool (mode_t mode)
|
293
|
+
attach_function :islnk, :lfp_islnk, [:mode_t], :bool
|
294
|
+
|
295
|
+
# _Bool (mode_t mode)
|
296
|
+
attach_function :isreg, :lfp_isreg, [:mode_t], :bool
|
297
|
+
|
298
|
+
# _Bool (mode_t mode)
|
299
|
+
attach_function :issock, :lfp_issock, [:mode_t], :bool
|
300
|
+
|
301
|
+
# int (int priority)
|
302
|
+
attach_function :log_mask, :lfp_log_mask, [:int32], :int32
|
303
|
+
|
304
|
+
# int (int priority)
|
305
|
+
attach_function :log_upto, :lfp_log_upto, [:int32], :int32
|
306
|
+
|
307
|
+
# off_t (int fd, off_t offset, int whence)
|
308
|
+
attach_function :lseek, :lfp_lseek, [:int32, :off_t, :int32], :off_t
|
309
|
+
|
310
|
+
# int (const char *path, struct stat *buf)
|
311
|
+
attach_function :lstat, :lfp_lstat, [:string, :pointer], :int32
|
312
|
+
|
313
|
+
# int (char *tmplate, unsigned long int flags)
|
314
|
+
attach_function :mkostemp, :lfp_mkostemp, [:buffer_inout, :uint64], :int32
|
315
|
+
|
316
|
+
# int (char *tmplate)
|
317
|
+
attach_function :mkstemp, :lfp_mkstemp, [:buffer_inout], :int32
|
318
|
+
|
319
|
+
# void *(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
|
320
|
+
attach_function :mmap, :lfp_mmap, [:buffer_inout, :size_t, :int32, :int32, :int32, :off_t], :pointer
|
321
|
+
|
322
|
+
# int (void *addr, size_t length)
|
323
|
+
attach_function :munmap, :lfp_munmap, [:buffer_inout, :size_t], :int32
|
324
|
+
|
325
|
+
# int (int incr, int *new_nice)
|
326
|
+
attach_function :nice_k, :lfp_nice_k, [:int32, :buffer_inout], :int32
|
327
|
+
|
328
|
+
# int (int *newfd, const char *pathname, unsigned long int flags, mode_t mode)
|
329
|
+
attach_function :open_k, :lfp_open_k, [:buffer_inout, :string, :uint64, :mode_t], :int32
|
330
|
+
|
331
|
+
# struct opaque_ptr *(const char *name)
|
332
|
+
attach_function :opendir, :lfp_opendir, [:string], :pointer
|
333
|
+
|
334
|
+
# void (const char *ident, int options, int facility)
|
335
|
+
attach_function :openlog, :lfp_openlog, [:string, :int32, :int32], :void
|
336
|
+
|
337
|
+
# int (unsigned long int flags)
|
338
|
+
attach_function :openpt, :lfp_openpt, [:uint64], :int32
|
339
|
+
|
340
|
+
# long int (const char *s, enum lfp_memsize_measure_unit default_unit)
|
341
|
+
attach_function :parse_memsize, :lfp_parse_memsize, [:string, :memsize_measure_unit], :int64
|
342
|
+
|
343
|
+
# int (int pipefd[2], unsigned long int flags)
|
344
|
+
attach_function :pipe, :lfp_pipe, [:buffer_in, :uint64], :int32
|
345
|
+
|
346
|
+
# ssize_t (int fd, void *buf, size_t count, off_t offset)
|
347
|
+
attach_function :pread, :lfp_pread, [:int32, :buffer_inout, :size_t, :off_t], :ssize_t
|
348
|
+
|
349
|
+
# int (int masterfd, char *buf, size_t buflen)
|
350
|
+
attach_function :ptsname, :lfp_ptsname, [:int32, :buffer_inout, :size_t], :int32
|
351
|
+
|
352
|
+
# ssize_t (int fd, const void *buf, size_t count, off_t offset)
|
353
|
+
attach_function :pwrite, :lfp_pwrite, [:int32, :buffer_inout, :size_t, :off_t], :ssize_t
|
354
|
+
|
355
|
+
# int (struct opaque_ptr *dirp, struct dirent *entry, struct dirent **result)
|
356
|
+
attach_function :readdir, :lfp_readdir, [:pointer, :pointer, :pointer], :int32
|
357
|
+
|
358
|
+
# void (struct opaque_ptr *dirp)
|
359
|
+
attach_function :rewinddir, :lfp_rewinddir, [:pointer], :void
|
360
|
+
|
361
|
+
# void (struct opaque_ptr *dirp, long int offset)
|
362
|
+
attach_function :seekdir, :lfp_seekdir, [:pointer, :int64], :void
|
363
|
+
|
364
|
+
# int (int nfds, struct opaque_ptr *readfds, struct opaque_ptr *writefds, struct opaque_ptr *exceptfds, const struct timespec *timeout)
|
365
|
+
attach_function :select, :lfp_select, [:int32, :pointer, :pointer, :pointer, :pointer], :int32
|
366
|
+
|
367
|
+
# ssize_t (int out_fd, int in_fd, off_t offset, size_t nbytes)
|
368
|
+
attach_function :sendfile, :lfp_sendfile, [:int32, :int32, :off_t, :size_t], :ssize_t
|
369
|
+
|
370
|
+
# int (char **newenv)
|
371
|
+
attach_function :set_environ, :lfp_set_environ, [:buffer_inout], :int32
|
372
|
+
|
373
|
+
# int (int value)
|
374
|
+
attach_function :set_errno, :lfp_set_errno, [:int32], :int32
|
375
|
+
|
376
|
+
# int (int fd, _Bool enabled)
|
377
|
+
attach_function :set_fd_cloexec, :lfp_set_fd_cloexec, [:int32, :bool], :int32
|
378
|
+
|
379
|
+
# int (int fd, _Bool enabled)
|
380
|
+
attach_function :set_fd_nonblock, :lfp_set_fd_nonblock, [:int32, :bool], :int32
|
381
|
+
|
382
|
+
# int (int maskpri)
|
383
|
+
attach_function :setlogmask, :lfp_setlogmask, [:int32], :int32
|
384
|
+
|
385
|
+
# int (int resource, const struct rlimit *rlim)
|
386
|
+
attach_function :setrlimit, :lfp_setrlimit, [:int32, :pointer], :int32
|
387
|
+
|
388
|
+
# lfp_sighandler_t (void)
|
389
|
+
attach_function :sig_dfl, :lfp_sig_dfl, [], :sighandler
|
390
|
+
|
391
|
+
# lfp_sighandler_t (void)
|
392
|
+
attach_function :sig_err, :lfp_sig_err, [], :sighandler
|
393
|
+
|
394
|
+
# lfp_sighandler_t (void)
|
395
|
+
attach_function :sig_hold, :lfp_sig_hold, [], :sighandler
|
396
|
+
|
397
|
+
# lfp_sighandler_t (void)
|
398
|
+
attach_function :sig_ign, :lfp_sig_ign, [], :sighandler
|
399
|
+
|
400
|
+
# int (void)
|
401
|
+
attach_function :sigrtmax, :lfp_sigrtmax, [], :int32
|
402
|
+
|
403
|
+
# int (void)
|
404
|
+
attach_function :sigrtmin, :lfp_sigrtmin, [], :int32
|
405
|
+
|
406
|
+
# int (int domain, int type, int protocol, unsigned long int flags)
|
407
|
+
attach_function :socket, :lfp_socket, [:int32, :int32, :int32, :uint64], :int32
|
408
|
+
|
409
|
+
# int (pid_t *restrict pid, const char *restrict path, char *const argv[], char *const envp[], const lfp_spawn_file_actions_t *restrict file_actions, const lfp_spawnattr_t *restrict attr)
|
410
|
+
attach_function :spawn, :lfp_spawn, [:buffer_inout, :string, :pointer, :pointer, :pointer, :pointer], :int32
|
411
|
+
|
412
|
+
# int (pid_t *restrict pid, const char *restrict file, char *const argv[], char *const envp[], const lfp_spawn_file_actions_t *restrict file_actions, const lfp_spawnattr_t *restrict attr)
|
413
|
+
attach_function :spawnp, :lfp_spawnp, [:buffer_inout, :string, :pointer, :pointer, :pointer, :pointer], :int32
|
414
|
+
|
415
|
+
# int (const char *path, struct stat *buf)
|
416
|
+
attach_function :stat, :lfp_stat, [:string, :pointer], :int32
|
417
|
+
|
418
|
+
# char *(const char *s, size_t maxlen)
|
419
|
+
attach_function :strndup, :lfp_strndup, [:string, :size_t], :string
|
420
|
+
|
421
|
+
# size_t (const char *s, size_t maxlen)
|
422
|
+
attach_function :strnlen, :lfp_strnlen, [:string, :size_t], :size_t
|
423
|
+
|
424
|
+
# long int (struct opaque_ptr *dirp)
|
425
|
+
attach_function :telldir, :lfp_telldir, [:pointer], :int64
|
426
|
+
|
427
|
+
# int (const char *path, off_t length)
|
428
|
+
attach_function :truncate, :lfp_truncate, [:string, :off_t], :int32
|
429
|
+
|
430
|
+
# void (int priority, const char *msg, va_list args)
|
431
|
+
attach_function :vsyslog, :lfp_vsyslog, [:int32, :string, :pointer], :void
|
432
|
+
|
433
|
+
# _Bool (int status)
|
434
|
+
attach_function :wcoredump, :lfp_wcoredump, [:int32], :bool
|
435
|
+
|
436
|
+
# int (int status)
|
437
|
+
attach_function :wexitstatus, :lfp_wexitstatus, [:int32], :int32
|
438
|
+
|
439
|
+
# _Bool (int status)
|
440
|
+
attach_function :wifcontinued, :lfp_wifcontinued, [:int32], :bool
|
441
|
+
|
442
|
+
# _Bool (int status)
|
443
|
+
attach_function :wifexited, :lfp_wifexited, [:int32], :bool
|
444
|
+
|
445
|
+
# _Bool (int status)
|
446
|
+
attach_function :wifsignaled, :lfp_wifsignaled, [:int32], :bool
|
447
|
+
|
448
|
+
# _Bool (int status)
|
449
|
+
attach_function :wifstopped, :lfp_wifstopped, [:int32], :bool
|
450
|
+
|
451
|
+
# int (int status)
|
452
|
+
attach_function :wstopsig, :lfp_wstopsig, [:int32], :int32
|
453
|
+
|
454
|
+
# int (int status)
|
455
|
+
attach_function :wtermsig, :lfp_wtermsig, [:int32], :int32
|
456
|
+
|
457
|
+
# int (lfp_spawn_file_actions_t *file_actions, int fd)
|
458
|
+
attach_function :spawn_file_actions_addclose, :lfp_spawn_file_actions_addclose, [:pointer, :int32], :int32
|
459
|
+
|
460
|
+
# int (lfp_spawn_file_actions_t *file_actions, int fd, int newfd)
|
461
|
+
attach_function :spawn_file_actions_adddup2, :lfp_spawn_file_actions_adddup2, [:pointer, :int32, :int32], :int32
|
462
|
+
|
463
|
+
# int (lfp_spawn_file_actions_t *file_actions, int fd)
|
464
|
+
attach_function :spawn_file_actions_addkeep, :lfp_spawn_file_actions_addkeep, [:pointer, :int32], :int32
|
465
|
+
|
466
|
+
# int (lfp_spawn_file_actions_t *file_actions, int fd, const char *path, unsigned long int oflags, mode_t mode)
|
467
|
+
attach_function :spawn_file_actions_addopen, :lfp_spawn_file_actions_addopen, [:pointer, :int32, :string, :uint64, :mode_t], :int32
|
468
|
+
|
469
|
+
# int (lfp_spawn_file_actions_t *file_actions)
|
470
|
+
attach_function :spawn_file_actions_destroy, :lfp_spawn_file_actions_destroy, [:pointer], :int32
|
471
|
+
|
472
|
+
# int (lfp_spawn_file_actions_t *file_actions)
|
473
|
+
attach_function :spawn_file_actions_init, :lfp_spawn_file_actions_init, [:pointer], :int32
|
474
|
+
|
475
|
+
# int (lfp_spawnattr_t *attr)
|
476
|
+
attach_function :spawnattr_destroy, :lfp_spawnattr_destroy, [:pointer], :int32
|
477
|
+
|
478
|
+
# int (lfp_spawnattr_t *attr, char **path)
|
479
|
+
attach_function :spawnattr_getctty, :lfp_spawnattr_getctty, [:pointer, :buffer_inout], :int32
|
480
|
+
|
481
|
+
# int (lfp_spawnattr_t *attr, char **path)
|
482
|
+
attach_function :spawnattr_getcwd, :lfp_spawnattr_getcwd, [:pointer, :buffer_inout], :int32
|
483
|
+
|
484
|
+
# int (lfp_spawnattr_t *attr, unsigned int *flags)
|
485
|
+
attach_function :spawnattr_getflags, :lfp_spawnattr_getflags, [:pointer, :buffer_inout], :int32
|
486
|
+
|
487
|
+
# int (lfp_spawnattr_t *attr, pid_t *pgroup)
|
488
|
+
attach_function :spawnattr_getpgroup, :lfp_spawnattr_getpgroup, [:pointer, :buffer_inout], :int32
|
489
|
+
|
490
|
+
# int (lfp_spawnattr_t *attr, lfp_rlimit_t **rlim, size_t *rlim_size)
|
491
|
+
attach_function :spawnattr_getrlimit, :lfp_spawnattr_getrlimit, [:pointer, :pointer, :buffer_inout], :int32
|
492
|
+
|
493
|
+
# int (lfp_spawnattr_t *attr, struct sigset_t *sigdefault)
|
494
|
+
attach_function :spawnattr_getsigdefault, :lfp_spawnattr_getsigdefault, [:pointer, :pointer], :int32
|
495
|
+
|
496
|
+
# int (lfp_spawnattr_t *attr, struct sigset_t *sigmask)
|
497
|
+
attach_function :spawnattr_getsigmask, :lfp_spawnattr_getsigmask, [:pointer, :pointer], :int32
|
498
|
+
|
499
|
+
# int (lfp_spawnattr_t *attr, mode_t *umask)
|
500
|
+
attach_function :spawnattr_getumask, :lfp_spawnattr_getumask, [:pointer, :buffer_inout], :int32
|
501
|
+
|
502
|
+
# int (lfp_spawnattr_t *attr)
|
503
|
+
attach_function :spawnattr_init, :lfp_spawnattr_init, [:pointer], :int32
|
504
|
+
|
505
|
+
# int (lfp_spawnattr_t *attr, const char *path)
|
506
|
+
attach_function :spawnattr_setctty, :lfp_spawnattr_setctty, [:pointer, :string], :int32
|
507
|
+
|
508
|
+
# int (lfp_spawnattr_t *attr, const char *path)
|
509
|
+
attach_function :spawnattr_setcwd, :lfp_spawnattr_setcwd, [:pointer, :string], :int32
|
510
|
+
|
511
|
+
# int (lfp_spawnattr_t *attr, const unsigned int flags)
|
512
|
+
attach_function :spawnattr_setflags, :lfp_spawnattr_setflags, [:pointer, :uint32], :int32
|
513
|
+
|
514
|
+
# int (lfp_spawnattr_t *attr, const pid_t pgroup)
|
515
|
+
attach_function :spawnattr_setpgroup, :lfp_spawnattr_setpgroup, [:pointer, :pid_t], :int32
|
516
|
+
|
517
|
+
# int (lfp_spawnattr_t *attr, const lfp_rlimit_t *rlim, size_t rlim_size)
|
518
|
+
attach_function :spawnattr_setrlimit, :lfp_spawnattr_setrlimit, [:pointer, :pointer, :size_t], :int32
|
519
|
+
|
520
|
+
# int (lfp_spawnattr_t *attr)
|
521
|
+
attach_function :spawnattr_setsid, :lfp_spawnattr_setsid, [:pointer], :int32
|
522
|
+
|
523
|
+
# int (lfp_spawnattr_t *attr, const struct sigset_t *sigdefault)
|
524
|
+
attach_function :spawnattr_setsigdefault, :lfp_spawnattr_setsigdefault, [:pointer, :pointer], :int32
|
525
|
+
|
526
|
+
# int (lfp_spawnattr_t *attr, const struct sigset_t *sigmask)
|
527
|
+
attach_function :spawnattr_setsigmask, :lfp_spawnattr_setsigmask, [:pointer, :pointer], :int32
|
528
|
+
|
529
|
+
# int (lfp_spawnattr_t *attr, const mode_t umask)
|
530
|
+
attach_function :spawnattr_setumask, :lfp_spawnattr_setumask, [:pointer, :mode_t], :int32
|
531
|
+
|
532
|
+
end
|
data/lib/libfixposix.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LFP
|
4
|
+
module LFPFile
|
5
|
+
def self.local_so
|
6
|
+
list = []
|
7
|
+
list += ENV["LIBFIXPOSIX_PATH"].split(";;") if ENV["LIBFIXPOSIX_PATH"]
|
8
|
+
list << "fixposix"
|
9
|
+
list
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
begin
|
14
|
+
require "libfixposix/binary"
|
15
|
+
rescue LoadError
|
16
|
+
# no binary installed, use system wide or ENV var
|
17
|
+
end
|
18
|
+
require_relative "./libfixposix/ffi"
|
19
|
+
|
20
|
+
# Extract bound version
|
21
|
+
module LFP
|
22
|
+
VERSION = "#{LFP::INTERFACE_VERSION}.0"
|
23
|
+
Buildinfo.new.tap {|ptr|
|
24
|
+
LFP.buildinfo(ptr)
|
25
|
+
SO_VERSION = [ptr[:release]].pack("L").unpack("ccc").reverse.join(".")
|
26
|
+
}
|
27
|
+
COMPLETE_VERSION = {
|
28
|
+
gem: LFP::VERSION,
|
29
|
+
interface: LFP::INTERFACE_VERSION,
|
30
|
+
library: LFP::SO_VERSION,
|
31
|
+
}
|
32
|
+
if defined? LFP::Binary
|
33
|
+
COMPLETE_VERSION[:binary] = {
|
34
|
+
gem: LFP::Binary::GEM_VERSION,
|
35
|
+
interface: LFP::Binary::API_VERSION,
|
36
|
+
library: LFP::Binary::SO_VERSION,
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ffi-bindings-libfixposix
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Patrick Plenefisch
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ffi-binary-libfixposix
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.5.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.5.1
|
41
|
+
description: Direct FFI bindings for libfixposix. Binary not included.
|
42
|
+
email:
|
43
|
+
- simonpatp@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- Gemfile
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- lib/libfixposix.rb
|
52
|
+
- lib/libfixposix/ffi.rb
|
53
|
+
- lib/libfixposix/version.rb
|
54
|
+
homepage: https://github.com/byteit101/subspawn
|
55
|
+
licenses: []
|
56
|
+
metadata:
|
57
|
+
homepage_uri: https://github.com/byteit101/subspawn
|
58
|
+
source_code_uri: https://github.com/byteit101/subspawn
|
59
|
+
changelog_uri: https://github.com/byteit101/subspawn
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.6.0
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubygems_version: 3.0.3.1
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Direct FFI bindings for libfixposix
|
79
|
+
test_files: []
|