1// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gio
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type UnixFDListClass struct {
17 _ structs.HostLayout
18
19 ParentClass gobject.ObjectClass
20
21 xGReserved1 uintptr
22
23 xGReserved2 uintptr
24
25 xGReserved3 uintptr
26
27 xGReserved4 uintptr
28
29 xGReserved5 uintptr
30}
31
32func (x *UnixFDListClass) GoPointer() uintptr {
33 return uintptr(unsafe.Pointer(x))
34}
35
36// OverrideGReserved1 sets the "_g_reserved1" callback function.
37func (x *UnixFDListClass) OverrideGReserved1(cb func()) {
38 if cb == nil {
39 x.xGReserved1 = 0
40 } else {
41 x.xGReserved1 = purego.NewCallback(func() {
42 cb()
43 })
44 }
45}
46
47// GetGReserved1 gets the "_g_reserved1" callback function.
48func (x *UnixFDListClass) GetGReserved1() func() {
49 if x.xGReserved1 == 0 {
50 return nil
51 }
52 var rawCallback func()
53 purego.RegisterFunc(&rawCallback, x.xGReserved1)
54 return func() {
55 rawCallback()
56 }
57}
58
59// OverrideGReserved2 sets the "_g_reserved2" callback function.
60func (x *UnixFDListClass) OverrideGReserved2(cb func()) {
61 if cb == nil {
62 x.xGReserved2 = 0
63 } else {
64 x.xGReserved2 = purego.NewCallback(func() {
65 cb()
66 })
67 }
68}
69
70// GetGReserved2 gets the "_g_reserved2" callback function.
71func (x *UnixFDListClass) GetGReserved2() func() {
72 if x.xGReserved2 == 0 {
73 return nil
74 }
75 var rawCallback func()
76 purego.RegisterFunc(&rawCallback, x.xGReserved2)
77 return func() {
78 rawCallback()
79 }
80}
81
82// OverrideGReserved3 sets the "_g_reserved3" callback function.
83func (x *UnixFDListClass) OverrideGReserved3(cb func()) {
84 if cb == nil {
85 x.xGReserved3 = 0
86 } else {
87 x.xGReserved3 = purego.NewCallback(func() {
88 cb()
89 })
90 }
91}
92
93// GetGReserved3 gets the "_g_reserved3" callback function.
94func (x *UnixFDListClass) GetGReserved3() func() {
95 if x.xGReserved3 == 0 {
96 return nil
97 }
98 var rawCallback func()
99 purego.RegisterFunc(&rawCallback, x.xGReserved3)
100 return func() {
101 rawCallback()
102 }
103}
104
105// OverrideGReserved4 sets the "_g_reserved4" callback function.
106func (x *UnixFDListClass) OverrideGReserved4(cb func()) {
107 if cb == nil {
108 x.xGReserved4 = 0
109 } else {
110 x.xGReserved4 = purego.NewCallback(func() {
111 cb()
112 })
113 }
114}
115
116// GetGReserved4 gets the "_g_reserved4" callback function.
117func (x *UnixFDListClass) GetGReserved4() func() {
118 if x.xGReserved4 == 0 {
119 return nil
120 }
121 var rawCallback func()
122 purego.RegisterFunc(&rawCallback, x.xGReserved4)
123 return func() {
124 rawCallback()
125 }
126}
127
128// OverrideGReserved5 sets the "_g_reserved5" callback function.
129func (x *UnixFDListClass) OverrideGReserved5(cb func()) {
130 if cb == nil {
131 x.xGReserved5 = 0
132 } else {
133 x.xGReserved5 = purego.NewCallback(func() {
134 cb()
135 })
136 }
137}
138
139// GetGReserved5 gets the "_g_reserved5" callback function.
140func (x *UnixFDListClass) GetGReserved5() func() {
141 if x.xGReserved5 == 0 {
142 return nil
143 }
144 var rawCallback func()
145 purego.RegisterFunc(&rawCallback, x.xGReserved5)
146 return func() {
147 rawCallback()
148 }
149}
150
151type UnixFDListPrivate struct {
152 _ structs.HostLayout
153}
154
155func (x *UnixFDListPrivate) GoPointer() uintptr {
156 return uintptr(unsafe.Pointer(x))
157}
158
159// A `GUnixFDList` contains a list of file descriptors. It owns the file
160// descriptors that it contains, closing them when finalized.
161//
162// It may be wrapped in a
163// [`GUnixFDMessage`](../gio-unix/class.UnixFDMessage.html) and sent over a
164// [class@Gio.Socket] in the `G_SOCKET_FAMILY_UNIX` family by using
165// [method@Gio.Socket.send_message] and received using
166// [method@Gio.Socket.receive_message].
167//
168// Before 2.74, `<gio/gunixfdlist.h>` belonged to the UNIX-specific GIO
169// interfaces, thus you had to use the `gio-unix-2.0.pc` pkg-config file when
170// using it.
171//
172// Since 2.74, the API is available for Windows.
173type UnixFDList struct {
174 gobject.Object
175}
176
177var xUnixFDListGLibType func() types.GType
178
179func UnixFDListGLibType() types.GType {
180 return xUnixFDListGLibType()
181}
182
183func UnixFDListNewFromInternalPtr(ptr uintptr) *UnixFDList {
184 cls := &UnixFDList{}
185 cls.Ptr = ptr
186 return cls
187}
188
189var xNewUnixFDList func() uintptr
190
191// Creates a new #GUnixFDList containing no file descriptors.
192func NewUnixFDList() *UnixFDList {
193 var cls *UnixFDList
194
195 cret := xNewUnixFDList()
196
197 if cret == 0 {
198 return nil
199 }
200 cls = &UnixFDList{}
201 cls.Ptr = cret
202 return cls
203}
204
205var xNewUnixFDListFromArray func([]int, int) uintptr
206
207// Creates a new #GUnixFDList containing the file descriptors given in
208// @fds. The file descriptors become the property of the new list and
209// may no longer be used by the caller. The array itself is owned by
210// the caller.
211//
212// Each file descriptor in the array should be set to close-on-exec.
213//
214// If @n_fds is -1 then @fds must be terminated with -1.
215func NewUnixFDListFromArray(FdsVar []int, NFdsVar int) *UnixFDList {
216 var cls *UnixFDList
217
218 cret := xNewUnixFDListFromArray(FdsVar, NFdsVar)
219
220 if cret == 0 {
221 return nil
222 }
223 cls = &UnixFDList{}
224 cls.Ptr = cret
225 return cls
226}
227
228var xUnixFDListAppend func(uintptr, int, **glib.Error) int
229
230// Adds a file descriptor to @list.
231//
232// The file descriptor is duplicated using dup(). You keep your copy
233// of the descriptor and the copy contained in @list will be closed
234// when @list is finalized.
235//
236// A possible cause of failure is exceeding the per-process or
237// system-wide file descriptor limit.
238//
239// The index of the file descriptor in the list is returned. If you use
240// this index with g_unix_fd_list_get() then you will receive back a
241// duplicated copy of the same file descriptor.
242func (x *UnixFDList) Append(FdVar int) (int, error) {
243 var cerr *glib.Error
244
245 cret := xUnixFDListAppend(x.GoPointer(), FdVar, &cerr)
246 if cerr == nil {
247 return cret, nil
248 }
249 return cret, cerr
250
251}
252
253var xUnixFDListGet func(uintptr, int, **glib.Error) int
254
255// Gets a file descriptor out of @list.
256//
257// @index_ specifies the index of the file descriptor to get. It is a
258// programmer error for @index_ to be out of range; see
259// g_unix_fd_list_get_length().
260//
261// The file descriptor is duplicated using dup() and set as
262// close-on-exec before being returned. You must call close() on it
263// when you are done.
264//
265// A possible cause of failure is exceeding the per-process or
266// system-wide file descriptor limit.
267func (x *UnixFDList) Get(IndexVar int) (int, error) {
268 var cerr *glib.Error
269
270 cret := xUnixFDListGet(x.GoPointer(), IndexVar, &cerr)
271 if cerr == nil {
272 return cret, nil
273 }
274 return cret, cerr
275
276}
277
278var xUnixFDListGetLength func(uintptr) int
279
280// Gets the length of @list (ie: the number of file descriptors
281// contained within).
282func (x *UnixFDList) GetLength() int {
283
284 cret := xUnixFDListGetLength(x.GoPointer())
285 return cret
286}
287
288var xUnixFDListPeekFds func(uintptr, *int) uintptr
289
290// Returns the array of file descriptors that is contained in this
291// object.
292//
293// After this call, the descriptors remain the property of @list. The
294// caller must not close them and must not free the array. The array is
295// valid only until @list is changed in any way.
296//
297// If @length is non-%NULL then it is set to the number of file
298// descriptors in the returned array. The returned array is also
299// terminated with -1.
300//
301// This function never returns %NULL. In case there are no file
302// descriptors contained in @list, an empty array is returned.
303func (x *UnixFDList) PeekFds(LengthVar *int) uintptr {
304
305 cret := xUnixFDListPeekFds(x.GoPointer(), LengthVar)
306 return cret
307}
308
309var xUnixFDListStealFds func(uintptr, *int) uintptr
310
311// Returns the array of file descriptors that is contained in this
312// object.
313//
314// After this call, the descriptors are no longer contained in
315// @list. Further calls will return an empty list (unless more
316// descriptors have been added).
317//
318// The return result of this function must be freed with g_free().
319// The caller is also responsible for closing all of the file
320// descriptors. The file descriptors in the array are set to
321// close-on-exec.
322//
323// If @length is non-%NULL then it is set to the number of file
324// descriptors in the returned array. The returned array is also
325// terminated with -1.
326//
327// This function never returns %NULL. In case there are no file
328// descriptors contained in @list, an empty array is returned.
329func (x *UnixFDList) StealFds(LengthVar *int) uintptr {
330
331 cret := xUnixFDListStealFds(x.GoPointer(), LengthVar)
332 return cret
333}
334
335func (c *UnixFDList) GoPointer() uintptr {
336 if c == nil {
337 return 0
338 }
339 return c.Ptr
340}
341
342func (c *UnixFDList) SetGoPointer(ptr uintptr) {
343 c.Ptr = ptr
344}
345
346func init() {
347 core.SetPackageName("GIO", "gio-2.0")
348 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
349 var libs []uintptr
350 for _, libPath := range core.GetPaths("GIO") {
351 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
352 if err != nil {
353 panic(err)
354 }
355 libs = append(libs, lib)
356 }
357
358 core.PuregoSafeRegister(&xUnixFDListGLibType, libs, "g_unix_fd_list_get_type")
359
360 core.PuregoSafeRegister(&xNewUnixFDList, libs, "g_unix_fd_list_new")
361 core.PuregoSafeRegister(&xNewUnixFDListFromArray, libs, "g_unix_fd_list_new_from_array")
362
363 core.PuregoSafeRegister(&xUnixFDListAppend, libs, "g_unix_fd_list_append")
364 core.PuregoSafeRegister(&xUnixFDListGet, libs, "g_unix_fd_list_get")
365 core.PuregoSafeRegister(&xUnixFDListGetLength, libs, "g_unix_fd_list_get_length")
366 core.PuregoSafeRegister(&xUnixFDListPeekFds, libs, "g_unix_fd_list_peek_fds")
367 core.PuregoSafeRegister(&xUnixFDListStealFds, libs, "g_unix_fd_list_steal_fds")
368
369}