env subdir for getenv

This commit is contained in:
Jack Halford 2016-11-10 17:07:05 +01:00
parent ece5c61bea
commit b3e78bb758
9 changed files with 49 additions and 11 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */
/* Updated: 2016/11/10 12:14:04 by jhalford ### ########.fr */
/* Updated: 2016/11/10 14:40:54 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -31,6 +31,14 @@
# define FT_MAX(a, b) ((a) > (b) ? (a) : (b))
# define FT_DIST(a, b) (FT_ABS((a) - (b)))
typedef struct s_stof t_stof;
struct s_stof
{
char *name;
int (*f)();
};
void ft_debug(void);
void *ft_memset(void *b, int c, size_t len);
@ -118,4 +126,6 @@ int ft_time_isrecent(time_t event);
char *ft_path_notdir(char *path);
int ft_printf(const char *format, ...);
char *ft_getenv(char **env, char *key);
#endif

27
libftasm/src/env/ft_getenv.c vendored Normal file
View file

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_getenv.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 14:30:00 by jhalford #+# #+# */
/* Updated: 2016/11/10 14:30:27 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_getenv(char **env, char *key)
{
if (!env)
return (NULL);
while (*env)
{
/* ft_printf("%s\n", env[i]); */
if (ft_strcmp(*env, key) == '=')
return (*env + ft_strlen(key) + 1);
env++;
}
return (NULL);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:31:48 by jhalford #+# #+# */
/* Updated: 2016/11/07 16:56:28 by jhalford ### ########.fr */
/* Updated: 2016/11/10 12:59:25 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 16:53:07 by jhalford #+# #+# */
/* Updated: 2016/11/07 17:25:47 by jhalford ### ########.fr */
/* Updated: 2016/11/10 13:02:07 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -38,12 +38,15 @@ static void ft_fmt_validate_flag_conv(t_fmt *fmt)
i = 0;
flag_ptr = fmt->flags;
while (fmt->conversion != g_convs[i].id)
i++;
while (*flag_ptr)
{
flag = *flag_ptr;
if (!ft_strchr(g_convs[i].allowed_flags, flag))
{
ft_fmt_error_flag_conv(flag, fmt->conversion);
/* ft_printf("allowed flags:%s\n", g_convs[i].allowed_flags); */
if (flag == '#')
*flag_ptr = '.';
}
@ -56,8 +59,6 @@ void ft_fmt_validate_flags(t_fmt *fmt)
int i;
i = 0;
while (fmt->conversion != g_convs[i].id)
i++;
ft_fmt_validate_flag_conv(fmt);
ft_fmt_validate_flag_flag(fmt);
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */
/* Updated: 2016/11/07 16:20:10 by jhalford ### ########.fr */
/* Updated: 2016/11/10 12:59:41 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:24 by jhalford #+# #+# */
/* Updated: 2016/11/07 16:56:47 by jhalford ### ########.fr */
/* Updated: 2016/11/10 12:59:50 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/07 10:56:53 by jhalford #+# #+# */
/* Updated: 2016/08/20 23:16:44 by jhalford ### ########.fr */
/* Updated: 2016/11/10 12:18:00 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,7 +19,7 @@ char *ft_strcat(char *s1, const char *s2)
size = ft_strlen(s1);
j = 0;
while (s2[j] != '\0')
while (s2 && s2[j])
{
s1[size + j] = s2[j];
j++;

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:18 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:18 by jhalford ### ########.fr */
/* Updated: 2016/11/10 10:14:09 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:22 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:23 by jhalford ### ########.fr */
/* Updated: 2016/11/10 10:14:18 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */