File: %40m..%40slib%40sstd%40sprivate%40swin_setenv.nim.c

package info (click to toggle)
nim 1.6.10-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,165,312 kB
  • sloc: sh: 20,999; ansic: 1,716; makefile: 958; python: 461; sql: 298; asm: 141; xml: 13
file content (284 lines) | stat: -rw-r--r-- 8,568 bytes parent folder | download
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/* Generated by Nim Compiler v1.6.10 */
#define NIM_INTBITS 32

#include "nimbase.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
#define nimfr_(x, y)
#define nimln_(x, y)
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct tySequence__9aKpvUh0ca6Bp9cKAwrowqUg tySequence__9aKpvUh0ca6Bp9cKAwrowqUg;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A;
typedef NU8 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ;
typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p);
struct TNimType {
NI size;
NI align;
tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A kind;
tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ;
struct TNimNode {
tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef NI16 tyUncheckedArray__Tyd4y3haUOOHTj71TPIRag[1];
typedef N_STDCALL_PTR(NI32, tyProc__3pVglHKolpBa6UoJifpHkA) (NCSTRING lpName, NCSTRING lpValue);
struct tySequence__9aKpvUh0ca6Bp9cKAwrowqUg {
  TGenericSeq Sup;
  NI16 data[SEQ_DECL_SIZE];
};
static N_INLINE(NIM_BOOL, eqeq___system_7778)(NCSTRING x, NCSTRING y);
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringDesc* s);
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src);
static N_INLINE(void, copyMem__system_1727)(void* dest, void* source, NI size);
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, rawNewString)(NI space);
N_LIB_PRIVATE N_NIMCALL(tySequence__9aKpvUh0ca6Bp9cKAwrowqUg*, newSeq__stdZprivateZwin95setenv_36)(NI len);
static N_NIMCALL(void, Marker_tySequence__9aKpvUh0ca6Bp9cKAwrowqUg)(void* p, NI op);
N_LIB_PRIVATE N_NIMCALL(void*, nimLoadLibrary)(NimStringDesc* path);
N_LIB_PRIVATE N_NIMCALL(void, nimLoadLibraryError)(NimStringDesc* path);
N_LIB_PRIVATE N_NIMCALL(void*, nimGetProcAddr)(void* lib, NCSTRING name);
STRING_LITERAL(TM__UOYsq9cbb0VE8vr3Xt181HA_2, "=", 1);
STRING_LITERAL(TM__UOYsq9cbb0VE8vr3Xt181HA_3, "=  ", 3);
extern TNimType NTIint4954__kDPg4wXyR8DDyA0MeEjIsw_;
N_LIB_PRIVATE TNimType NTIseqLutf4954charT__9aKpvUh0ca6Bp9cKAwrowqUg_;
STRING_LITERAL(TM__UOYsq9cbb0VE8vr3Xt181HA_6, "kernel32", 8);
STRING_LITERAL(TM__UOYsq9cbb0VE8vr3Xt181HA_7, "kernel32", 8);
extern wchar_t** _wenviron;
static void* TM__UOYsq9cbb0VE8vr3Xt181HA_4;
tyProc__3pVglHKolpBa6UoJifpHkA Dl_1426063362_;
static N_INLINE(NIM_BOOL, eqeq___system_7778)(NCSTRING x, NCSTRING y) {
	NIM_BOOL result;
	result = (NIM_BOOL)0;
	{
		if (!(((void*) (x)) == ((void*) (y)))) goto LA3_;
		result = NIM_TRUE;
	}
	goto LA1_;
	LA3_: ;
	{
		NIM_BOOL T6_;
		T6_ = (NIM_BOOL)0;
		T6_ = (x == 0);
		if (T6_) goto LA7_;
		T6_ = (y == 0);
		LA7_: ;
		if (!T6_) goto LA8_;
		result = NIM_FALSE;
	}
	goto LA1_;
	LA8_: ;
	{
		int T11_;
		T11_ = (int)0;
		T11_ = strcmp(x, y);
		result = (T11_ == ((NI32) 0));
	}
	LA1_: ;
	return result;
}
static N_INLINE(NCSTRING, nimToCStringConv)(NimStringDesc* s) {
	NCSTRING result;
	result = (NCSTRING)0;
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = (s == ((NimStringDesc*) NIM_NIL));
		if (T3_) goto LA4_;
		T3_ = ((*s).Sup.len == ((NI) 0));
		LA4_: ;
		if (!T3_) goto LA5_;
		result = "";
	}
	goto LA1_;
	LA5_: ;
	{
		result = ((NCSTRING) ((*s).data));
	}
	LA1_: ;
	return result;
}
static N_INLINE(void, nimCopyMem)(void* dest, void* source, NI size) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memcpy(dest, source, ((size_t) (size)));
}
static N_INLINE(void, copyMem__system_1727)(void* dest, void* source, NI size) {
	nimCopyMem(dest, source, size);
}
static N_INLINE(void, appendString)(NimStringDesc* dest, NimStringDesc* src) {
	{
		if (!!((src == ((NimStringDesc*) NIM_NIL)))) goto LA3_;
		copyMem__system_1727(((void*) ((&(*dest).data[(*dest).Sup.len]))), ((void*) ((*src).data)), ((NI) ((NI)((*src).Sup.len + ((NI) 1)))));
		(*dest).Sup.len += (*src).Sup.len;
	}
	LA3_: ;
}
static N_NIMCALL(void, Marker_tySequence__9aKpvUh0ca6Bp9cKAwrowqUg)(void* p, NI op) {
	tySequence__9aKpvUh0ca6Bp9cKAwrowqUg* a;
	NI T1_;
	a = (tySequence__9aKpvUh0ca6Bp9cKAwrowqUg*)p;
	T1_ = (NI)0;
}
N_LIB_PRIVATE N_NIMCALL(int, setEnvImpl__stdZprivateZwin95setenv_17)(NimStringDesc* name, NimStringDesc* value, int overwrite) {
	int result;
	NimStringDesc* envstring_2;
	NimStringDesc* T18_;
	NCSTRING s;
{	result = (int)0;
	{
		NIM_BOOL T3_;
		NCSTRING T5_;
		NIM_BOOL T6_;
		T3_ = (NIM_BOOL)0;
		T3_ = (overwrite == ((NI32) 0));
		if (!(T3_)) goto LA4_;
		T5_ = (NCSTRING)0;
		T5_ = getenv(nimToCStringConv(name));
		T6_ = (NIM_BOOL)0;
		T6_ = eqeq___system_7778(T5_, ((NCSTRING) NIM_NIL));
		T3_ = !(T6_);
		LA4_: ;
		if (!T3_) goto LA7_;
		result = ((int) 0);
		goto BeforeRet_;
	}
	LA7_: ;
	{
		NimStringDesc* envstring;
		NimStringDesc* T13_;
		int e;
		if (!!(((value ? value->Sup.len : 0) == 0))) goto LA11_;
		T13_ = NIM_NIL;
		T13_ = rawNewString((name ? name->Sup.len : 0) + (value ? value->Sup.len : 0) + 1);
appendString(T13_, name);
appendString(T13_, ((NimStringDesc*) &TM__UOYsq9cbb0VE8vr3Xt181HA_2));
appendString(T13_, value);
		envstring = T13_;
		e = _putenv(nimToCStringConv(envstring));
		{
			if (!!((e == ((NI32) 0)))) goto LA16_;
			errno = ((int) 22);
			result = ((int) -1);
			goto BeforeRet_;
		}
		LA16_: ;
		result = ((int) 0);
		goto BeforeRet_;
	}
	LA11_: ;
	T18_ = NIM_NIL;
	T18_ = rawNewString((name ? name->Sup.len : 0) + 3);
appendString(T18_, name);
appendString(T18_, ((NimStringDesc*) &TM__UOYsq9cbb0VE8vr3Xt181HA_3));
	envstring_2 = T18_;
	{
		int T21_;
		T21_ = (int)0;
		T21_ = _putenv(nimToCStringConv(envstring_2));
		if (!!((T21_ == ((NI32) 0)))) goto LA22_;
		errno = ((int) 22);
		result = ((int) -1);
		goto BeforeRet_;
	}
	LA22_: ;
	s = getenv(nimToCStringConv(name));
	s[((NI) 0)] = 0;
	s = getenv(nimToCStringConv(name));
	s[((NI) 1)] = 61;
	{
		NI requiredSize;
		size_t T28_;
		tySequence__9aKpvUh0ca6Bp9cKAwrowqUg* buf;
		wchar_t* buf2;
		NI16* ptrToEnv;
		wchar_t* T34_;
		wchar_t* T35_;
		if (!!((_wenviron == ((wchar_t**) NIM_NIL)))) goto LA26_;
		T28_ = (size_t)0;
		T28_ = mbstowcs(((wchar_t*) NIM_NIL), nimToCStringConv(name), ((size_t) 0));
		requiredSize = ((NI) (T28_));
		buf = newSeq__stdZprivateZwin95setenv_36(((NI) ((NI)(requiredSize + ((NI) 1)))));
		buf2 = ((wchar_t*) ((&buf->data[((NI) 0)])));
		{
			size_t T31_;
			T31_ = (size_t)0;
			T31_ = mbstowcs(buf2, nimToCStringConv(name), ((size_t) ((NI)(requiredSize + ((NI) 1)))));
			if (!(T31_ == ((size_t) IL64(4294967295)))) goto LA32_;
			errno = ((int) 22);
			result = ((int) -1);
			goto BeforeRet_;
		}
		LA32_: ;
		T34_ = (wchar_t*)0;
		T34_ = _wgetenv(buf2);
		ptrToEnv = ((NI16*) (T34_));
		ptrToEnv[((NI) 0)] = ((NI16) 0);
		T35_ = (wchar_t*)0;
		T35_ = _wgetenv(buf2);
		ptrToEnv = ((NI16*) (T35_));
		ptrToEnv[((NI) 1)] = ((NI16) 61);
	}
	LA26_: ;
	{
		NI32 T38_;
		T38_ = (NI32)0;
		T38_ = Dl_1426063362_(nimToCStringConv(name), nimToCStringConv(value));
		if (!(T38_ == ((NI32) 0))) goto LA39_;
		errno = ((int) 22);
		result = ((int) -1);
		goto BeforeRet_;
	}
	LA39_: ;
	result = ((int) 0);
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatslibatsstdatsprivateatswin_setenvdotnim_DatInit000)(void) {
NTIseqLutf4954charT__9aKpvUh0ca6Bp9cKAwrowqUg_.size = sizeof(tySequence__9aKpvUh0ca6Bp9cKAwrowqUg*);
NTIseqLutf4954charT__9aKpvUh0ca6Bp9cKAwrowqUg_.align = NIM_ALIGNOF(tySequence__9aKpvUh0ca6Bp9cKAwrowqUg*);
NTIseqLutf4954charT__9aKpvUh0ca6Bp9cKAwrowqUg_.kind = 24;
NTIseqLutf4954charT__9aKpvUh0ca6Bp9cKAwrowqUg_.base = (&NTIint4954__kDPg4wXyR8DDyA0MeEjIsw_);
NTIseqLutf4954charT__9aKpvUh0ca6Bp9cKAwrowqUg_.marker = Marker_tySequence__9aKpvUh0ca6Bp9cKAwrowqUg;
if (!((TM__UOYsq9cbb0VE8vr3Xt181HA_4 = nimLoadLibrary(((NimStringDesc*) &TM__UOYsq9cbb0VE8vr3Xt181HA_6)))
)) nimLoadLibraryError(((NimStringDesc*) &TM__UOYsq9cbb0VE8vr3Xt181HA_7));
	Dl_1426063362_ = (tyProc__3pVglHKolpBa6UoJifpHkA) nimGetProcAddr(TM__UOYsq9cbb0VE8vr3Xt181HA_4, "SetEnvironmentVariableA");
}