-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresolverevent.go
43 lines (36 loc) · 1.04 KB
/
resolverevent.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// CGo binding for Avahi
//
// Copyright (C) 2024 and up by Alexander Pevzner ([email protected])
// See LICENSE for license terms and conditions
//
// Avahi resolver events
//
//go:build linux || freebsd
package avahi
// #include <avahi-client/client.h>
import "C"
import "fmt"
// ResolverEvent is the CGo representation of the [AvahiResolverEvent].
//
// [AvahiResolverEvent]: https://avahi.org/doxygen/html/defs_8h.html#ae524657615ba2ec3b17613098a3394cf
type ResolverEvent int
// ResolverEvent values:
const (
// Successful resolving
ResolverFound ResolverEvent = C.AVAHI_RESOLVER_FOUND
// Resolving failed due to some reason.
ResolverFailure ResolverEvent = C.AVAHI_RESOLVER_FAILURE
)
// resolverEventNames contains names for known resolver events.
var resolverEventNames = map[ResolverEvent]string{
ResolverFound: "ResolverFound",
ResolverFailure: "ResolverFailure",
}
// String returns a name of ResolverEvent
func (e ResolverEvent) String() string {
n := resolverEventNames[e]
if n == "" {
n = fmt.Sprintf("UNKNOWN %d", int(e))
}
return n
}