예제 #1
0
파일: keycodes.c 프로젝트: gmange/scop
int					keycode_fun_quit(t_env *env)
{
	debug_stdout("INIT", FILE_LINE_FUN);
	ft_exit(env, EXIT_SUCCESS, NULL, NULL);
	debug_stdout("END", FILE_LINE_FUN);
	return (EXIT_SUCCESS);
}
예제 #2
0
파일: get_address.c 프로젝트: gmange/malloc
t_list_rb	*get_next_zone_address(t_list_rb *lst)
{
	debug_stdout("INIT", __FILE__, __LINE__, __func__);
	debug_lst("lst", lst, __FILE__, __LINE__);
	debug_stdout("--", "headed_content_size", get_headed_content_size(lst), "");
	return ((t_list_rb *)((unsigned char *)lst + get_headed_content_size(lst)));
}
예제 #3
0
파일: mlx_launch.c 프로젝트: gmange/scop
static int			key_hook(int keycode, t_env *env)
{
	debug_stdout("INIT", FILE_LINE_FUN);
	if (SCOP_DEBUG)
		fprintf(stdout, "keycode:%d\n", keycode);
	keycodes(env, keycode);
	debug_stdout("END", FILE_LINE_FUN);
	return (EXIT_SUCCESS);
}
예제 #4
0
static int			obj_struct_init_gvtx(t_env *env)
{
	debug_stdout("INIT", FILE_LINE_FUN);
	if (SCOP_DEBUG)
		fprintf(stdout, "g_vtx_size: %zu, g_vtxs_nb: %d; g_vtxs_malloc: %zu\n",
				sizeof(t_g_vertex), OBJ_CNTS[e_geometric_vertex],
				sizeof(t_g_vertex) * OBJ_CNTS[e_geometric_vertex]);
	if (OBJ_CNTS[e_geometric_vertex]
		&& !(OBJ_GVTX = (t_g_vertex *)
			ft_memalloc(sizeof(t_g_vertex) * OBJ_CNTS[e_geometric_vertex])))
		return (ft_error(env, __FUNCTION__, "malloc OBJ_GVTX failed"));
	debug_stdout("END", FILE_LINE_FUN);
	return (EXIT_SUCCESS);
}
예제 #5
0
static int			obj_struct_init_color(t_env *env)
{
	debug_stdout("INIT", FILE_LINE_FUN);
	if (SCOP_DEBUG)
		fprintf(stdout, "color_size: %zu, color_nb: %d; color_malloc: %zu\n",
				sizeof(t_color), OBJ_CNTS[e_color],
				sizeof(t_color) * OBJ_CNTS[e_color]);
	if (OBJ_CNTS[e_color]
		&& !(OBJ_COLS = (t_color *)
			ft_memalloc(sizeof(t_color) * OBJ_CNTS[e_color])))
		return (ft_error(env, __FUNCTION__, "malloc OBJ_COLS failed"));
	debug_stdout("END", FILE_LINE_FUN);
	return (EXIT_SUCCESS);
}
예제 #6
0
void print_char_buf(char *buf_name, char *buf, int64_t buf_len)
{
    int i;

    debug_stdout("print_char_buf: %s\n", buf_name);
    for (i = 0; i < buf_len; i++)
    {
	debug_stdout("%c ", buf[i]);
	if (((i + 1) % 10) == 0)
	    debug_stdout("\n");	    
	else if (((i + 1) % 5) == 0)
	    debug_stdout("  ");
    }
    debug_stdout("\n");
}
예제 #7
0
파일: obj_read_face.c 프로젝트: gmange/scop
int					obj_read_face(t_env *env, char *line, int nb)
{
	int				ret;

	debug_stdout("INIT", FILE_LINE_FUN);
	if (SCOP_DEBUG)
		fprintf(stdout, "OBJ_CNTS[e_face] = %d\n", OBJ_CNTS[e_face]);
	ret = 1;
	while (ret && ret != EOF)
	{
		if (obj_read_face_line(env, &line, &nb, &ret) != EXIT_SUCCESS)
			return (ft_error(env, __FUNCTION__, "obj_read_face_line FAILED"));
	}
	debug_stdout("END", FILE_LINE_FUN);
	return (EXIT_SUCCESS);
}
예제 #8
0
파일: mlx_launch.c 프로젝트: gmange/scop
static int			idle_hook(t_env *env)
{
	debug_stdout("INIT", FILE_LINE_FUN);
	expose_hook(env);
	test_opengl_error("ERROR", FILE_LINE_FUN);
	return (EXIT_SUCCESS);
}
예제 #9
0
파일: dump_hexa.c 프로젝트: gmange/malloc
void			*print_content_hexa(t_list_rb *root, t_list_rb **prev,
								t_list_rb *lst, size_t malloc_size)
{
	size_t	size;

	debug_stdout("INIT", FILE_LINE_FUNC);
	debug_lst("lst", lst, __FILE__, __LINE__);
	size = 0;
	while (size < lst->content_size)
	{
		if (size)
		{
			if (!(size % 32))
				ft_putchar('\n');
			else if (!(size % 2))
				ft_putchar(' ');
		}
		ft_putnbr_base(ft_ctoi(((unsigned char *)lst->content)[size]), 16, 2);
		++size;
	}
	ft_putchar('\n');
	(void)root;
	(void)prev;
	(void)malloc_size;
	return (lst);
}
예제 #10
0
파일: keycodes.c 프로젝트: gmange/scop
int					keycodes(t_env *env, int keycode)
{
	size_t		i;

	debug_stdout("INIT", FILE_LINE_FUN);
	i = 0;
	while (g_keycodes_int[i] > -1 && keycode != g_keycodes_int[i])
		++i;
	test_opengl_error("ERROR", FILE_LINE_FUN);
	if (g_keycodes_int[i] > -1)
	{
		if (SCOP_DEBUG)
			fprintf(stdout, "g_keycodes_ind[%zu]: %d\n", i, g_keycodes_int[i]);
		return (g_keycodes_fun[i](env));
	}
	debug_stdout("END", FILE_LINE_FUN);
	return (EXIT_SUCCESS);
}
예제 #11
0
파일: keycodes.c 프로젝트: gmange/scop
int					print_tutorial(t_env *env)
{
	unsigned int	i;

	debug_stdout("INIT", FILE_LINE_FUN);
	fprintf(stdout, "use the following keys to interact:\n");
	i = 0;
	while (g_keycodes_fun[i])
		++i;
	if (g_keycodes_int[i] != -1)
		return (ft_error(env, __FUNCTION__, "g_keycode_fun and int mismatch"));
	i = 0;
	while (g_keycodes_str[i])
		fprintf(stdout, "%s\n", g_keycodes_str[i++]);
	if (SCOP_DEBUG)
		fprintf(stdout, "E_TXMV_STP:%f\n", E_TXMV_STP);
	debug_stdout("END", FILE_LINE_FUN);
	return (EXIT_SUCCESS);
}
예제 #12
0
파일: is_it_ptr.c 프로젝트: gmange/malloc
int		is_it_ptr(t_list_rb *prev, t_list_rb *lst, void *ptr)
{
    debug_stdout("INIT", __FILE__, __LINE__, __func__);
    debug_ptr("ptr", (const void **)&ptr);
    debug_lst("prev", prev, __FILE__, __LINE__);
    debug_lst("lst", lst, __FILE__, __LINE__);
    if (lst->content == ptr)
        return (ft_end(NULL, EXIT_SUCCESS, "lst to be freed\n"));
    return (EXIT_FAILURE);
}
예제 #13
0
파일: get_address.c 프로젝트: gmange/malloc
void		*get_content_address(t_list_rb *lst, size_t malloc_size)
{
	void	*ptr;

	debug_stdout("INIT", __FILE__, __LINE__, __func__);
	ptr = (void *)((unsigned char *)lst + get_malloc_head_size(malloc_size));
	if (lst->content && ptr != lst->content)
		return (ft_error_ptr(NULL, "malloc address lost\n", __func__, NULL));
	return (ptr);
}
예제 #14
0
파일: ftp_len.c 프로젝트: gmange/ft_printf
int			ftp_len(t_spec *cur)
{
	debug_stdout(__FILE__, __LINE__, __func__, "INIT\n");
	if (STATE > e_state_length)
		return (-1);
	STATE = e_state_length;
	if (*STR == 'l' || *STR == 'h' || *STR == 'j' || *STR == 'z')
		FLG_LEN = *STR;
	else
		return (-1);
	return (ftp_choose_func(cur));
}
예제 #15
0
int					obj_struct_init(t_env *env)
{
	debug_stdout("INIT", FILE_LINE_FUN);
	if (obj_struct_init_gvtx(env) != EXIT_SUCCESS)
		return (ft_error(env, __FUNCTION__, "obj_struct_init_gvtx failed"));
	if (obj_struct_init_color(env) != EXIT_SUCCESS)
		return (ft_error(env, __FUNCTION__, "obj_struct_init_color failed"));
	if (SCOP_DEBUG)
		fprintf(stdout, "OBJ_CNTS[e_face]: %d\n", OBJ_CNTS[e_face]);
	if (OBJ_CNTS[e_face] && !(OBJ_FCES = (t_face *)
								ft_memalloc(sizeof(t_face) * OBJ_CNTS[e_face])))
		return (ft_error(env, __FUNCTION__, "malloc OBJ_FCES failed"));
	if (SCOP_DEBUG)
		fprintf(stdout, "vtx_size: %zu, vtxs_nb: %d; vtxs_malloc: %zu\n",
				sizeof(t_vertex), OBJ_CNTS[e_face],
				sizeof(t_vertex) * OBJ_CNTS[e_face]);
	if (OBJ_CNTS[e_face] && !(OBJ_VTXS = (t_vertex *)
							ft_memalloc(sizeof(t_vertex) * OBJ_CNTS[e_face])))
		return (ft_error(env, __FUNCTION__, "malloc OBJ_VTXS failed"));
	debug_stdout("END", FILE_LINE_FUN);
	return (EXIT_SUCCESS);
}
예제 #16
0
파일: mlx_launch.c 프로젝트: gmange/scop
static int			expose_hook(t_env *env)
{
	debug_stdout("INIT", FILE_LINE_FUN);
	++NB_FRAME;
	if (SCOP_DEBUG)
		fprintf(stdout, "nb_frame = %d\n", NB_FRAME);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	if (fig_draw(env) != EXIT_SUCCESS)
		return (ft_error(env, __FUNCTION__, "fig_draw error"));
	mlx_opengl_swap_buffers(WIN);
	test_opengl_error("ERROR", FILE_LINE_FUN);
	return (EXIT_SUCCESS);
}
예제 #17
0
파일: dump_hexa.c 프로젝트: gmange/malloc
void			dump_hexa(void *ptr)
{
	void	*ret;

	debug_stdout("INIT", FILE_LINE_FUNC);
	debug_ptr("dump_hexa receives ptr", (const void **)&ptr);
	if (!ptr)
		return (ft_end_void(NULL, EXIT_SUCCESS, "ptr = NULL\n"));
	debug_stdout("END", FILE_LINE_FUNC);
	if (pthread_mutex_lock(&g_malloc_mutex) < 0)
		return (ft_error_void(NULL, "ERROR: mutex lock\n", __func__));
	ret = find_ptr_in_zones(ptr, 1, &print_content_hexa);
	if (pthread_mutex_unlock(&g_malloc_mutex))
		return (ft_error_void(NULL, "ERROR: mutex unlock\n", __func__));
	if (!ret && DEBUG)
	{
		print_str("_ERROR_: ptr not found\n", STDERR_FILENO, e_debug);
		debug_ptr("ret ptr ...", (const void **)&ptr);
		return (ft_error_void(NULL, "ERROR: ptr not found\n", __func__));
	}
	return ;
}
예제 #18
0
파일: mlx_launch.c 프로젝트: gmange/scop
int					mlx_launch(t_env *env)
{
	debug_stdout("INIT", FILE_LINE_FUN);
	if (!(MLX = mlx_init()))
		return (ft_error(env, __FUNCTION__, "mlx_init error"));
	if (!(WIN = mlx_new_opengl_window(MLX, WDT, HGT, TITLE)))
		return (ft_error(env, __FUNCTION__, "mlx_new_window error"));
	mlx_opengl_window_set_context(WIN);
	if (ogl_init(env) != EXIT_SUCCESS)
		return (ft_error(env, __FUNCTION__, "ogl_init error"));
	mlx_expose_hook(WIN, expose_hook, env);
	mlx_key_hook(WIN, key_hook, env);
	mlx_hook(WIN, KeyRelease, KeyReleaseMask, key_hook, env);
	if (print_tutorial(env) != EXIT_SUCCESS)
		return (ft_error(env, __FUNCTION__, "print_tutorial error"));
	mlx_hook(WIN, LASTEvent, NoEventMask, idle_hook, env);
	mlx_loop_hook(MLX, expose_hook, env);
	test_opengl_error("ERROR", __FILE__, __LINE__, "Launching MLX_LOOP");
	mlx_loop(MLX);
	return (EXIT_SUCCESS);
}