48 lines
1.5 KiB
C
48 lines
1.5 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* dictparse.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/04/01 21:45:39 by tischmid #+# #+# */
|
|
/* Updated: 2023/04/01 21:59:39 by tischmid ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "dictparse.h"
|
|
#include "ft_io.h"
|
|
|
|
int parse_line(char *line, char **key, char **value)
|
|
{
|
|
(void)line;
|
|
*key = "20";
|
|
*value = "twenty";
|
|
return (1);
|
|
}
|
|
|
|
// `value' instead of `buf` in ll_map_push
|
|
int parse_dict(char *path, t_map_entry *map)
|
|
{
|
|
char buf[MAX_LINE_LENGTH];
|
|
int offset;
|
|
char *key;
|
|
char *value;
|
|
int idx;
|
|
|
|
offset = 0;
|
|
idx = -1;
|
|
while (++idx < 20)
|
|
{
|
|
offset = readline(buf, MAX_LINE_LENGTH, path, offset);
|
|
if (offset == FILE_READ_ERROR)
|
|
break ;
|
|
else if (offset == LINE_TOO_LONG)
|
|
return (0);
|
|
if (!parse_line(buf, &key, &value))
|
|
return (0);
|
|
ll_map_push(map, key, buf);
|
|
}
|
|
return (1);
|
|
}
|