jehanne: implement setenv and unsetenv

This commit is contained in:
Giacomo Tesio 2017-10-03 00:51:16 +02:00
parent dfb145077c
commit 75921fd16e
3 changed files with 45 additions and 3 deletions

View File

@ -15,7 +15,7 @@ endif
lib_a_SOURCES = getenv_r.c getenv.c malloc.c mallocr.c free.c freer.c \
calloc.c callocr.c realloc.c reallocr.c environ.c signal.c \
sysfcntl.c exit.c
sysfcntl.c exit.c setenv_r.c
lib_a_LIBADD = $(extra_objs)
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c \

View File

@ -63,7 +63,8 @@ am_lib_a_OBJECTS = lib_a-getenv_r.$(OBJEXT) lib_a-getenv.$(OBJEXT) \
lib_a-calloc.$(OBJEXT) lib_a-callocr.$(OBJEXT) \
lib_a-realloc.$(OBJEXT) lib_a-reallocr.$(OBJEXT) \
lib_a-environ.$(OBJEXT) lib_a-signal.$(OBJEXT) \
lib_a-sysfcntl.$(OBJEXT) lib_a-exit.$(OBJEXT)
lib_a-sysfcntl.$(OBJEXT) lib_a-exit.$(OBJEXT) \
lib_a-setenv_r.$(OBJEXT)
lib_a_OBJECTS = $(am_lib_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp =
@ -190,7 +191,7 @@ noinst_LIBRARIES = lib.a
lib_a_SOURCES = getenv_r.c getenv.c malloc.c mallocr.c free.c freer.c \
calloc.c callocr.c realloc.c reallocr.c environ.c signal.c \
sysfcntl.c exit.c
sysfcntl.c exit.c setenv_r.c
lib_a_LIBADD = $(extra_objs)
EXTRA_lib_a_SOURCES = libposix_conf.c syscalls.c chown.c getrusage.c \
@ -349,6 +350,12 @@ lib_a-exit.o: exit.c
lib_a-exit.obj: exit.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-exit.obj `if test -f 'exit.c'; then $(CYGPATH_W) 'exit.c'; else $(CYGPATH_W) '$(srcdir)/exit.c'; fi`
lib_a-setenv_r.o: setenv_r.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-setenv_r.o `test -f 'setenv_r.c' || echo '$(srcdir)/'`setenv_r.c
lib_a-setenv_r.obj: setenv_r.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-setenv_r.obj `if test -f 'setenv_r.c'; then $(CYGPATH_W) 'setenv_r.c'; else $(CYGPATH_W) '$(srcdir)/setenv_r.c'; fi`
lib_a-libposix_conf.o: libposix_conf.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-libposix_conf.o `test -f 'libposix_conf.c' || echo '$(srcdir)/'`libposix_conf.c

View File

@ -0,0 +1,35 @@
/*
* This file is part of Jehanne.
*
* Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3 of the License.
*
* Jehanne is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
*/
#include <u.h>
#include <libc.h>
#include <posix.h>
#include <reent.h>
int
_setenv_r(struct _reent *r, const char *name, const char *value, int overwrite)
{
int *errnop = &r->_errno;
return POSIX_setenv(errnop, name, value, overwrite);
}
int
_unsetenv_r(struct _reent *r, const char *name)
{
int *errnop = &r->_errno;
return POSIX_unsetenv(errnop, name);
}