1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5 "github.com/ebitengine/purego"
6
7 "github.com/bnema/puregotk/pkg/core"
8)
9
10var xEnvironGetenv func([]string, string) string
11
12// Returns the value of the environment variable @variable in the
13// provided list @envp.
14func EnvironGetenv(EnvpVar []string, VariableVar string) string {
15
16 cret := xEnvironGetenv(EnvpVar, VariableVar)
17
18 return cret
19}
20
21var xEnvironSetenv func([]string, string, string, bool) []string
22
23// Sets the environment variable @variable in the provided list
24// @envp to @value.
25func EnvironSetenv(EnvpVar []string, VariableVar string, ValueVar string, OverwriteVar bool) []string {
26
27 cret := xEnvironSetenv(EnvpVar, VariableVar, ValueVar, OverwriteVar)
28
29 return cret
30}
31
32var xEnvironUnsetenv func([]string, string) []string
33
34// Removes the environment variable @variable from the provided
35// environment @envp.
36func EnvironUnsetenv(EnvpVar []string, VariableVar string) []string {
37
38 cret := xEnvironUnsetenv(EnvpVar, VariableVar)
39
40 return cret
41}
42
43var xGetEnviron func() []string
44
45// Gets the list of environment variables for the current process.
46//
47// The list is %NULL terminated and each item in the list is of the
48// form 'NAME=VALUE'.
49//
50// This is equivalent to direct access to the 'environ' global variable,
51// except portable.
52//
53// The return value is freshly allocated and it should be freed with
54// g_strfreev() when it is no longer needed.
55func GetEnviron() []string {
56
57 cret := xGetEnviron()
58
59 return cret
60}
61
62var xGetenv func(string) string
63
64// Returns the value of an environment variable.
65//
66// On UNIX, the name and value are byte strings which might or might not
67// be in some consistent character set and encoding. On Windows, they are
68// in UTF-8.
69// On Windows, in case the environment variable's value contains
70// references to other environment variables, they are expanded.
71func Getenv(VariableVar string) string {
72
73 cret := xGetenv(VariableVar)
74
75 return cret
76}
77
78var xListenv func() []string
79
80// Gets the names of all variables set in the environment.
81//
82// Programs that want to be portable to Windows should typically use
83// this function and g_getenv() instead of using the environ array
84// from the C library directly. On Windows, the strings in the environ
85// array are in system codepage encoding, while in most of the typical
86// use cases for environment variables in GLib-using programs you want
87// the UTF-8 encoding that this function and g_getenv() provide.
88func Listenv() []string {
89
90 cret := xListenv()
91
92 return cret
93}
94
95var xSetenv func(string, string, bool) bool
96
97// Sets an environment variable. On UNIX, both the variable's name and
98// value can be arbitrary byte strings, except that the variable's name
99// cannot contain '='. On Windows, they should be in UTF-8.
100//
101// Note that on some systems, when variables are overwritten, the memory
102// used for the previous variables and its value isn't reclaimed.
103//
104// You should be mindful of the fact that environment variable handling
105// in UNIX is not thread-safe, and your program may crash if one thread
106// calls g_setenv() while another thread is calling getenv(). (And note
107// that many functions, such as gettext(), call getenv() internally.)
108// This function is only safe to use at the very start of your program,
109// before creating any other threads (or creating objects that create
110// worker threads of their own).
111//
112// If you need to set up the environment for a child process, you can
113// use g_get_environ() to get an environment array, modify that with
114// g_environ_setenv() and g_environ_unsetenv(), and then pass that
115// array directly to execvpe(), g_spawn_async(), or the like.
116func Setenv(VariableVar string, ValueVar string, OverwriteVar bool) bool {
117
118 cret := xSetenv(VariableVar, ValueVar, OverwriteVar)
119
120 return cret
121}
122
123var xUnsetenv func(string)
124
125// Removes an environment variable from the environment.
126//
127// Note that on some systems, when variables are overwritten, the
128// memory used for the previous variables and its value isn't reclaimed.
129//
130// You should be mindful of the fact that environment variable handling
131// in UNIX is not thread-safe, and your program may crash if one thread
132// calls g_unsetenv() while another thread is calling getenv(). (And note
133// that many functions, such as gettext(), call getenv() internally.) This
134// function is only safe to use at the very start of your program, before
135// creating any other threads (or creating objects that create worker
136// threads of their own).
137//
138// If you need to set up the environment for a child process, you can
139// use g_get_environ() to get an environment array, modify that with
140// g_environ_setenv() and g_environ_unsetenv(), and then pass that
141// array directly to execvpe(), g_spawn_async(), or the like.
142func Unsetenv(VariableVar string) {
143
144 xUnsetenv(VariableVar)
145
146}
147
148func init() {
149 core.SetPackageName("GLIB", "glib-2.0")
150 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
151 var libs []uintptr
152 for _, libPath := range core.GetPaths("GLIB") {
153 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
154 if err != nil {
155 panic(err)
156 }
157 libs = append(libs, lib)
158 }
159
160 core.PuregoSafeRegister(&xEnvironGetenv, libs, "g_environ_getenv")
161 core.PuregoSafeRegister(&xEnvironSetenv, libs, "g_environ_setenv")
162 core.PuregoSafeRegister(&xEnvironUnsetenv, libs, "g_environ_unsetenv")
163 core.PuregoSafeRegister(&xGetEnviron, libs, "g_get_environ")
164 core.PuregoSafeRegister(&xGetenv, libs, "g_getenv")
165 core.PuregoSafeRegister(&xListenv, libs, "g_listenv")
166 core.PuregoSafeRegister(&xSetenv, libs, "g_setenv")
167 core.PuregoSafeRegister(&xUnsetenv, libs, "g_unsetenv")
168
169}