Example #1
0
int		parsing(t_all *infos, char *file)
{
  FILE		*fd;
  int		err;

  if (add_file_to_list(&infos->files, file) == -1)
    {
      fprintf(stderr, "%s : file already opened\n", file);
      return (-1);
    }
  if ((fd = fopen(infos->files->name, "r")) == NULL)
    return (error_function(OPEN, -1, -1));
  err = start_parsing(infos, fd, infos->files->name);
  if (fclose(fd) == -1)
    return (error_function(CLOSE, -1, -1));
  return ((err == -1) ? err : 0);
}
Example #2
0
int			run_epikong()
{
  t_map			map;
  char			*path;

  if ((path = init_screen()) == NULL)
    return (EXIT_FAILURE);
  if (start_music() == EXIT_FAILURE)
    return (EXIT_FAILURE);
  if (start_parsing(path, &map) == EXIT_FAILURE)
    return (EXIT_FAILURE);
  if (get_monster(&map) == EXIT_FAILURE)
    return (EXIT_FAILURE);
  if (get_hero(&map) == EXIT_FAILURE)
    return (EXIT_FAILURE);
  if (parse_map(&map) == EXIT_FAILURE)
    return (EXIT_FAILURE);
  return (EXIT_SUCCESS);
}
Example #3
0
File: main.c Project: abelcha/42sh
int			main(int ac, char **av, char **env)
{
  t_token		*root;
  t_parse_tree		*tree;
  t_shell		*sh;

  (void)av;
  (void)ac;
  if (!(sh = init_sh(env)))
    return (FAILURE);
  parse_config_file(sh);
  while (!sh->exe->exit && get_line_caps(sh->line) != FAILURE)
    {
      pre_parsing(sh);
      if (!(root = get_tokens(sh->line->line)))
	return (FAILURE);
      if ((tree = start_parsing(root, sh)) && (sh->exe->return_value = 2))
	exec_cmd(tree, sh->exe);
      free_tokens(root);
      XFREE(sh->line->line);
    }
  add_in_history_file(sh->line);
  return (clean_all(sh));
}