/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* u_alias.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include "d_define.h" #include "s_lalias.h" #include "s_struct.h" short u_get_alias_value(char str[], const char name[], size_t dstsize, t_msh *msh) { t_lalias *ptr; if (str != NULL) { str[0] = C_NUL; } ptr = msh->alias; while (ptr != NULL && ft_strncmp(ptr->name, name, ft_strlen(name) + 1) != 0) { ptr = ptr->next; } if (ptr == NULL) { return (0); } if (str != NULL) { ft_strlcpy(str, ptr->val, dstsize); } return (ptr->id); } void u_set_alias_value(const char name[], const char value[], t_msh *msh) { t_lalias *new; if (u_get_alias_value(NULL, name, 0, msh) != 0) { s_lalias_rebind(&msh->alias, name, value); } else { if ((new = s_lalias_new(name, value)) == NULL) { return ; } s_lalias_add_front(&msh->alias, new); } }