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 UnixSocketAddressClass struct {
17 _ structs.HostLayout
18
19 ParentClass SocketAddressClass
20}
21
22func (x *UnixSocketAddressClass) GoPointer() uintptr {
23 return uintptr(unsafe.Pointer(x))
24}
25
26type UnixSocketAddressPrivate struct {
27 _ structs.HostLayout
28}
29
30func (x *UnixSocketAddressPrivate) GoPointer() uintptr {
31 return uintptr(unsafe.Pointer(x))
32}
33
34// Support for UNIX-domain (also known as local) sockets, corresponding to
35// `struct sockaddr_un`.
36//
37// UNIX domain sockets are generally visible in the filesystem.
38// However, some systems support abstract socket names which are not
39// visible in the filesystem and not affected by the filesystem
40// permissions, visibility, etc. Currently this is only supported
41// under Linux. If you attempt to use abstract sockets on other
42// systems, function calls may return `G_IO_ERROR_NOT_SUPPORTED`
43// errors. You can use [func@Gio.UnixSocketAddress.abstract_names_supported]
44// to see if abstract names are supported.
45//
46// Since GLib 2.72, `GUnixSocketAddress` is available on all platforms. It
47// requires underlying system support (such as Windows 10 with `AF_UNIX`) at
48// run time.
49//
50// Before GLib 2.72, `<gio/gunixsocketaddress.h>` belonged to the UNIX-specific
51// GIO interfaces, thus you had to use the `gio-unix-2.0.pc` pkg-config file
52// when using it. This is no longer necessary since GLib 2.72.
53type UnixSocketAddress struct {
54 SocketAddress
55}
56
57var xUnixSocketAddressGLibType func() types.GType
58
59func UnixSocketAddressGLibType() types.GType {
60 return xUnixSocketAddressGLibType()
61}
62
63func UnixSocketAddressNewFromInternalPtr(ptr uintptr) *UnixSocketAddress {
64 cls := &UnixSocketAddress{}
65 cls.Ptr = ptr
66 return cls
67}
68
69var xNewUnixSocketAddress func(string) uintptr
70
71// Creates a new #GUnixSocketAddress for @path.
72//
73// To create abstract socket addresses, on systems that support that,
74// use g_unix_socket_address_new_abstract().
75func NewUnixSocketAddress(PathVar string) *UnixSocketAddress {
76 var cls *UnixSocketAddress
77
78 cret := xNewUnixSocketAddress(PathVar)
79
80 if cret == 0 {
81 return nil
82 }
83 cls = &UnixSocketAddress{}
84 cls.Ptr = cret
85 return cls
86}
87
88var xNewUnixSocketAddressAbstract func([]byte, int) uintptr
89
90// Creates a new %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED
91// #GUnixSocketAddress for @path.
92func NewUnixSocketAddressAbstract(PathVar []byte, PathLenVar int) *UnixSocketAddress {
93 var cls *UnixSocketAddress
94
95 cret := xNewUnixSocketAddressAbstract(PathVar, PathLenVar)
96
97 if cret == 0 {
98 return nil
99 }
100 cls = &UnixSocketAddress{}
101 cls.Ptr = cret
102 return cls
103}
104
105var xNewUnixSocketAddressWithType func([]byte, int, UnixSocketAddressType) uintptr
106
107// Creates a new #GUnixSocketAddress of type @type with name @path.
108//
109// If @type is %G_UNIX_SOCKET_ADDRESS_PATH, this is equivalent to
110// calling g_unix_socket_address_new().
111//
112// If @type is %G_UNIX_SOCKET_ADDRESS_ANONYMOUS, @path and @path_len will be
113// ignored.
114//
115// If @path_type is %G_UNIX_SOCKET_ADDRESS_ABSTRACT, then @path_len
116// bytes of @path will be copied to the socket's path, and only those
117// bytes will be considered part of the name. (If @path_len is -1,
118// then @path is assumed to be NUL-terminated.) For example, if @path
119// was "test", then calling g_socket_address_get_native_size() on the
120// returned socket would return 7 (2 bytes of overhead, 1 byte for the
121// abstract-socket indicator byte, and 4 bytes for the name "test").
122//
123// If @path_type is %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED, then
124// @path_len bytes of @path will be copied to the socket's path, the
125// rest of the path will be padded with 0 bytes, and the entire
126// zero-padded buffer will be considered the name. (As above, if
127// @path_len is -1, then @path is assumed to be NUL-terminated.) In
128// this case, g_socket_address_get_native_size() will always return
129// the full size of a `struct sockaddr_un`, although
130// g_unix_socket_address_get_path_len() will still return just the
131// length of @path.
132//
133// %G_UNIX_SOCKET_ADDRESS_ABSTRACT is preferred over
134// %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED for new programs. Of course,
135// when connecting to a server created by another process, you must
136// use the appropriate type corresponding to how that process created
137// its listening socket.
138func NewUnixSocketAddressWithType(PathVar []byte, PathLenVar int, TypeVar UnixSocketAddressType) *UnixSocketAddress {
139 var cls *UnixSocketAddress
140
141 cret := xNewUnixSocketAddressWithType(PathVar, PathLenVar, TypeVar)
142
143 if cret == 0 {
144 return nil
145 }
146 cls = &UnixSocketAddress{}
147 cls.Ptr = cret
148 return cls
149}
150
151var xUnixSocketAddressGetAddressType func(uintptr) UnixSocketAddressType
152
153// Gets @address's type.
154func (x *UnixSocketAddress) GetAddressType() UnixSocketAddressType {
155
156 cret := xUnixSocketAddressGetAddressType(x.GoPointer())
157 return cret
158}
159
160var xUnixSocketAddressGetIsAbstract func(uintptr) bool
161
162// Tests if @address is abstract.
163func (x *UnixSocketAddress) GetIsAbstract() bool {
164
165 cret := xUnixSocketAddressGetIsAbstract(x.GoPointer())
166 return cret
167}
168
169var xUnixSocketAddressGetPath func(uintptr) string
170
171// Gets @address's path, or for abstract sockets the "name".
172//
173// Guaranteed to be zero-terminated, but an abstract socket
174// may contain embedded zeros, and thus you should use
175// g_unix_socket_address_get_path_len() to get the true length
176// of this string.
177func (x *UnixSocketAddress) GetPath() string {
178
179 cret := xUnixSocketAddressGetPath(x.GoPointer())
180 return cret
181}
182
183var xUnixSocketAddressGetPathLen func(uintptr) uint
184
185// Gets the length of @address's path.
186//
187// For details, see g_unix_socket_address_get_path().
188func (x *UnixSocketAddress) GetPathLen() uint {
189
190 cret := xUnixSocketAddressGetPathLen(x.GoPointer())
191 return cret
192}
193
194func (c *UnixSocketAddress) GoPointer() uintptr {
195 if c == nil {
196 return 0
197 }
198 return c.Ptr
199}
200
201func (c *UnixSocketAddress) SetGoPointer(ptr uintptr) {
202 c.Ptr = ptr
203}
204
205// SetPropertyAbstract sets the "abstract" property.
206// Whether or not this is an abstract address
207func (x *UnixSocketAddress) SetPropertyAbstract(value bool) {
208 var v gobject.Value
209 v.Init(gobject.TypeBooleanVal)
210 v.SetBoolean(value)
211 x.SetProperty("abstract", &v)
212}
213
214// GetPropertyAbstract gets the "abstract" property.
215// Whether or not this is an abstract address
216func (x *UnixSocketAddress) GetPropertyAbstract() bool {
217 var v gobject.Value
218 x.GetProperty("abstract", &v)
219 return v.GetBoolean()
220}
221
222// SetPropertyPath sets the "path" property.
223// Unix socket path.
224func (x *UnixSocketAddress) SetPropertyPath(value string) {
225 var v gobject.Value
226 v.Init(gobject.TypeStringVal)
227 v.SetString(&value)
228 x.SetProperty("path", &v)
229}
230
231// GetPropertyPath gets the "path" property.
232// Unix socket path.
233func (x *UnixSocketAddress) GetPropertyPath() string {
234 var v gobject.Value
235 x.GetProperty("path", &v)
236 return v.GetString()
237}
238
239// SetPropertyPathAsArray sets the "path-as-array" property.
240// Unix socket path, as a byte array.
241func (x *UnixSocketAddress) SetPropertyPathAsArray(value []byte) {
242 var v gobject.Value
243 v.Init(glib.ByteArrayGLibType())
244 v.SetBoxed(uintptr(unsafe.Pointer(&value[0])))
245 x.SetProperty("path-as-array", &v)
246}
247
248// GetPropertyPathAsArray gets the "path-as-array" property.
249// Unix socket path, as a byte array.
250func (x *UnixSocketAddress) GetPropertyPathAsArray() []byte {
251 var v gobject.Value
252 x.GetProperty("path-as-array", &v)
253 ptr := v.GetBoxed()
254 if ptr == 0 {
255 return nil
256 }
257 // GByteArray layout: { guint8 *data; guint len; }
258 dataPtr := *(*uintptr)(unsafe.Pointer(ptr))
259 length := *(*uint32)(unsafe.Pointer(ptr + unsafe.Sizeof(uintptr(0))))
260 if length == 0 || dataPtr == 0 {
261 return nil
262 }
263 return unsafe.Slice((*byte)(unsafe.Pointer(dataPtr)), length)
264}
265
266// Creates a #GSocketAddressEnumerator for @connectable.
267func (x *UnixSocketAddress) Enumerate() *SocketAddressEnumerator {
268 var cls *SocketAddressEnumerator
269
270 cret := XGSocketConnectableEnumerate(x.GoPointer())
271
272 if cret == 0 {
273 return nil
274 }
275 cls = &SocketAddressEnumerator{}
276 cls.Ptr = cret
277 return cls
278}
279
280// Creates a #GSocketAddressEnumerator for @connectable that will
281// return a #GProxyAddress for each of its addresses that you must connect
282// to via a proxy.
283//
284// If @connectable does not implement
285// g_socket_connectable_proxy_enumerate(), this will fall back to
286// calling g_socket_connectable_enumerate().
287func (x *UnixSocketAddress) ProxyEnumerate() *SocketAddressEnumerator {
288 var cls *SocketAddressEnumerator
289
290 cret := XGSocketConnectableProxyEnumerate(x.GoPointer())
291
292 if cret == 0 {
293 return nil
294 }
295 cls = &SocketAddressEnumerator{}
296 cls.Ptr = cret
297 return cls
298}
299
300// Format a #GSocketConnectable as a string. This is a human-readable format for
301// use in debugging output, and is not a stable serialization format. It is not
302// suitable for use in user interfaces as it exposes too much information for a
303// user.
304//
305// If the #GSocketConnectable implementation does not support string formatting,
306// the implementation’s type name will be returned as a fallback.
307func (x *UnixSocketAddress) ToString() string {
308
309 cret := XGSocketConnectableToString(x.GoPointer())
310 return cret
311}
312
313var xUnixSocketAddressAbstractNamesSupported func() bool
314
315// Checks if abstract UNIX domain socket names are supported.
316func UnixSocketAddressAbstractNamesSupported() bool {
317
318 cret := xUnixSocketAddressAbstractNamesSupported()
319 return cret
320}
321
322func init() {
323 core.SetPackageName("GIO", "gio-2.0")
324 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
325 var libs []uintptr
326 for _, libPath := range core.GetPaths("GIO") {
327 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
328 if err != nil {
329 panic(err)
330 }
331 libs = append(libs, lib)
332 }
333
334 core.PuregoSafeRegister(&xUnixSocketAddressGLibType, libs, "g_unix_socket_address_get_type")
335
336 core.PuregoSafeRegister(&xNewUnixSocketAddress, libs, "g_unix_socket_address_new")
337 core.PuregoSafeRegister(&xNewUnixSocketAddressAbstract, libs, "g_unix_socket_address_new_abstract")
338 core.PuregoSafeRegister(&xNewUnixSocketAddressWithType, libs, "g_unix_socket_address_new_with_type")
339
340 core.PuregoSafeRegister(&xUnixSocketAddressGetAddressType, libs, "g_unix_socket_address_get_address_type")
341 core.PuregoSafeRegister(&xUnixSocketAddressGetIsAbstract, libs, "g_unix_socket_address_get_is_abstract")
342 core.PuregoSafeRegister(&xUnixSocketAddressGetPath, libs, "g_unix_socket_address_get_path")
343 core.PuregoSafeRegister(&xUnixSocketAddressGetPathLen, libs, "g_unix_socket_address_get_path_len")
344
345 core.PuregoSafeRegister(&xUnixSocketAddressAbstractNamesSupported, libs, "g_unix_socket_address_abstract_names_supported")
346
347}