int fill_vertex(t_ply *ply, t_ply_info *info, int fd) { int i; char *str; char **tab; i = -1; while (++i < info->nb_vertex && (str = get_next_line(fd))) { if (!(tab = str_to_wordtab(str, ' ')) || count_tab(tab) < count_prop(info->vertex_prop, NB_V_VAR)) return (1); ply->list_vertex[i].vec.x = (info->vertex_prop[V_X] == -1) ? 0 : my_getdouble(tab[info->vertex_prop[V_X]]); ply->list_vertex[i].vec.y = (info->vertex_prop[V_Y] == -1) ? 0 : my_getdouble(tab[info->vertex_prop[V_Y]]); ply->list_vertex[i].vec.z = (info->vertex_prop[V_Z] == -1) ? 0 : my_getdouble(tab[info->vertex_prop[V_Z]]); if (parse_color_vertex (&ply->list_vertex[i].color, tab, info->vertex_prop, &ply->list_vertex[i].get_color)) return (1); my_free(tab); my_free(str); } return (0); }
int fill_face(t_ply *ply, t_ply_info *info, int fd) { int i; int j; int count; int size; char *str; char **tab; i = -1; count = count_prop(info->face_prop, NB_F_VAR); while (++i < info->nb_face && (str = get_next_line(fd))) { j = 0; if (!(tab = str_to_wordtab(str, ' ')) || (size = count_tab(tab)) < count) return (1); ply->list_face[i].face = (info->face_prop[F_VERTICES_INDICES] == -1) ? NULL : add_list_face(tab, &j, &ply->list_face[i].nb_face, size); ply->list_face[i].texcoord = (info->face_prop[F_TEXCOORD] == -1) ? NULL : add_list_texcoord(tab, &j, &ply->list_face[i].nb_tex, size); ply->list_face[i].texnumber = (info->face_prop[F_TEXNUMBER] == -1) ? 0 : (F_TEXNUMBER + j >= size) ? 0 : my_getnbr(tab[info->face_prop[F_TEXNUMBER] + j]); my_free(tab); my_free(str); } return (0); }
int send_private(t_client *client) { int pos; if (count_tab(client->tab) < 3) return (derrorn("/msg usage: /msg _nickname_ _message_")); pos = recup_msg(client->buffer_in); snprintf(client->buffer_out, 512, "PRIVMSG %s :%s", client->tab[1], client->buffer_in + pos); client->action = WRITE; return (0); }
float find_maxlat(char** col){ int i,n; float collat, latmaxf; latmaxf = (float)(atof(col[10])); n = count_tab(col); for(i=1;i<n-1;i++){ collat = (float)(atof(col[i])); if(collat>latmaxf&&(collat-latmaxf)<2){ // corrige des erreur latmaxf= collat;//printf("latmaxf collone:%d value= %f\n",i,latmaxf); } } return latmaxf; }
int display_tab(char **tab) { int i = count_tab(tab); if (i == 0) return (-1); while (--i >= 0) { if (25 -i < 10) printf("[%d] %s\n",25 - i, tab[i]); else printf("[%d] %s\n",25 - i, tab[i]); } return (1); }
int chanli(t_client *client) { int i; i = 0; printf("Current-- %s - %d\nTotal-- %d\n\n-------------\n", client->channel[client->current_chan], client->current_chan + 1, count_tab(client->channel)); while (i < MAXCHAN) { if (client->channel[i] != NULL) printf("%s ---\t\t%d\n", client->channel[i], (i + 1)); ++i; } return (0); }
void do_connect(gchar *cmd, gpointer data) { gchar **tab; tab = wordtab(cmd); if (count_tab(tab) < 2) add_text("/server ip port \n", data); else { if (try_connect(tab, data)) add_text("Connected succesfully \n", data); else add_text("Error while trying to connect \n", data); } free_tab(tab); }
float find_maxlon(char** col){ float lonmaxf,collat; int i,ne1; lonmaxf = (float)(atof(col[10])); //printf("lonmaxf value commence a ligne 10 = %f\n",i,lonmaxf); ne1 = count_tab(col); for(i=1;i<ne1-1;i++){ collat = (float)(atof(col[i])); if(collat>lonmaxf&&(collat-lonmaxf)<2){ lonmaxf= collat;//printf("lonmaxf collone:%d value= %f\n",i,lonmaxf); } } return lonmaxf; }
float find_minlon(char** col){ float lonminf, collat;; int i,n; lonminf = (float)(atof(col[10])); n = count_tab(col); for(i=1;i<n-1;i++){ collat = (float)(atof(col[i])); if(collat<lonminf&&(lonminf-collat)<2){ lonminf= collat;//printf("lonminf collone:%d value= %f\n",i,lonminf); } } return lonminf; }
float find_minlat(char** col){ int i,n; float collat, latminf; latminf = (float)(atof(col[10])); //printf("flasfffffhhhhhhhhh\n"); n = count_tab(col); for(i=1;i<n-1;i++){ collat = (float)(atof(col[i])); if(collat<latminf&&(latminf-collat)<2){ latminf= collat;//printf("latminf collone:%d value= %f\n",i,latminf); } } return latminf; }
void fill_cam(t_overview *over, char *trim) { char **tab; tab = ft_strsplit(trim, ' '); if (count_tab(tab) < 7) { ft_putendl("Error cam parsing"); exit(0); } over->cam.x = ft_atof(tab[1]); over->cam.y = ft_atof(tab[2]); over->cam.w = ft_atof(tab[3]); over->dir.x = ft_atof(tab[4]); over->dir.y = ft_atof(tab[5]); over->dir.w = ft_atof(tab[6]); }
int pipe_parsing(char *str) { char **tab_pipe; int ret; int tab_len; if (!valid_str(str) || !last_verif(str)) return (0); if (in_str(str, token_val("|")) && (tab_pipe = str_to_wordtab(str, token_val("|")))) { tab_len = count_tab(tab_pipe); ret = exec_pipe(tab_pipe, tab_len); free(tab_pipe); } else ret = parse_command_redir(str); return (ret); }
static void the_exit(char *cmd) { char **env; char **tab; int leave; leave = 1; tab = ft_strsplit(cmd, ' '); ft_printf("%sexit %s:'(%s\n", c(PINK), c(GRBL), c(NO)); if (tab[1] && !ft_strisint(tab[1])) ft_printf("42sh: exit: %s: numeric argument required\n", tab[1]); if (count_tab(tab) > 2) { ft_putendl("42sh: exit: too many arguments\n"); if (ft_strisint(tab[1])) leave = 0; } env = get_env(NULL); free_tab(&env); leaving(tab, leave); }
void send_msg(gchar **tab, gchar *cmd, gpointer data) { int len; gchar *msg; t_supinfo *supinfo; supinfo = (t_supinfo *)data; if (count_tab(tab) < 3) return ; cmd += strlen(tab[1]) + strlen(CMD_MSG); len = strlen(tab[1]) + strlen(cmd) + 3 + 1 + 1; msg = g_malloc(len); g_strlcpy(msg , "49[", 4); g_strlcat(msg, tab[1], strlen(tab[1]) + 4 + 1); g_strlcat(msg, "[", strlen(tab[1]) + 4 + 1); g_strlcat(msg, cmd, len); msg[2] = '\0'; msg[3 + strlen(tab[1])] = '\0'; g_printf("Msg %s \n", msg); if (send(supinfo->info_cli->s, msg, len, 0) == -1) add_text("Error sending message \n", data); g_free(msg); }