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/gobject"
12 "github.com/bnema/puregotk/v4/gobject/types"
13)
14
15type InetAddressClass struct {
16 _ structs.HostLayout
17
18 ParentClass gobject.ObjectClass
19
20 xToString uintptr
21
22 xToBytes uintptr
23}
24
25func (x *InetAddressClass) GoPointer() uintptr {
26 return uintptr(unsafe.Pointer(x))
27}
28
29// OverrideToString sets the "to_string" callback function.
30func (x *InetAddressClass) OverrideToString(cb func(*InetAddress) string) {
31 if cb == nil {
32 x.xToString = 0
33 } else {
34 x.xToString = purego.NewCallback(func(AddressVarp uintptr) string {
35 return cb(InetAddressNewFromInternalPtr(AddressVarp))
36 })
37 }
38}
39
40// GetToString gets the "to_string" callback function.
41func (x *InetAddressClass) GetToString() func(*InetAddress) string {
42 if x.xToString == 0 {
43 return nil
44 }
45 var rawCallback func(AddressVarp uintptr) string
46 purego.RegisterFunc(&rawCallback, x.xToString)
47 return func(AddressVar *InetAddress) string {
48 return rawCallback(AddressVar.GoPointer())
49 }
50}
51
52// OverrideToBytes sets the "to_bytes" callback function.
53func (x *InetAddressClass) OverrideToBytes(cb func(*InetAddress) byte) {
54 if cb == nil {
55 x.xToBytes = 0
56 } else {
57 x.xToBytes = purego.NewCallback(func(AddressVarp uintptr) byte {
58 return cb(InetAddressNewFromInternalPtr(AddressVarp))
59 })
60 }
61}
62
63// GetToBytes gets the "to_bytes" callback function.
64func (x *InetAddressClass) GetToBytes() func(*InetAddress) byte {
65 if x.xToBytes == 0 {
66 return nil
67 }
68 var rawCallback func(AddressVarp uintptr) byte
69 purego.RegisterFunc(&rawCallback, x.xToBytes)
70 return func(AddressVar *InetAddress) byte {
71 return rawCallback(AddressVar.GoPointer())
72 }
73}
74
75type InetAddressPrivate struct {
76 _ structs.HostLayout
77}
78
79func (x *InetAddressPrivate) GoPointer() uintptr {
80 return uintptr(unsafe.Pointer(x))
81}
82
83// `GInetAddress` represents an IPv4 or IPv6 internet address. Use
84// [method@Gio.Resolver.lookup_by_name] or
85// [method@Gio.Resolver.lookup_by_name_async] to look up the `GInetAddress` for
86// a hostname. Use [method@Gio.Resolver.lookup_by_address] or
87// [method@Gio.Resolver.lookup_by_address_async] to look up the hostname for a
88// `GInetAddress`.
89//
90// To actually connect to a remote host, you will need a
91// [class@Gio.InetSocketAddress] (which includes a `GInetAddress` as well as a
92// port number).
93type InetAddress struct {
94 gobject.Object
95}
96
97var xInetAddressGLibType func() types.GType
98
99func InetAddressGLibType() types.GType {
100 return xInetAddressGLibType()
101}
102
103func InetAddressNewFromInternalPtr(ptr uintptr) *InetAddress {
104 cls := &InetAddress{}
105 cls.Ptr = ptr
106 return cls
107}
108
109var xNewInetAddressAny func(SocketFamily) uintptr
110
111// Creates a #GInetAddress for the "any" address (unassigned/"don't
112// care") for @family.
113func NewInetAddressAny(FamilyVar SocketFamily) *InetAddress {
114 var cls *InetAddress
115
116 cret := xNewInetAddressAny(FamilyVar)
117
118 if cret == 0 {
119 return nil
120 }
121 cls = &InetAddress{}
122 cls.Ptr = cret
123 return cls
124}
125
126var xNewInetAddressFromBytes func([]byte, SocketFamily) uintptr
127
128// Creates a new #GInetAddress from the given @family and @bytes.
129// @bytes should be 4 bytes for %G_SOCKET_FAMILY_IPV4 and 16 bytes for
130// %G_SOCKET_FAMILY_IPV6.
131func NewInetAddressFromBytes(BytesVar []byte, FamilyVar SocketFamily) *InetAddress {
132 var cls *InetAddress
133
134 cret := xNewInetAddressFromBytes(BytesVar, FamilyVar)
135
136 if cret == 0 {
137 return nil
138 }
139 cls = &InetAddress{}
140 cls.Ptr = cret
141 return cls
142}
143
144var xNewInetAddressFromBytesWithIpv6Info func([]byte, SocketFamily, uint32, uint32) uintptr
145
146// Creates a new [class@Gio.InetAddress] from the given @family, @bytes
147// and @scope_id.
148//
149// @bytes must be 4 bytes for [enum@Gio.SocketFamily.IPV4] and 16 bytes for
150// [enum@Gio.SocketFamily.IPV6].
151func NewInetAddressFromBytesWithIpv6Info(BytesVar []byte, FamilyVar SocketFamily, FlowinfoVar uint32, ScopeIdVar uint32) *InetAddress {
152 var cls *InetAddress
153
154 cret := xNewInetAddressFromBytesWithIpv6Info(BytesVar, FamilyVar, FlowinfoVar, ScopeIdVar)
155
156 if cret == 0 {
157 return nil
158 }
159 cls = &InetAddress{}
160 cls.Ptr = cret
161 return cls
162}
163
164var xNewInetAddressFromString func(string) uintptr
165
166// Parses @string as an IP address and creates a new #GInetAddress.
167//
168// If @address is an IPv6 address, it can also contain a scope ID
169// (separated from the address by a `%`). Note that currently this
170// behavior is platform specific. This may change in a future release.
171func NewInetAddressFromString(StringVar string) *InetAddress {
172 var cls *InetAddress
173
174 cret := xNewInetAddressFromString(StringVar)
175
176 if cret == 0 {
177 return nil
178 }
179 cls = &InetAddress{}
180 cls.Ptr = cret
181 return cls
182}
183
184var xNewInetAddressLoopback func(SocketFamily) uintptr
185
186// Creates a #GInetAddress for the loopback address for @family.
187func NewInetAddressLoopback(FamilyVar SocketFamily) *InetAddress {
188 var cls *InetAddress
189
190 cret := xNewInetAddressLoopback(FamilyVar)
191
192 if cret == 0 {
193 return nil
194 }
195 cls = &InetAddress{}
196 cls.Ptr = cret
197 return cls
198}
199
200var xInetAddressEqual func(uintptr, uintptr) bool
201
202// Checks if two #GInetAddress instances are equal, e.g. the same address.
203func (x *InetAddress) Equal(OtherAddressVar *InetAddress) bool {
204
205 cret := xInetAddressEqual(x.GoPointer(), OtherAddressVar.GoPointer())
206 return cret
207}
208
209var xInetAddressGetFamily func(uintptr) SocketFamily
210
211// Gets @address's family
212func (x *InetAddress) GetFamily() SocketFamily {
213
214 cret := xInetAddressGetFamily(x.GoPointer())
215 return cret
216}
217
218var xInetAddressGetFlowinfo func(uintptr) uint32
219
220// Gets the value of [property@Gio.InetAddress:flowinfo].
221func (x *InetAddress) GetFlowinfo() uint32 {
222
223 cret := xInetAddressGetFlowinfo(x.GoPointer())
224 return cret
225}
226
227var xInetAddressGetIsAny func(uintptr) bool
228
229// Tests whether @address is the "any" address for its family.
230func (x *InetAddress) GetIsAny() bool {
231
232 cret := xInetAddressGetIsAny(x.GoPointer())
233 return cret
234}
235
236var xInetAddressGetIsLinkLocal func(uintptr) bool
237
238// Tests whether @address is a link-local address (that is, if it
239// identifies a host on a local network that is not connected to the
240// Internet).
241func (x *InetAddress) GetIsLinkLocal() bool {
242
243 cret := xInetAddressGetIsLinkLocal(x.GoPointer())
244 return cret
245}
246
247var xInetAddressGetIsLoopback func(uintptr) bool
248
249// Tests whether @address is the loopback address for its family.
250func (x *InetAddress) GetIsLoopback() bool {
251
252 cret := xInetAddressGetIsLoopback(x.GoPointer())
253 return cret
254}
255
256var xInetAddressGetIsMcGlobal func(uintptr) bool
257
258// Tests whether @address is a global multicast address.
259func (x *InetAddress) GetIsMcGlobal() bool {
260
261 cret := xInetAddressGetIsMcGlobal(x.GoPointer())
262 return cret
263}
264
265var xInetAddressGetIsMcLinkLocal func(uintptr) bool
266
267// Tests whether @address is a link-local multicast address.
268func (x *InetAddress) GetIsMcLinkLocal() bool {
269
270 cret := xInetAddressGetIsMcLinkLocal(x.GoPointer())
271 return cret
272}
273
274var xInetAddressGetIsMcNodeLocal func(uintptr) bool
275
276// Tests whether @address is a node-local multicast address.
277func (x *InetAddress) GetIsMcNodeLocal() bool {
278
279 cret := xInetAddressGetIsMcNodeLocal(x.GoPointer())
280 return cret
281}
282
283var xInetAddressGetIsMcOrgLocal func(uintptr) bool
284
285// Tests whether @address is an organization-local multicast address.
286func (x *InetAddress) GetIsMcOrgLocal() bool {
287
288 cret := xInetAddressGetIsMcOrgLocal(x.GoPointer())
289 return cret
290}
291
292var xInetAddressGetIsMcSiteLocal func(uintptr) bool
293
294// Tests whether @address is a site-local multicast address.
295func (x *InetAddress) GetIsMcSiteLocal() bool {
296
297 cret := xInetAddressGetIsMcSiteLocal(x.GoPointer())
298 return cret
299}
300
301var xInetAddressGetIsMulticast func(uintptr) bool
302
303// Tests whether @address is a multicast address.
304func (x *InetAddress) GetIsMulticast() bool {
305
306 cret := xInetAddressGetIsMulticast(x.GoPointer())
307 return cret
308}
309
310var xInetAddressGetIsSiteLocal func(uintptr) bool
311
312// Tests whether @address is a site-local address such as 10.0.0.1
313// (that is, the address identifies a host on a local network that can
314// not be reached directly from the Internet, but which may have
315// outgoing Internet connectivity via a NAT or firewall).
316func (x *InetAddress) GetIsSiteLocal() bool {
317
318 cret := xInetAddressGetIsSiteLocal(x.GoPointer())
319 return cret
320}
321
322var xInetAddressGetNativeSize func(uintptr) uint
323
324// Gets the size of the native raw binary address for @address. This
325// is the size of the data that you get from g_inet_address_to_bytes().
326func (x *InetAddress) GetNativeSize() uint {
327
328 cret := xInetAddressGetNativeSize(x.GoPointer())
329 return cret
330}
331
332var xInetAddressGetScopeId func(uintptr) uint32
333
334// Gets the value of [property@Gio.InetAddress:scope-id].
335func (x *InetAddress) GetScopeId() uint32 {
336
337 cret := xInetAddressGetScopeId(x.GoPointer())
338 return cret
339}
340
341var xInetAddressToBytes func(uintptr) byte
342
343// Gets the raw binary address data from @address.
344func (x *InetAddress) ToBytes() byte {
345
346 cret := xInetAddressToBytes(x.GoPointer())
347 return cret
348}
349
350var xInetAddressToString func(uintptr) string
351
352// Converts @address to string form.
353func (x *InetAddress) ToString() string {
354
355 cret := xInetAddressToString(x.GoPointer())
356 return cret
357}
358
359func (c *InetAddress) GoPointer() uintptr {
360 if c == nil {
361 return 0
362 }
363 return c.Ptr
364}
365
366func (c *InetAddress) SetGoPointer(ptr uintptr) {
367 c.Ptr = ptr
368}
369
370// SetPropertyBytes sets the "bytes" property.
371// The raw address data.
372func (x *InetAddress) SetPropertyBytes(value uintptr) {
373 var v gobject.Value
374 v.Init(gobject.TypePointerVal)
375 v.SetPointer(value)
376 x.SetProperty("bytes", &v)
377}
378
379// GetPropertyBytes gets the "bytes" property.
380// The raw address data.
381func (x *InetAddress) GetPropertyBytes() uintptr {
382 var v gobject.Value
383 x.GetProperty("bytes", &v)
384 return v.GetPointer()
385}
386
387// SetPropertyFlowinfo sets the "flowinfo" property.
388// The flowinfo for an IPv6 address.
389// See [method@Gio.InetAddress.get_flowinfo].
390func (x *InetAddress) SetPropertyFlowinfo(value uint) {
391 var v gobject.Value
392 v.Init(gobject.TypeUintVal)
393 v.SetUint(value)
394 x.SetProperty("flowinfo", &v)
395}
396
397// GetPropertyFlowinfo gets the "flowinfo" property.
398// The flowinfo for an IPv6 address.
399// See [method@Gio.InetAddress.get_flowinfo].
400func (x *InetAddress) GetPropertyFlowinfo() uint {
401 var v gobject.Value
402 x.GetProperty("flowinfo", &v)
403 return v.GetUint()
404}
405
406// GetPropertyIsAny gets the "is-any" property.
407// Whether this is the "any" address for its family.
408// See g_inet_address_get_is_any().
409func (x *InetAddress) GetPropertyIsAny() bool {
410 var v gobject.Value
411 x.GetProperty("is-any", &v)
412 return v.GetBoolean()
413}
414
415// GetPropertyIsLinkLocal gets the "is-link-local" property.
416// Whether this is a link-local address.
417// See g_inet_address_get_is_link_local().
418func (x *InetAddress) GetPropertyIsLinkLocal() bool {
419 var v gobject.Value
420 x.GetProperty("is-link-local", &v)
421 return v.GetBoolean()
422}
423
424// GetPropertyIsLoopback gets the "is-loopback" property.
425// Whether this is the loopback address for its family.
426// See g_inet_address_get_is_loopback().
427func (x *InetAddress) GetPropertyIsLoopback() bool {
428 var v gobject.Value
429 x.GetProperty("is-loopback", &v)
430 return v.GetBoolean()
431}
432
433// GetPropertyIsMcGlobal gets the "is-mc-global" property.
434// Whether this is a global multicast address.
435// See g_inet_address_get_is_mc_global().
436func (x *InetAddress) GetPropertyIsMcGlobal() bool {
437 var v gobject.Value
438 x.GetProperty("is-mc-global", &v)
439 return v.GetBoolean()
440}
441
442// GetPropertyIsMcLinkLocal gets the "is-mc-link-local" property.
443// Whether this is a link-local multicast address.
444// See g_inet_address_get_is_mc_link_local().
445func (x *InetAddress) GetPropertyIsMcLinkLocal() bool {
446 var v gobject.Value
447 x.GetProperty("is-mc-link-local", &v)
448 return v.GetBoolean()
449}
450
451// GetPropertyIsMcNodeLocal gets the "is-mc-node-local" property.
452// Whether this is a node-local multicast address.
453// See g_inet_address_get_is_mc_node_local().
454func (x *InetAddress) GetPropertyIsMcNodeLocal() bool {
455 var v gobject.Value
456 x.GetProperty("is-mc-node-local", &v)
457 return v.GetBoolean()
458}
459
460// GetPropertyIsMcOrgLocal gets the "is-mc-org-local" property.
461// Whether this is an organization-local multicast address.
462// See g_inet_address_get_is_mc_org_local().
463func (x *InetAddress) GetPropertyIsMcOrgLocal() bool {
464 var v gobject.Value
465 x.GetProperty("is-mc-org-local", &v)
466 return v.GetBoolean()
467}
468
469// GetPropertyIsMcSiteLocal gets the "is-mc-site-local" property.
470// Whether this is a site-local multicast address.
471// See g_inet_address_get_is_mc_site_local().
472func (x *InetAddress) GetPropertyIsMcSiteLocal() bool {
473 var v gobject.Value
474 x.GetProperty("is-mc-site-local", &v)
475 return v.GetBoolean()
476}
477
478// GetPropertyIsMulticast gets the "is-multicast" property.
479// Whether this is a multicast address.
480// See g_inet_address_get_is_multicast().
481func (x *InetAddress) GetPropertyIsMulticast() bool {
482 var v gobject.Value
483 x.GetProperty("is-multicast", &v)
484 return v.GetBoolean()
485}
486
487// GetPropertyIsSiteLocal gets the "is-site-local" property.
488// Whether this is a site-local address.
489// See g_inet_address_get_is_loopback().
490func (x *InetAddress) GetPropertyIsSiteLocal() bool {
491 var v gobject.Value
492 x.GetProperty("is-site-local", &v)
493 return v.GetBoolean()
494}
495
496// SetPropertyScopeId sets the "scope-id" property.
497// The scope-id for an IPv6 address.
498// See [method@Gio.InetAddress.get_scope_id].
499func (x *InetAddress) SetPropertyScopeId(value uint) {
500 var v gobject.Value
501 v.Init(gobject.TypeUintVal)
502 v.SetUint(value)
503 x.SetProperty("scope-id", &v)
504}
505
506// GetPropertyScopeId gets the "scope-id" property.
507// The scope-id for an IPv6 address.
508// See [method@Gio.InetAddress.get_scope_id].
509func (x *InetAddress) GetPropertyScopeId() uint {
510 var v gobject.Value
511 x.GetProperty("scope-id", &v)
512 return v.GetUint()
513}
514
515func init() {
516 core.SetPackageName("GIO", "gio-2.0")
517 core.SetSharedLibraries("GIO", []string{"libgio-2.0.so.0"})
518 var libs []uintptr
519 for _, libPath := range core.GetPaths("GIO") {
520 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
521 if err != nil {
522 panic(err)
523 }
524 libs = append(libs, lib)
525 }
526
527 core.PuregoSafeRegister(&xInetAddressGLibType, libs, "g_inet_address_get_type")
528
529 core.PuregoSafeRegister(&xNewInetAddressAny, libs, "g_inet_address_new_any")
530 core.PuregoSafeRegister(&xNewInetAddressFromBytes, libs, "g_inet_address_new_from_bytes")
531 core.PuregoSafeRegister(&xNewInetAddressFromBytesWithIpv6Info, libs, "g_inet_address_new_from_bytes_with_ipv6_info")
532 core.PuregoSafeRegister(&xNewInetAddressFromString, libs, "g_inet_address_new_from_string")
533 core.PuregoSafeRegister(&xNewInetAddressLoopback, libs, "g_inet_address_new_loopback")
534
535 core.PuregoSafeRegister(&xInetAddressEqual, libs, "g_inet_address_equal")
536 core.PuregoSafeRegister(&xInetAddressGetFamily, libs, "g_inet_address_get_family")
537 core.PuregoSafeRegister(&xInetAddressGetFlowinfo, libs, "g_inet_address_get_flowinfo")
538 core.PuregoSafeRegister(&xInetAddressGetIsAny, libs, "g_inet_address_get_is_any")
539 core.PuregoSafeRegister(&xInetAddressGetIsLinkLocal, libs, "g_inet_address_get_is_link_local")
540 core.PuregoSafeRegister(&xInetAddressGetIsLoopback, libs, "g_inet_address_get_is_loopback")
541 core.PuregoSafeRegister(&xInetAddressGetIsMcGlobal, libs, "g_inet_address_get_is_mc_global")
542 core.PuregoSafeRegister(&xInetAddressGetIsMcLinkLocal, libs, "g_inet_address_get_is_mc_link_local")
543 core.PuregoSafeRegister(&xInetAddressGetIsMcNodeLocal, libs, "g_inet_address_get_is_mc_node_local")
544 core.PuregoSafeRegister(&xInetAddressGetIsMcOrgLocal, libs, "g_inet_address_get_is_mc_org_local")
545 core.PuregoSafeRegister(&xInetAddressGetIsMcSiteLocal, libs, "g_inet_address_get_is_mc_site_local")
546 core.PuregoSafeRegister(&xInetAddressGetIsMulticast, libs, "g_inet_address_get_is_multicast")
547 core.PuregoSafeRegister(&xInetAddressGetIsSiteLocal, libs, "g_inet_address_get_is_site_local")
548 core.PuregoSafeRegister(&xInetAddressGetNativeSize, libs, "g_inet_address_get_native_size")
549 core.PuregoSafeRegister(&xInetAddressGetScopeId, libs, "g_inet_address_get_scope_id")
550 core.PuregoSafeRegister(&xInetAddressToBytes, libs, "g_inet_address_to_bytes")
551 core.PuregoSafeRegister(&xInetAddressToString, libs, "g_inet_address_to_string")
552
553}