mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-12-22 14:30:29 +00:00
33 lines
614 B
C
33 lines
614 B
C
|
#pragma noroot
|
||
|
#pragma optimize -1
|
||
|
#include <types.h>
|
||
|
#include <shell.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
char *getenv(char *name)
|
||
|
{
|
||
|
Get_VarPB gv;
|
||
|
char *vn;
|
||
|
int l;
|
||
|
|
||
|
l = strlen(name);
|
||
|
gv.var_name = malloc(l+1);
|
||
|
gv.var_name[0] = l; memcpy(gv.var_name+1,name,(size_t)l);
|
||
|
gv.value = malloc(256l);
|
||
|
GET_VAR(&gv);
|
||
|
gv.value[gv.value[0]+1] = 0;
|
||
|
free(gv.var_name);
|
||
|
if (gv.value[0] == 0) { free(gv.value); return NULL; }
|
||
|
vn = malloc(gv.value[0]+1);
|
||
|
memcpy(vn,gv.value+1,gv.value[0]);
|
||
|
vn[gv.value[0]] = 0;
|
||
|
free(gv.value);
|
||
|
return vn;
|
||
|
}
|
||
|
|
||
|
/*void exit(int blah)
|
||
|
{
|
||
|
rexit(blah);
|
||
|
} */
|