Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
d8557834
Commit
d8557834
authored
Nov 13, 2015
by
Paul Sokolovsky
Browse files
unix/modos: Add getenv().
Dependency of upip.
parent
a01f6c9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
unix/modos.c
View file @
d8557834
...
...
@@ -30,6 +30,7 @@
#include
<unistd.h>
#include
<errno.h>
#include
<stdlib.h>
#include
<string.h>
#include
"py/mpconfig.h"
#include
"py/nlr.h"
...
...
@@ -134,6 +135,12 @@ STATIC mp_obj_t mod_os_system(mp_obj_t cmd_in) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
mod_os_system_obj
,
mod_os_system
);
STATIC
mp_obj_t
mod_os_getenv
(
mp_obj_t
var_in
)
{
const
char
*
s
=
getenv
(
mp_obj_str_get_str
(
var_in
));
return
mp_obj_new_str
(
s
,
strlen
(
s
),
false
);
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
mod_os_getenv_obj
,
mod_os_getenv
);
STATIC
const
mp_map_elem_t
mp_module_os_globals_table
[]
=
{
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___name__
),
MP_OBJ_NEW_QSTR
(
MP_QSTR__os
)
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_stat
),
(
mp_obj_t
)
&
mod_os_stat_obj
},
...
...
@@ -142,6 +149,7 @@ STATIC const mp_map_elem_t mp_module_os_globals_table[] = {
#endif
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_system
),
(
mp_obj_t
)
&
mod_os_system_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_unlink
),(
mp_obj_t
)
&
mod_os_unlink_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_getenv
),(
mp_obj_t
)
&
mod_os_getenv_obj
},
};
STATIC
MP_DEFINE_CONST_DICT
(
mp_module_os_globals
,
mp_module_os_globals_table
);
...
...
unix/qstrdefsport.h
View file @
d8557834
...
...
@@ -41,6 +41,7 @@ Q(statvfs)
#endif
Q
(
system
)
Q
(
unlink
)
Q
(
getenv
)
Q
(
ffi
)
Q
(
ffimod
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment