Пример #1
0
t_data		take_end(t_data the)
{
	if (ft_strcmp(the.line, "##end") == 0)
	{
		get_next_line(0, &the.line);
		if (the.line[0] == '#')
			error();
		the.j++;
		the.aff[the.j] = ft_strdup(the.line);
		if (check_room(the) == 1)
			the.end = take_name(the.line);
		else
			error();
	}
	return (the);
}
Пример #2
0
static struct dt_node *new_node(const char *name)
{
	struct dt_node *node = malloc(sizeof *node);
	if (!node) {
		prerror("Failed to allocate node\n");
		abort();
	}

	node->name = take_name(name);
	node->parent = NULL;
	list_head_init(&node->properties);
	list_head_init(&node->children);
	/* FIXME: locking? */
	node->phandle = new_phandle();
	return node;
}
Пример #3
0
/*
** Open file 
** and create file_name.s to file_name.cor if
** this one doesn't exist 
*/
void	xopen(char *str, t_open *opn)
{
  if ((opn->name = malloc(sizeof(*opn->name))) == NULL)
    exit (0);
  if ((opn->fd = open(str, O_RDONLY)) == -1)
    my_putstr("File doesn't exist\n");
  else
    {
      if (check_file(str) == 0)
	{
	  opn->name = take_name(str);
	  if ((opn->fd2 = open(opn->name, O_CREAT | O_WRONLY | O_RDONLY, 777)) == -1)
	    exit(0);
	}
      else
	my_putstr("Enter file with .s extension\n");
    }
}