Example #1
0
int		main(int ac, char **av)
{
	t_all			all;
	int				ret;

	all.elem = NULL;
	all.win.nb_elem = 0;
	all.show = 1;
	if (ac > 1 && av[1] != NULL)
	{
		ft_signal();
		if (init_term(&all))
			return (-1);
		if ((ret = init_lst(&(all.elem), av, &all)) == TRUE)
		{
			memoire(&all, 0);
			ret = ft_select(&all);
		}
		if (reset_term(&all) == -1)
			return (-1);
		if (ret == -2)
			print_select(&all);
		if (all.win.nb_elem > 0)
			freelst(&all);
	}
	return (0);
}
Example #2
0
static int	main_minishell(t_lst *node, char **env)
{
	char	*line;
	char	**arg;

	line = NULL;
	while (1)
	{
		if (check_lst(node) == 0)
			node = init_lst(env);
		get_prompt(node);
		if (get_next_line(0, &line) != 1)
			break ;
		arg = ft_strsplit(line, ';');
		while (*arg)
		{
			if (do_arg(node, *arg) >= 0)
			{
				ft_putstr("exit\n");
				ft_strdel(arg);
				return (0);
			}
			ft_putchar('\n');
			arg++;
		}
	}
	return (0);
}
OMX_ERRORTYPE tiz_shuffle_lst_init (tiz_shuffle_lst_ptr_t *app_shuffle_lst,
                                    const size_t a_list_size)
{
  OMX_ERRORTYPE rc = OMX_ErrorInsufficientResources;
  tiz_shuffle_lst_t *p_shuffle_lst = NULL;

  assert (NULL != app_shuffle_lst);
  assert (a_list_size > 0);

  p_shuffle_lst = tiz_mem_calloc (1, sizeof(tiz_shuffle_lst_t));
  if (p_shuffle_lst)
    {
      p_shuffle_lst->length = a_list_size;
      if (OMX_ErrorNone == (rc = init_lst (p_shuffle_lst)))
        {
          srand (time (NULL));
          shuffle_lst (p_shuffle_lst->p_lst, p_shuffle_lst->length);
        }
    }

  if (OMX_ErrorNone != rc)
    {
      destroy_lst (p_shuffle_lst);
      p_shuffle_lst = NULL;
    }

  *app_shuffle_lst = p_shuffle_lst;
  return rc;
}
Example #4
0
File: draw.c Project: rdestreb/FdF
void	draw_map(t_disp *d)
{
	t_coord *c1;
	t_coord c2;
	t_coord *c3;

	c1 = init_lst();
	c1 = c1->next;
	while (c1 && c1->next)
	{
		if ((c1->xp < 0 || c1->xp > d->win_size) &&
			(c1->yp < 0 || c1->yp > d->win_size))
		{
			c1 = c1->next;
			continue;
		}
		if (c1->x < c1->next->x)
		{
			c2.xp = c1->next->xp;
			c2.yp = c1->next->yp;
			draw_line(d, c1, &c2);
		}
		if ((c3 = get_next_y(c1)) && (c1->z < c3->z))
			draw_line(d, c1, c3);
		c1 = c1->next;
	}
}
Example #5
0
t_list			*get_lst_resource(void)
{
	static t_list	*lst = NULL;

	if (lst == NULL)
		lst = init_lst();
	return (lst);
}
Example #6
0
File: term.c Project: Zethir/42sh
t_struct	*init_select_struct(char **argv)
{
	t_struct	*info;

	if (!(info = (t_struct *)malloc(sizeof(t_struct))))
		return (NULL);
	info->on = 0;
	info->node = init_lst(argv);
	info->node->head->line = 1;
	return (info);
}
Example #7
0
int			main(int ac, char **av, char **env)
{
	t_lst	*node;

	av = NULL;
	node = init_lst(env);
	signal(SIGINT, SIG_IGN);
	if (ac == 1)
		main_minishell(node, env);
	else
		return (1);
	if (node)
		free_list(node);
	return (0);
}
Example #8
0
int main(int argc,char **argv) {

  long int del_sec,del_msec;
  // struct timeval tv_s,tv_e;
  int group = 4;

  if (argc>1) n = atoi(argv[1]);
  else n = NELM;
  printf("n=%d\n",n);
  init_lst(lst,n);
  // print_lst(lst,n);

  // gettimeofday(&tv_s, NULL); 
  // selection_sort(lst,n);
  //  merge_sort(lst,tmp,n);

  int *src, * dest;

  src = lst;
  dest = tmp;

  // printf("%x  :  %x\n", src, lst);
  // printf("%x  :  %x\n", dest, tmp);

  //   printf("%x  :  %x\n", src, &lst);
  // printf("%x  :  %x\n", dest, &tmp);

  for (int iii = 0; iii < 32; iii += group) {
    int_radix_sort(src, dest, n, iii);
    
    int *temp;
    temp = src;
    src = dest;
    dest = temp;

  }

  //  float_radix_sort(lst,tmp,n);
  // gettimeofday(&tv_e, NULL); 

  /****
    PRINT elapsed time in sec and milli secs
  ****/

  // print_lst(lst,n);
  self_check(lst, n);
  return 0;
}
Example #9
0
File: draw.c Project: rdestreb/FdF
void	projection(t_coord *c)
{
	t_param	*par;

	c = init_lst();
	c = c->next;
	par = get_params();
	while (c)
	{
		if (((par->proj) % 2) == ISO)
		{
			c->xp = (par->cst * c->x - par->cst2 * c->z) * par->zoom + par->x0;
			c->yp = ((par->cst / 2) * c->x + (par->cst2 / 2) * c->z - c->y) *
				par->zoom + par->y0;
		}
		else
		{
			c->xp = (c->x - par->cst * c->z) * par->zoom + par->x0;
			c->yp = (par->cst / 2 * c->z - c->y) * par->zoom + par->y0;
		}
		c = c->next;
	}
}