void		fractal_choice(char **argv, t_struct *mystruct)
{
	if (ft_strequ(argv[1], "Julia") == 1)
	{
		mystruct->fracnum = 1;
		julia_init(mystruct);
		mlx_mouse_hook(mystruct->win, ft_zoom, mystruct);
		mlx_hook(mystruct->win, 6, (1L << 6), motion_julia, mystruct);
	}
	else if (ft_strequ(argv[1], "Mandel") == 1)
	{
		mystruct->fracnum = 2;
		mandel_init(mystruct);
		mlx_mouse_hook(mystruct->win, ft_zoom_mandel, mystruct);
		mlx_hook(mystruct->win, 6, (1L << 6), motion_mandel, mystruct);
	}
	else if (ft_strequ(argv[1], "Burning") == 1)
	{
		mystruct->fracnum = 3;
		burn_init(mystruct);
		mlx_mouse_hook(mystruct->win, ft_zoom_burning, mystruct);
		mlx_hook(mystruct->win, 6, (1L << 6), motion_burning, mystruct);
	}
	else
		error_arg();
}
Exemple #2
0
static void		read_option(t_env *e, int ac, char **av)
{
	if (ac != 2)
		error_arg();
	if (open_file(e, av[1]) == 0)
		error_map();
}
int			main(int argc, char **argv)
{
	t_struct *mystruct;

	if (argc != 2)
	{
		error_arg();
		return (0);
	}
	mystruct = give_struct();
	fractal_choice(argv, mystruct);
	mlx_put_image_to_window(mystruct->mlx,
			mystruct->win, mystruct->img->img_ptr, 0, 0);
	mlx_expose_hook(mystruct->win, expose_hoo, mystruct);
	mlx_key_hook(mystruct->win, event_mlx, mystruct);
	mlx_loop(mystruct->mlx);
	return (0);
}
Exemple #4
0
int		main(int ac, char **av)
{
  int		fd;
  t_env		env;
  f_action	*fptr_action;

  if (init_args(ac, av, &env) == -1)
    {
      error_arg();
      return (-1);
    }
  signal(SIGTERM, &set_flag);
  signal(SIGINT, &set_flag);
  if (verif_fd() == -1
      || create_socket(&fd) == -1
      || init_server_socket(fd, env.port) == -1
      || init_env(&env, fd, &fptr_action) == -1
      || server(&env, fptr_action) == -1)
    return (-1);
  printf("Bye Bye\n");
  delete_env(&env, fptr_action);
  return (0);
}
Exemple #5
0
int main(int argc,char *argv[])
{
	int ret;
	int cpunumber_node;
	struct sysinfo *info;
	int i;
	int j;
	int k;
	size_t memorysize;
	size_t memorysize_5;
	size_t memorysize_dimension;
	size_t MAXI;
	size_t MAXJ;
	size_t MAXK;

	if(argc != 6){
		error_arg();
		exit(-1);
	}
	info = malloc(sizeof(struct sysinfo));
	sysinfo(info);

#ifdef DEBUG
	printf(" %ld kb\n ",info->freeram);
#endif
	
#ifdef MULTI
	MPI_Init(NULL,NULL);
	MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
	MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
	MPI_Get_processor_name(name, &resultlen);
	printf(" My processor is %s Total Free Memory is %ld \n",name,info->freeram);
	printf(" Total processor is %d myrank is %d \n",nprocs,myrank);
#endif

	printf(" Memory is %ld \n",info->totalram);
	printf(" Free Memory is %ld \n",info->freeram);

	cpunumber_node = (sysconf(_SC_NPROCESSORS_CONF) * 1 );
	
	if(atoi(argv[2]) == 0){
		cpunumber_node = cpunumber_node;
	}else{
		if(atoi(argv[2]) > cpunumber_node){
			printf(" ****** Attension! ******* \n");
			printf(" CPU Number is maybe over ... \n");
			cpunumber_node = cpunumber_node;
		} else {
			cpunumber_node = atoi(argv[2]);
		}
	}
	memorysize = info->totalram * 0.7;
	memorysize_5 = (memorysize / cpunumber_node) * 0.7;

	memorysize_dimension = (cbrt_simple(memorysize_5))*0.7;

	if(atoi(argv[3]) == 0){
		MAXI = memorysize_dimension;
		MAXJ = memorysize_dimension;
		MAXK = memorysize_dimension;
	} else if( atoi(argv[3]) > memorysize_dimension ){
		MAXI = memorysize_dimension;
		MAXJ = memorysize_dimension;
		MAXK = memorysize_dimension;
		printf(" ****** Attension! ******* \n");
		printf(" Array size may be over ... \n");
	} else {
		MAXI = atoi(argv[3]);
		MAXJ = atoi(argv[3]);
		MAXK = atoi(argv[3]);
	}

	printf(" MAXI is %ld \n",MAXI);
	printf(" MAXJ is %ld \n",MAXJ);
	printf(" MAXK is %ld \n",MAXK);

	filemaxsize = atoi(argv[6]);
	printf(" File Size is %ld \n",filemaxsize);

#ifdef DEBUG
	printf(" MAXI is %ld \n",MAXI);
	printf(" MAXJ is %ld \n",MAXJ);
	printf(" MAXK is %ld \n",MAXK);
#endif
	printf(" CPU number is %d \n",cpunumber_node);

	a = (double **)malloc( (sizeof(double *)*cpunumber_node) );

	if(atoi(argv[1]) == 0){
		ret = ogafile(20, 30, 5, 20, 10000, filemaxsize*0.8, filemaxsize, 100000);
	}else if(atoi(argv[1]) == 1){
		ret = function_create_thread(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), atoi(argv[4]), atoi(argv[5]), atoi(argv[6]), cpunumber_node, MAXI); 
	}else if(atoi(argv[1]) == 2 ){
		ret = function_create_thread(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), atoi(argv[4]), atoi(argv[5]), atoi(argv[6]), cpunumber_node, MAXI); 
	}else if(atoi(argv[1]) == 3){
		ret = function_create_thread(atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), atoi(argv[4]), atoi(argv[5]), atoi(argv[6]), cpunumber_node, MAXI); 
	}

	if(atoi(argv[1]) == 1 || atoi(argv[1]) == 2){
	}

#ifdef MULTI
	MPI_Finalize();
#endif
	free(info);
	return 0;
}