void print_placement(int good, int bad) { my_putstr("\nPions bien places : "); my_putnbr(good); my_putstr("\nPions mal places : "); my_putnbr(bad); my_putstr("\n"); }
void print_mouse_position() { const t_bunny_position *mouse_pos; mouse_pos = bunny_get_mouse_position(); my_putstr("Mouse position : X --> "); my_putnbr(mouse_pos->x); my_putstr(" Y --> "); my_putnbr(mouse_pos->y); my_putstr("\n"); }
void my_putnbr(int nb) { if (nb >= 10) my_putnbr(nb / 10); if ( nb < 0) { my_putchar('-'); my_putnbr(-nb); } else my_putchar((nb % 10) + 48); }
int my_aff_coord(t_coord *coord) { if (coord == NULL) return (1); my_putchar('(', 1); my_putnbr(coord->x, 1); my_putchar(',', 1); my_putnbr(coord->y, 1); my_putchar(',', 1); my_putnbr(coord->z, 1); my_putstr(")\n", 1); return (0); }
int my_verbose(t_list **l_a, t_list **l_b, char *op, int verbose) { static unsigned int i = 0; if (i && !verbose) my_putchar(' '); if (verbose) { if (i) my_putchar('\n'); my_putstr("-----\n\033[35mOperation n°"); my_putnbr(i + 1); my_putstr("\033[0m\n"); my_putstr(op); my_putstr(" :\n"); my_putstr("\033[32ml_a -> \033[0m"); my_print_list(l_a); my_putstr("\n\033[33ml_b -> \033[0m"); my_print_list(l_b); } else my_putstr(op); i++; return (i); }
void my_putnbr(int fd, int nb) { int neg; neg = 0; if (nb < 0) { my_putchar(fd, '-'); if (nb == -2147483648) { neg = -1; nb = nb + 1; } nb = nb * -1; } if (nb >= 10) my_putnbr(fd, nb /10); if (neg == -1) { neg = 0; my_putchar(fd, nb % 10 + '1'); } else my_putchar(fd, nb % 10 + '0'); }
void *malloc(unsigned int taille) { t_blk *new_blk; unsigned char psize; char val[33]; taille += sizeof(t_blk); sup_power(&taille, &psize); if (!(new_blk = get_available(psize))) { new_blk = sbrk(taille); add_blk(new_blk, psize); } else { new_blk->is_available = 0; } my_putstr("taille :\n"); my_putnbr(psize); my_putchar('\n'); conv_10_to_16(new_blk, val); my_putstr(val); my_putchar('\n'); show_alloc_mem(); return (new_blk + 1); }
int check_object_name_existence(t_list *list, int column_nb) { int count; int count_char; int count_tab; count = 0; count_char = -1; while (count != column_nb && list->line[++count_char] != '\0') if (list->line[count_char] == SEPARATOR) { count++; if (count == column_nb) { count_tab = -1; while (++count_tab != SIZE_STRUCT_TAB) if (my_strcmp_parser(&(list->line[count_char + 1]), struct_tab[count_tab].name) == 0) return (struct_tab[count_tab].nb_ref); my_puterror(WRONG_OBJECT); my_putnbr(list->line_nb); return (-1); } } return (-1); }
int game(char *code, char *pion, int tentative, int slot) { int win; int round; char buffer[24]; int len; if (check_game(code, pion, slot, tentative) == 1) return (1); my_putstr("Trouverez-vous le code secret ?\n"); round = 1; win = 0; while (tentative >= round && win != 1) { my_putstr("---\n"); write(1, "Round ", 6); my_putnbr(round); write(1, "\n>", 1); len = read(0, buffer, 23); buffer[len - 1] = 0; win = is_solution(code, buffer, pion, slot); round++; } win_msg(round - 1, win, code); free(code); free(pion); return (0); }
void print_len_err(int slot) { my_putstr("Erreur : le nombre de slot donne n'est pas correcte\n"); my_putstr("Le nombre de slot doit etre de longeur "); my_putnbr(slot); my_putchar('\n'); }
void print_player(int mode, int player) { static int turn = 0; my_putstr("Turn "); my_putnbr(++turn); my_putstr((player == 1) ? "\033[34m" : "\033[31m"); my_putstr(": Player "); my_putnbr(player); my_putstr(" ("); if ((player == 1 && mode == 0) || (winner == 2 && mode < 2)) my_putstr("IA"); else my_putstr("human"); my_putstr(")\033[0m\n"); }
int _sig_error(int pid) { my_putstr("Can't send message to PID "); my_putnbr(pid); my_putchar(10); return (EXIT_FAILURE); }
/* ** Will use our global variable */ char my_print_error(int i) { if (i > 133 || i < 0) return (my_write(g_fd, "Unknown error ", 14) + my_putnbr(i)); my_write(g_fd, g_my_tab[i], my_strlen(g_my_tab[i])); return (0); }
void print_status(int id) { if (id == 0) my_putstr("----\n"); my_putnbr(id); my_putstr(": mon etat est "); if (gl_info.status[id] == THINK) my_putstr("\"reflechi\""); else if (gl_info.status[id] == EAT) my_putstr("\"mange\"\t"); else my_putstr("\"dort\"\t"); my_putstr("\tj'ai "); my_putnbr(gl_info.hp[id]); my_putstr(" hp\n"); }
void disp_sudoku(t_root *list_cur, t_root *root, int **tab) { unsigned int i; unsigned int j; i = 0; my_putstr("|------------------|\n"); while (i < 9) { j = 0; my_putstr("| "); while (j < 9) { my_putnbr(tab[i][j]); if (j < 8) my_putstr(" "); j += 1; } my_putstr("|\n"); i += 1; } my_putstr("|------------------|\n"); if (list_cur->next != root->prev) my_putstr("####################\n"); }
/* imprime les nombres avec la base voulu */ int my_putnbr(int nombre, int base) { int flag = 0; char base16[16]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; /* tableau utilisé avec les bases */ char base_16[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; /* tableau utilisé pour le spécifieur 'X' appelé avec la base '-16' les utilisation de my_abs sont pour faire en sorte que la fonction marche même quand la base '-16' sera appelé */ if (nombre>=my_abs(base)) { my_putnbr(nombre /my_abs(base),base); } if (base<0) { my_putchar(base_16[nombre%my_abs(base)]); } else { my_putchar(base16[nombre%my_abs(base)]); } return 0; }
void my_putnbr(int nbr) { int neg; neg = 0; if (nbr < 0) { my_putchar('-'); if (nbr == -2147483648) { neg = 1; nbr++; } nbr = nbr * -1; } if (nbr >= 10) my_putnbr(nbr / 10); if (neg == 1) { neg = 0; my_putchar(nbr % 10 + '1'); } else my_putchar(nbr % 10 + '0'); }
void my_putnbr(int nb) { int neg; neg = 0; if (nb < 0) { my_putchar('-'); if (nb == -2147483648) { neg = 1; nb++; } nb *= -1; } if (nb >= 10) my_putnbr(nb / 10); if (neg == 1) { neg = 0; my_putchar(nb % 10 + '1'); } else my_putchar(nb % 10 + '0'); }
int my_putnbr(int nb) { if (nb > 9) my_putnbr(nb / 10); my_putchar(nb % 10 + '0'); return (0); }
int get_aliasing(char *nb, int line_nb, t_rt *rt) { if (nb[0] < '0' || nb[0] > '9') { my_puterror(ALIASING_BAD_ARG); my_putnbr(line_nb); return (EXIT_FAILURE); } rt->general_param.aliasing = atoi(nb); if (rt->general_param.aliasing < 1 || rt->general_param.aliasing > 30) { my_puterror(ALIASING_BAD_ARG); my_putnbr(line_nb); return (EXIT_FAILURE); } return (EXIT_SUCCESS); }
int get_threads(char *nb, int line_nb, t_rt *rt) { if (nb[0] < '0' || nb[0] > '9') { my_puterror(THREAD_BAD_ARG); my_putnbr(line_nb); return (EXIT_FAILURE); } rt->general_param.threads = atoi(nb); if (rt->general_param.threads > 4 || rt->general_param.threads < 1) { my_puterror(THREAD_BAD_ARG); my_putnbr(line_nb); return (EXIT_FAILURE); } return (EXIT_SUCCESS); }
void my_putnbr(int i) { if (i > 0) { my_putnbr(i / 10); my_putchar(i % 10 + 48); } }
int nbaff(va_list ap) { int nb; nb = va_arg(ap, int); my_putnbr(nb); return (0); }
void my_putnbr(int nbr) { if(nbr < 0) { my_putchar('-'); my_putnbr(nbr / -10); } if(nbr > 9) { my_putnbr(nbr / 10); } my_putchar((nbr < 0 ? -(nbr % 10) : nbr % 10)+ '0'); }
int flag_u(va_list list, int output, char *ptr) { uint nb; nb = va_arg(list, uint); output = output + my_putnbr(nb); return (output); }
int get_filtre(char *nb, int line_nb, t_rt *rt) { if (nb[0] < '0' || nb[0] > '9') { my_puterror(FILTER_BAD_ARG); my_putnbr(line_nb); return (EXIT_FAILURE); } rt->general_param.filter = atoi(nb); if (rt->general_param.filter < 0 || rt->general_param.filter > 10) { my_puterror(FILTER_BAD_ARG); my_putnbr(line_nb); return (EXIT_FAILURE); } return (EXIT_SUCCESS); }
int f_op(int *i, va_list *ap, int *count) { int value; *i = *i + 1; value = va_arg(*ap, double); my_putnbr(value, count); return (0); }
int main(int ac, char **av) { my_putstr("Server PID : "); my_putnbr(getpid()); my_putchar(10); signal(SIGUSR1, decrypt); signal(SIGUSR2, decrypt); while (pause()); }
int get_ambiance(char *nb, int line_nb, t_rt *rt) { if (nb[0] < '0' || nb[0] > '9') { my_puterror(AMBIANCE_BAD_ARG); my_putnbr(line_nb); return (EXIT_FAILURE); } rt->general_param.ambiance_light = atof(nb); if (rt->general_param.ambiance_light < 0 || rt->general_param.ambiance_light > 1) { my_puterror(AMBIANCE_BAD_ARG); my_putnbr(line_nb); return (EXIT_FAILURE); } return (EXIT_SUCCESS); }
void print_game(struct grid *grid) { my_putstr("____________________________\n"); display_grid(grid, false); my_putnbr(grid->flags); my_putstr(" flags\n"); my_putnbr(grid->mines); my_putstr(" mines\n"); my_putstr("What do you want to do ?\n Check a cell : coord_x coord_y\n"); my_putstr("Set/Unset a flag : -f coord_x coord_y\n Give up : exit\n"); }