42-archive/libft/srcs/sys/ft_getenv.c
2017-03-31 21:42:02 +02:00

27 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_getenv.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 12:15:45 by jhalford #+# #+# */
/* Updated: 2017/03/18 03:09:57 by wescande ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_getenv(char **env, char *key)
{
if (!env)
return (NULL);
while (*env)
{
if (ft_strcmp(*env, key) == '='
&& ft_strlen(key) == ft_strlenchr(*env, '='))
return (*env + ft_strlen(key) + 1);
env++;
}
return (NULL);
}