Example #1
0
int		my_unsetenvbis(char *buffer, t_struct *pile)
{
  int		p;
  t_list	*save;
  t_list	*new_elem;

  p = 0;
  save = pile->my_env;
  if (buffer[0] == '*')
    {
      my_free_list(pile->my_env);
      pile->my_env = 0;
      return (0);
    }
  if (my_strcmp2(buffer, pile->my_env->data) == 0)
    {
      new_elem = pile->my_env->next;
      free(pile->my_env->data);
      free(pile->my_env);
      pile->my_env = new_elem;
      if (new_elem != NULL)
	pile->my_env->prev = 0;
    }
  else
    my_del_elem(buffer, pile->my_env);
  return (0);
}
Example #2
0
int		main(int ac, char **av, char **env)
{
  char		*s;

  ac = ac;
  av = av;
  my_env = tab_to_list(env);
  while (42)
    {
      if (signal(SIGINT, sig_handler) == SIG_ERR)
	printf("Error while trying to catch SIGINT.\n");
      prompt(my_env);
      s = get_next_line(0);
      if (s != NULL)
	{
	  if (strlen(s) != 0)
	    parsing(s, 0, &my_env);
	  free(s);
	}
      else	
	break ;
    }
  my_free_list(my_env);
  return (0);
}
Example #3
0
void		option_d(int ac, char **av, int pos, t_options option)
{
  t_list	*begin;

  begin = option_dlist(ac, av, pos, option);
  if (option.r == 1 && my_list_size(begin) > 1)
    my_rev_list(&begin);
  ls_display(begin, option);
  my_free_list(&begin);
}
Example #4
0
void		main_manager(char *s, t_main **my_env)
{
  t_main	*list;
  char		**env;

  env = list_to_tab(*my_env);
  list = NULL;
  parsing_entree(&list, s);
  if (list != NULL)
    {
      if (execution(list, my_env, env) != -1)
	my_free_list(list);
    }
  my_free_tab(env);
}
Example #5
0
t_list		*my_str_to_wordlist(char *str, char *sep)
{
  t_list	*backup;
  t_list	*wordlist;
  int		i;

  i = -1;
  backup = NULL;
  wordlist = NULL;
  while (str[++i])
    if (is_sep(str[i], sep) == 0 && (i == 0 || is_sep(str[i - 1], sep) == 1))
      {
	if ((wordlist = my_put_in_list(str + i, wordlist)) == NULL)
	  {
	    my_free_list(backup);
	    return (NULL);
	  }
	backup = wordlist;
      }
    else if (is_sep(str[i], sep) == 1)
      str[i] = '\0';
  return (wordlist);
}