static t_printf *s_ini_sgt_printf(void) { t_printf *alloc; if ((alloc = (t_printf *)malloc(sizeof(t_printf))) == NULL) ft_error_exit("Malloc", 0); alloc->buffer = NULL; alloc->len = 0; alloc->bszero = NULL; alloc->characters = NULL; s_ini_ptr_functions(&alloc); return (alloc); }
int main(void) { t_ctx *ctx; ctx = ft_ctx(); ctx->shm_key = ft_get_key(); if (ERR == ft_get_shared_mem()) ft_error_exit("Can't get shared memory"); ctx->w.mlx = mlx_init(); ctx->w.img = NULL; ctx->w.win = mlx_new_window(ctx->w.mlx, WIDTH, HEIGHT, "IPC"); ctx->shared = (t_shared *)shmat(ctx->segment_id, 0, 0); ctx->w.img = mlx_new_image(MLX, WIDTH, HEIGHT); mlx_key_hook(ctx->w.win, key_hook, ctx); mlx_loop_hook(ctx->w.mlx, ft_loop, ctx); mlx_loop(ctx->w.mlx); shmdt(ctx->shared); return (OK); }
void ft_not_builtins_fd_left(char **p, char **arg, char ***env, t_ast *ast) { int status; int i; int fildes; char **cmd; if ((i = fork()) > 0) waitpid(-1, &status, WNOHANG & WUNTRACED); else if (i == 0) { cmd = ft_strsplit(ast->right, ' '); if ((fildes = open_file(cmd[0])) == -1) ft_error_exit("{f_n_b_f_l} An error occurred while opening file"); dup2(fildes, 0); close(fildes); ft_execute(p, arg, env); } }