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
16// Class structure for #GCredentials.
17type CredentialsClass struct {
18 _ structs.HostLayout
19}
20
21func (x *CredentialsClass) GoPointer() uintptr {
22 return uintptr(unsafe.Pointer(x))
23}
24
25// The `GCredentials` type is a reference-counted wrapper for native
26// credentials.
27//
28// The information in `GCredentials` is typically used for identifying,
29// authenticating and authorizing other processes.
30//
31// Some operating systems supports looking up the credentials of the remote
32// peer of a communication endpoint - see e.g. [method@Gio.Socket.get_credentials].
33//
34// Some operating systems supports securely sending and receiving
35// credentials over a Unix Domain Socket, see [class@Gio.UnixCredentialsMessage],
36// [method@Gio.UnixConnection.send_credentials] and
37// [method@Gio.UnixConnection.receive_credentials] for details.
38//
39// On Linux, the native credential type is a `struct ucred` - see the
40// [`unix(7)` man page](man:unix(7)) for details. This corresponds to
41// `G_CREDENTIALS_TYPE_LINUX_UCRED`.
42//
43// On Apple operating systems (including iOS, tvOS, and macOS), the native credential
44// type is a `struct xucred`. This corresponds to `G_CREDENTIALS_TYPE_APPLE_XUCRED`.
45//
46// On FreeBSD, Debian GNU/kFreeBSD, and GNU/Hurd, the native credential type is a
47// `struct cmsgcred`. This corresponds to `G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED`.
48//
49// On NetBSD, the native credential type is a `struct unpcbid`.
50// This corresponds to `G_CREDENTIALS_TYPE_NETBSD_UNPCBID`.
51//
52// On OpenBSD, the native credential type is a `struct sockpeercred`.
53// This corresponds to `G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED`.
54//
55// On Solaris (including OpenSolaris and its derivatives), the native credential type
56// is a `ucred_t`. This corresponds to `G_CREDENTIALS_TYPE_SOLARIS_UCRED`.
57//
58// Since GLib 2.72, on Windows, the native credentials may contain the PID of a
59// process. This corresponds to `G_CREDENTIALS_TYPE_WIN32_PID`.
60type Credentials struct {
61 gobject.Object
62}
63
64var xCredentialsGLibType func() types.GType
65
66func CredentialsGLibType() types.GType {
67 return xCredentialsGLibType()
68}
69
70func CredentialsNewFromInternalPtr(ptr uintptr) *Credentials {
71 cls := &Credentials{}
72 cls.Ptr = ptr
73 return cls
74}
75
76var xNewCredentials func() uintptr
77
78// Creates a new #GCredentials object with credentials matching the
79// the current process.
80func NewCredentials() *Credentials {
81 var cls *Credentials
82
83 cret := xNewCredentials()
84
85 if cret == 0 {
86 return nil
87 }
88 cls = &Credentials{}
89 cls.Ptr = cret
90 return cls
91}
92
93var xCredentialsGetNative func(uintptr, CredentialsType) uintptr
94
95// Gets a pointer to native credentials of type @native_type from
96// @credentials.
97//
98// It is a programming error (which will cause a warning to be
99// logged) to use this method if there is no #GCredentials support for
100// the OS or if @native_type isn't supported by the OS.
101func (x *Credentials) GetNative(NativeTypeVar CredentialsType) uintptr {
102
103 cret := xCredentialsGetNative(x.GoPointer(), NativeTypeVar)
104 return cret
105}
106
107var xCredentialsGetUnixPid func(uintptr) int
108
109// Tries to get the UNIX process identifier from @credentials. This
110// method is only available on UNIX platforms.
111//
112// This operation can fail if #GCredentials is not supported on the
113// OS or if the native credentials type does not contain information
114// about the UNIX process ID.
115func (x *Credentials) GetUnixPid() (int, error) {
116 var cerr *glib.Error
117
118 cret := xCredentialsGetUnixPid(x.GoPointer())
119 if cerr == nil {
120 return cret, nil
121 }
122 return cret, cerr
123
124}
125
126var xCredentialsGetUnixUser func(uintptr) uint
127
128// Tries to get the UNIX user identifier from @credentials. This
129// method is only available on UNIX platforms.
130//
131// This operation can fail if #GCredentials is not supported on the
132// OS or if the native credentials type does not contain information
133// about the UNIX user.
134func (x *Credentials) GetUnixUser() (uint, error) {
135 var cerr *glib.Error
136
137 cret := xCredentialsGetUnixUser(x.GoPointer())
138 if cerr == nil {
139 return cret, nil
140 }
141 return cret, cerr
142
143}
144
145var xCredentialsIsSameUser func(uintptr, uintptr, **glib.Error) bool
146
147// Checks if @credentials and @other_credentials is the same user.
148//
149// This operation can fail if #GCredentials is not supported on the
150// the OS.
151func (x *Credentials) IsSameUser(OtherCredentialsVar *Credentials) (bool, error) {
152 var cerr *glib.Error
153
154 cret := xCredentialsIsSameUser(x.GoPointer(), OtherCredentialsVar.GoPointer(), &cerr)
155 if cerr == nil {
156 return cret, nil
157 }
158 return cret, cerr
159
160}
161
162var xCredentialsSetNative func(uintptr, CredentialsType, uintptr)
163
164// Copies the native credentials of type @native_type from @native
165// into @credentials.
166//
167// It is a programming error (which will cause a warning to be
168// logged) to use this method if there is no #GCredentials support for
169// the OS or if @native_type isn't supported by the OS.
170func (x *Credentials) SetNative(NativeTypeVar CredentialsType, NativeVar uintptr) {
171
172 xCredentialsSetNative(x.GoPointer(), NativeTypeVar, NativeVar)
173
174}
175
176var xCredentialsSetUnixUser func(uintptr, uint, **glib.Error) bool
177
178// Tries to set the UNIX user identifier on @credentials. This method
179// is only available on UNIX platforms.
180//
181// This operation can fail if #GCredentials is not supported on the
182// OS or if the native credentials type does not contain information
183// about the UNIX user. It can also fail if the OS does not allow the
184// use of "spoofed" credentials.
185func (x *Credentials) SetUnixUser(UidVar uint) (bool, error) {
186 var cerr *glib.Error
187
188 cret := xCredentialsSetUnixUser(x.GoPointer(), UidVar, &cerr)
189 if cerr == nil {
190 return cret, nil
191 }
192 return cret, cerr
193
194}
195
196var xCredentialsToString func(uintptr) string
197
198// Creates a human-readable textual representation of @credentials
199// that can be used in logging and debug messages. The format of the
200// returned string may change in future GLib release.
201func (x *Credentials) ToString() string {
202
203 cret := xCredentialsToString(x.GoPointer())
204 return cret
205}
206
207func (c *Credentials) GoPointer() uintptr {
208 if c == nil {
209 return 0
210 }
211 return c.Ptr
212}
213
214func (c *Credentials) SetGoPointer(ptr uintptr) {
215 c.Ptr = ptr
216}
217
218func init() {
219 core.SetPackageName("GIO", "gio-2.0")
220 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
221 var libs []uintptr
222 for _, libPath := range core.GetPaths("GIO") {
223 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
224 if err != nil {
225 panic(err)
226 }
227 libs = append(libs, lib)
228 }
229
230 core.PuregoSafeRegister(&xCredentialsGLibType, libs, "g_credentials_get_type")
231
232 core.PuregoSafeRegister(&xNewCredentials, libs, "g_credentials_new")
233
234 core.PuregoSafeRegister(&xCredentialsGetNative, libs, "g_credentials_get_native")
235 core.PuregoSafeRegister(&xCredentialsGetUnixPid, libs, "g_credentials_get_unix_pid")
236 core.PuregoSafeRegister(&xCredentialsGetUnixUser, libs, "g_credentials_get_unix_user")
237 core.PuregoSafeRegister(&xCredentialsIsSameUser, libs, "g_credentials_is_same_user")
238 core.PuregoSafeRegister(&xCredentialsSetNative, libs, "g_credentials_set_native")
239 core.PuregoSafeRegister(&xCredentialsSetUnixUser, libs, "g_credentials_set_unix_user")
240 core.PuregoSafeRegister(&xCredentialsToString, libs, "g_credentials_to_string")
241
242}