// Package gio was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gio import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) type UnixSocketAddressClass struct { _ structs.HostLayout ParentClass SocketAddressClass } func (x *UnixSocketAddressClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } type UnixSocketAddressPrivate struct { _ structs.HostLayout } func (x *UnixSocketAddressPrivate) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // Support for UNIX-domain (also known as local) sockets, corresponding to // `struct sockaddr_un`. // // UNIX domain sockets are generally visible in the filesystem. // However, some systems support abstract socket names which are not // visible in the filesystem and not affected by the filesystem // permissions, visibility, etc. Currently this is only supported // under Linux. If you attempt to use abstract sockets on other // systems, function calls may return `G_IO_ERROR_NOT_SUPPORTED` // errors. You can use [func@Gio.UnixSocketAddress.abstract_names_supported] // to see if abstract names are supported. // // Since GLib 2.72, `GUnixSocketAddress` is available on all platforms. It // requires underlying system support (such as Windows 10 with `AF_UNIX`) at // run time. // // Before GLib 2.72, `<gio/gunixsocketaddress.h>` belonged to the UNIX-specific // GIO interfaces, thus you had to use the `gio-unix-2.0.pc` pkg-config file // when using it. This is no longer necessary since GLib 2.72. type UnixSocketAddress struct { SocketAddress } var xUnixSocketAddressGLibType func() types.GType func UnixSocketAddressGLibType() types.GType { return xUnixSocketAddressGLibType() } func UnixSocketAddressNewFromInternalPtr(ptr uintptr) *UnixSocketAddress { cls := &UnixSocketAddress{} cls.Ptr = ptr return cls } var xNewUnixSocketAddress func(string) uintptr // Creates a new #GUnixSocketAddress for @path. // // To create abstract socket addresses, on systems that support that, // use g_unix_socket_address_new_abstract(). func NewUnixSocketAddress(PathVar string) *UnixSocketAddress { var cls *UnixSocketAddress cret := xNewUnixSocketAddress(PathVar) if cret == 0 { return nil } cls = &UnixSocketAddress{} cls.Ptr = cret return cls } var xNewUnixSocketAddressAbstract func([]byte, int) uintptr // Creates a new %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED // #GUnixSocketAddress for @path. func NewUnixSocketAddressAbstract(PathVar []byte, PathLenVar int) *UnixSocketAddress { var cls *UnixSocketAddress cret := xNewUnixSocketAddressAbstract(PathVar, PathLenVar) if cret == 0 { return nil } cls = &UnixSocketAddress{} cls.Ptr = cret return cls } var xNewUnixSocketAddressWithType func([]byte, int, UnixSocketAddressType) uintptr // Creates a new #GUnixSocketAddress of type @type with name @path. // // If @type is %G_UNIX_SOCKET_ADDRESS_PATH, this is equivalent to // calling g_unix_socket_address_new(). // // If @type is %G_UNIX_SOCKET_ADDRESS_ANONYMOUS, @path and @path_len will be // ignored. // // If @path_type is %G_UNIX_SOCKET_ADDRESS_ABSTRACT, then @path_len // bytes of @path will be copied to the socket's path, and only those // bytes will be considered part of the name. (If @path_len is -1, // then @path is assumed to be NUL-terminated.) For example, if @path // was "test", then calling g_socket_address_get_native_size() on the // returned socket would return 7 (2 bytes of overhead, 1 byte for the // abstract-socket indicator byte, and 4 bytes for the name "test"). // // If @path_type is %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED, then // @path_len bytes of @path will be copied to the socket's path, the // rest of the path will be padded with 0 bytes, and the entire // zero-padded buffer will be considered the name. (As above, if // @path_len is -1, then @path is assumed to be NUL-terminated.) In // this case, g_socket_address_get_native_size() will always return // the full size of a `struct sockaddr_un`, although // g_unix_socket_address_get_path_len() will still return just the // length of @path. // // %G_UNIX_SOCKET_ADDRESS_ABSTRACT is preferred over // %G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED for new programs. Of course, // when connecting to a server created by another process, you must // use the appropriate type corresponding to how that process created // its listening socket. func NewUnixSocketAddressWithType(PathVar []byte, PathLenVar int, TypeVar UnixSocketAddressType) *UnixSocketAddress { var cls *UnixSocketAddress cret := xNewUnixSocketAddressWithType(PathVar, PathLenVar, TypeVar) if cret == 0 { return nil } cls = &UnixSocketAddress{} cls.Ptr = cret return cls } var xUnixSocketAddressGetAddressType func(uintptr) UnixSocketAddressType // Gets @address's type. func (x *UnixSocketAddress) GetAddressType() UnixSocketAddressType { cret := xUnixSocketAddressGetAddressType(x.GoPointer()) return cret } var xUnixSocketAddressGetIsAbstract func(uintptr) bool // Tests if @address is abstract. func (x *UnixSocketAddress) GetIsAbstract() bool { cret := xUnixSocketAddressGetIsAbstract(x.GoPointer()) return cret } var xUnixSocketAddressGetPath func(uintptr) string // Gets @address's path, or for abstract sockets the "name". // // Guaranteed to be zero-terminated, but an abstract socket // may contain embedded zeros, and thus you should use // g_unix_socket_address_get_path_len() to get the true length // of this string. func (x *UnixSocketAddress) GetPath() string { cret := xUnixSocketAddressGetPath(x.GoPointer()) return cret } var xUnixSocketAddressGetPathLen func(uintptr) uint // Gets the length of @address's path. // // For details, see g_unix_socket_address_get_path(). func (x *UnixSocketAddress) GetPathLen() uint { cret := xUnixSocketAddressGetPathLen(x.GoPointer()) return cret } func (c *UnixSocketAddress) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *UnixSocketAddress) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // SetPropertyAbstract sets the "abstract" property. // Whether or not this is an abstract address func (x *UnixSocketAddress) SetPropertyAbstract(value bool) { var v gobject.Value v.Init(gobject.TypeBooleanVal) v.SetBoolean(value) x.SetProperty("abstract", &v) } // GetPropertyAbstract gets the "abstract" property. // Whether or not this is an abstract address func (x *UnixSocketAddress) GetPropertyAbstract() bool { var v gobject.Value x.GetProperty("abstract", &v) return v.GetBoolean() } // SetPropertyPath sets the "path" property. // Unix socket path. func (x *UnixSocketAddress) SetPropertyPath(value string) { var v gobject.Value v.Init(gobject.TypeStringVal) v.SetString(&value) x.SetProperty("path", &v) } // GetPropertyPath gets the "path" property. // Unix socket path. func (x *UnixSocketAddress) GetPropertyPath() string { var v gobject.Value x.GetProperty("path", &v) return v.GetString() } // SetPropertyPathAsArray sets the "path-as-array" property. // Unix socket path, as a byte array. func (x *UnixSocketAddress) SetPropertyPathAsArray(value []byte) { var v gobject.Value v.Init(glib.ByteArrayGLibType()) v.SetBoxed(uintptr(unsafe.Pointer(&value[0]))) x.SetProperty("path-as-array", &v) } // GetPropertyPathAsArray gets the "path-as-array" property. // Unix socket path, as a byte array. func (x *UnixSocketAddress) GetPropertyPathAsArray() []byte { var v gobject.Value x.GetProperty("path-as-array", &v) ptr := v.GetBoxed() if ptr == 0 { return nil } // GByteArray layout: { guint8 *data; guint len; } dataPtr := *(*uintptr)(unsafe.Pointer(ptr)) length := *(*uint32)(unsafe.Pointer(ptr + unsafe.Sizeof(uintptr(0)))) if length == 0 || dataPtr == 0 { return nil } return unsafe.Slice((*byte)(unsafe.Pointer(dataPtr)), length) } // Creates a #GSocketAddressEnumerator for @connectable. func (x *UnixSocketAddress) Enumerate() *SocketAddressEnumerator { var cls *SocketAddressEnumerator cret := XGSocketConnectableEnumerate(x.GoPointer()) if cret == 0 { return nil } cls = &SocketAddressEnumerator{} cls.Ptr = cret return cls } // Creates a #GSocketAddressEnumerator for @connectable that will // return a #GProxyAddress for each of its addresses that you must connect // to via a proxy. // // If @connectable does not implement // g_socket_connectable_proxy_enumerate(), this will fall back to // calling g_socket_connectable_enumerate(). func (x *UnixSocketAddress) ProxyEnumerate() *SocketAddressEnumerator { var cls *SocketAddressEnumerator cret := XGSocketConnectableProxyEnumerate(x.GoPointer()) if cret == 0 { return nil } cls = &SocketAddressEnumerator{} cls.Ptr = cret return cls } // Format a #GSocketConnectable as a string. This is a human-readable format for // use in debugging output, and is not a stable serialization format. It is not // suitable for use in user interfaces as it exposes too much information for a // user. // // If the #GSocketConnectable implementation does not support string formatting, // the implementation’s type name will be returned as a fallback. func (x *UnixSocketAddress) ToString() string { cret := XGSocketConnectableToString(x.GoPointer()) return cret } var xUnixSocketAddressAbstractNamesSupported func() bool // Checks if abstract UNIX domain socket names are supported. func UnixSocketAddressAbstractNamesSupported() bool { cret := xUnixSocketAddressAbstractNamesSupported() return cret } func init() { core.SetPackageName("GIO", "gio-2.0") core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("GIO") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xUnixSocketAddressGLibType, libs, "g_unix_socket_address_get_type") core.PuregoSafeRegister(&xNewUnixSocketAddress, libs, "g_unix_socket_address_new") core.PuregoSafeRegister(&xNewUnixSocketAddressAbstract, libs, "g_unix_socket_address_new_abstract") core.PuregoSafeRegister(&xNewUnixSocketAddressWithType, libs, "g_unix_socket_address_new_with_type") core.PuregoSafeRegister(&xUnixSocketAddressGetAddressType, libs, "g_unix_socket_address_get_address_type") core.PuregoSafeRegister(&xUnixSocketAddressGetIsAbstract, libs, "g_unix_socket_address_get_is_abstract") core.PuregoSafeRegister(&xUnixSocketAddressGetPath, libs, "g_unix_socket_address_get_path") core.PuregoSafeRegister(&xUnixSocketAddressGetPathLen, libs, "g_unix_socket_address_get_path_len") core.PuregoSafeRegister(&xUnixSocketAddressAbstractNamesSupported, libs, "g_unix_socket_address_abstract_names_supported") }