FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
sys_environ.c
Go to the documentation of this file.
1
/* environ$ function and setenviron stmt */
2
3
#include "
fb.h
"
4
5
FBCALL
FBSTRING
*
fb_GetEnviron
(
FBSTRING
*varname )
6
{
7
FBSTRING
*dst;
8
char
*tmp;
9
ssize_t len;
10
11
if
( (varname !=
NULL
) && (varname->
data
!=
NULL
) )
12
tmp = getenv( varname->
data
);
13
else
14
tmp =
NULL
;
15
16
FB_STRLOCK
();
17
18
if
( tmp !=
NULL
)
19
{
20
len = strlen( tmp );
21
dst =
fb_hStrAllocTemp_NoLock
(
NULL
, len );
22
if
( dst !=
NULL
)
23
{
24
fb_hStrCopy
( dst->
data
, tmp, len );
25
}
26
else
27
dst = &
__fb_ctx
.
null_desc
;
28
}
29
else
30
dst = &
__fb_ctx
.
null_desc
;
31
32
/* del if temp */
33
fb_hStrDelTemp_NoLock
( varname );
34
35
FB_STRUNLOCK
();
36
37
return
dst;
38
}
39
40
FBCALL
int
fb_SetEnviron
(
FBSTRING
*str )
41
{
42
int
res = 0;
43
44
if
( (str !=
NULL
) && (str->
data
!=
NULL
) )
45
{
46
#ifdef HOST_MINGW
47
res = _putenv( str->
data
);
48
#else
49
res = putenv( str->
data
);
50
#endif
51
}
52
53
/* del if temp */
54
fb_hStrDelTemp
( str );
55
56
return
res;
57
}
rtlib
sys_environ.c
Generated on Thu Jan 23 2014 19:40:14 for FreeBASIC by
1.8.4