void print(t_inst *inst, t_label *label, t_n_c *n_c) { t_inst *tmp; int i; i = 0; tmp = inst; print_n_label(n_c, label); ft_put("\n=======INSTRUCTIONS=======\n\n", RED); while (tmp) { i = 0; ft_put("ID : ", GREEN); ft_putnbr(tmp->id); ft_put(" OPCODE : ", YELLOW); ft_putnbr(tmp->opcode); print_par(tmp, i); if (tmp->error) { ft_putstr(" | INST ERROR : "); ft_putstr(tmp->error); } ft_putchar('\n'); tmp = tmp->next; } }
int ft_putwchar(wchar_t *w, t_format *lst) { int size; int *t; char *str; str = NULL; t = ft_cntwchar(&w, lst->precision); size = ft_sum(t); if (lst->width <= size) ft_put(w, t); else if (lst->just == '-') { ft_put(w, t); ft_putstr(str = ft_wh(' ', lst->width - size)); } else { ft_putstr(str = ft_wh(lst->just, lst->width - size)); ft_put(w, t); } ft_memdel((void**)&t); size += ft_strlen(str); ft_strdel(&str); free(w); return (size); }
void print_par(t_inst *tmp, int i) { while (tmp->par) { if (tmp->par->size == 4) { ft_put(" Par ", RED); ft_put(ft_strjoin(ft_itoa(i), " : "), RED); ft_putnbr(*(int *)tmp->par->p); } else if (tmp->par->p != NULL) { ft_put(" Par ", RED); ft_put(ft_strjoin(ft_itoa(i), " : "), RED); ft_putstr((char *)tmp->par->p); } if (tmp->par->error != NULL) { ft_putstr(" | ERROR : "); ft_putstr(tmp->par->error); ft_putchar('\n'); } tmp->par = tmp->par->next; i++; } }
void print_n_label(t_n_c *n_c, t_label *label) { t_n_c *tmp4; t_label *tmp2; tmp4 = n_c; tmp2 = label; if (tmp4) { ft_put("\nName : ", GREEN); ft_putstr(tmp4->name); ft_put("\nComment : ", GREEN); ft_putstr(tmp4->comment); } ft_put("\n\n=======LABEL=======\n", RED); while (tmp2) { ft_put("\nLabel : ", YELLOW); ft_putstr(tmp2->name); if (tmp2->error != NULL) { ft_putstr("\nLabel ERROR : "); ft_putstr(tmp2->error); } ft_putchar('\n'); tmp2 = tmp2->next; } }
int main(int ac, char **av) { t_env e; ft_singleton(&e); e.lvl_list = NULL; if (!check_levels(ac, av, &e) || !glfwInit()) return (-1); e.maxscore = 0; e.lvl = 0; e.window = glfwCreateWindow(WINX, WINY, "Arkanoid", NULL, NULL); if (!e.window) { glfwTerminate(); return (-1); } glfwMakeContextCurrent(e.window); init_hooks(&e); ft_start_game(&e); while (!glfwWindowShouldClose(e.window) && e.state) { rule_them_all(&e); glfwPollEvents(); } glfwTerminate(); ft_put(e); return (0); }
int main(int ac, char **av) { int sock; char buf[1023]; int r; if (ac != 3) usage(av[0]); sock = ft_create_client(av[1], ft_atoi(av[2])); while (1) { write(1, "$> ", 3); r = read(0, buf, 1023); buf[r - 1] = 0; write(sock, buf, r); if (ft_strcmp(buf, "quit") == 0) break ; if (ft_strncmp(buf, "put", 3) == 0) { r = test(sock); if (r > -1) { ft_put(buf, sock); ft_putstr("SUCCESS\n"); } } else if (ft_strncmp(buf, "get", 3) == 0) ft_get(buf, sock); else test(sock); } close(sock); return (0); }
int ft_putlnbr(long int n) { int ret; ret = 0; if ((unsigned long int)n == -9223372036854775808U) { write(1, "-9223372036854775808", 20); ret += 20; } else ret = ft_put(n, ret); return (ret); }
void ft_putnb_base(long long int n, char *base) { if (n == -9223372036854775807 - 1) ft_put("-9223372036854775808"); else if (n < 0) { ft_putchar('-'); ft_putnb_base(-n, base); } else if (0 <= n && n < ft_strlen(base)) ft_putchar(base[n]); else { ft_putnb_base(n / ft_strlen(base), base); ft_putnb_base(n % ft_strlen(base), base); } }
static void execcmd(char *buf, int sock) { if (ft_strcmp("quit", buf) == 0) { close(sock); exit(0); } else if (ft_strncmp(buf, "get ", 4) == 0) ft_get(sock, buf); else if (ft_strncmp(buf, "put ", 4) == 0) ft_put(sock, buf); else if (ft_strncmp(buf, "help", 4) == 0) { ft_bzero(buf, 1024); ft_help(); } else ft_putendl("ERROR"); }