int key_mouse(int key, int x, int y, t_infos *i) { double x_real; double y_real; if (y > 0) { x_real = (x / i->zoom) + i->x1; y_real = (y / i->zoom) + i->y1; if (key == 4) { i->zoom *= 1.1; i->x1 = x_real - (x / i->zoom); i->y1 = y_real - (y / i->zoom); i->i_max += 1; parsing(i); } if (key == 5) { i->zoom /= 1.1; i->x1 = x_real - (x / i->zoom); i->y1 = y_real - (y / i->zoom); i->i_max -= 1; parsing(i); } } return (0); }
void gest_semicolon(char *s, int i, int fd_enter, t_main **env) { char *s1; char *s2; if ((s1 = manage_spaces(my_selection(s, 0, i))) == NULL || ((s2 = manage_spaces(s + i + 1)) == NULL)) exit(-1); parsing(s1, fd_enter, env); parsing(s2, fd_enter, env); }
int main(int ac, char **av) { t_env e; e.inf.h = 0.2; e.div = 2; if (ac >= 2 && ac <= 7) { if (ft_strcmp(av[1], "-help") == 0) aff_help(); e.mlx = mlx_init(); init_env(&e); read_args(&e, ac, av); parsing(&e, av[1]); e.inf.scale = (((e.arg.winx + e.arg.winy) / (e.p.lenx + e.p.leny)) / 2); e.inf.scale = e.inf.scale <= 0 ? 0.8 : e.inf.scale; e.orix = e.arg.winx / 2; e.oriy = e.arg.winy / e.p.leny; backup(&e); draw(&e); } else aff_help(); return (0); }
void change(t_infos *i) { i->first = 0; i->num++; (i->num > 8) ? i->num = 1 : 0; parsing(i); }
int gest_separators(char *s, int i, int fd_enter, t_main **env) { char *s1; char *s2; s1 = manage_spaces(my_selection(s, 0, i)); s2 = manage_spaces(s + i + 2); parsing(s1, fd_enter, env); if (s[i] == '&' && exec_ret == 8) return (0); else if (s[i] == '|' && exec_ret != 8) return (0); parsing(s2, fd_enter, env); free(s1); return (0); }
void push_swap(char **argv) { t_data data; data.space = 0; data.nbr_mv = 0; if (arguments_checker(argv) == 0) return (ft_error(0)); if (ft_strcmp(argv[1], "-v") == 0) { parsing_flag(argv, &data); print_etat(&data); if (opti_solve(&data) == 1) brute_solve(&data); print_etat(&data); } else { parsing(argv, &data); if (opti_solve(&data) == 1) brute_solve(&data); } free(data.stack_a); free(data.stack_b); }
int main(int ac, char **av, char **env) { char *s; ac = ac; av = av; my_env = tab_to_list(env); while (42) { if (signal(SIGINT, sig_handler) == SIG_ERR) printf("Error while trying to catch SIGINT.\n"); prompt(my_env); s = get_next_line(0); if (s != NULL) { if (strlen(s) != 0) parsing(s, 0, &my_env); free(s); } else break ; } my_free_list(my_env); return (0); }
int main(int argc, char **argv) { t_env *e; t_objs *obj; if (argc == 2) { e = (t_env *)malloc(sizeof(t_env)); obj = (t_objs *)malloc(sizeof(t_objs)); if (!e || !obj) ft_error("Malloc error", 2); if (!(init_env(e))) return (0); if (!extension(argv[1])) ft_error("File need .rt extension", 2); if (!(obj = parsing(argv[1], e, obj))) ft_error("Parsing error", 2); obj = manage_data(e, obj); e->begin_list = obj; mlx_expose_hook(e->win, expose_hook, e); mlx_key_hook(e->win, key_events, e); mlx_loop(e->mlx); } return (0); }
int print_var(const char **format, va_list ap) { int ret; t_opt opt; int conv; int i; bzero_opt(&opt); i = 0; while (!ft_check_charset(**format, CONV)) { parsing(format, &opt, &ret); if (!ret) break ; } if (!(conv = get_conv(format, ap, &opt))) { print_before(opt, &i, &ret); ft_putchar(**format); print_after(opt, &i, &ret); (*format)++; return (ret); } modify_len(&opt); ret = print(opt); (*format)++; return (ret); }
void redirection(int placeFichier){ // Ouvre le fichier dans le quel on veux rediriger la sortie int descFichierCible = open( commandeParse[placeFichier], O_WRONLY | O_APPEND | O_CREAT, 0666 ); // Test si le fichier c'est correctement ouvert if( descFichierCible < 0 ) { fprintf(stderr,"ERREUR: Ouverture fichier %s. \n", commandeParse[placeFichier]); return; } else { // Sauvegarde la sortie standard int oldout = dup(1); dup2(descFichierCible,1); close(descFichierCible); // On exécute la commande du coup on supprime la redirection char * buffer = NULL; buffer = (char*) malloc (1024 * sizeof(char)); strcpy(buffer,commandeParse[0]); int i; for(i=1; i< (placeFichier-1); i++){ strcat(buffer," "); strcat(buffer,commandeParse[i]); } commande = malloc(sizeof(buffer)); strcpy(commande, buffer); parsing(); dup2(oldout,1); close(oldout); free(buffer); } }
void main() { init_List(); FILE* fp = fopen("test.txt", "rb"); char buff[1000]; //fread(buff, 1, sizeof(buff), fp); int i = 0; while (!feof(fp) && i< MOVIE_NUM) { if (buff != NULL) { fgets(buff, 1000, fp); parsing(buff, i++); } } fclose(fp); for (i = 0; i < MOVIE_NUM; i++) { //printf("%s %d %d %s %s %s %s\n", chart[i]->name, chart[i]->audience, chart[i]->screen_num, chart[i]->nation, chart[i]->genre[0], chart[i]->director, chart[i]->actors[0]); //for(int j =0; j<3; j++)if(chart[i]->actors[j]!=NULL)printf("%s\n", chart[i]->actors[j]); } i = 0; makeVisit(); genre_heap* heap = createGenreHeap(20); for (i = 0; i < 20; i++) { insertHeap(heap, *genres[i]); } for (i = 0; i < 20; i++){ printf("%s - %d\n", deletHeap(heap).name, deletHeap(heap).genre_count); } /*while (genres[i]->name != NULL) { printf("%s -%d\n", genres[i]->name, genres[i]->genre_count); i++; } while (actors[i]->name != NULL) { printf("%s -%d\n", actors[i]->name, actors[i]->avg_aud); i++; }*/ }
__interrupt void H5_UART0IT(void) // Interrupt accepts packet, processes, prints via the putchar function, and continues on { __disable_interrupt(); //disable interrupt and continue with the processing of packet //The following code gives the user the state of the 3 buffers //while(!(UCSR0A & 0x80)); //while UCSR1A is not 1000 0000, do nothing (THIS IS USART RECEIVE COMPLETE FLAG! IT TURNS TO 1 WHEN THE PACKET RECEIVE IS COMPLETE) //otherwise, once UCSR1A is 1000 0000, (PACKET IS RECEIVED AND SITTING IN UDR1 READY FOR USE) data = UDR0; //set data equal to UDR1 - where the packet is sitting putchar(data); //run this packet character by character through the putchar function if (data == '$'){ //first character of packet save_on = 1; //set save_on to 1, we will fill the c array with the packet, character by character } else if (data == '@'){ //otherwise if 'data' is @ symbol, last character of packet packet_data[ii] = NULL;//set that final character to null char ms_delay(100); //wait 100 milliseconds and then set the flag to allow TWI to commence. pure_transmissions_only = 1; //set the flag to allow the TWI transmissions to commence. save_on = 0; //set save_on to 0, we will not be filling any more characters of the array 'c' if(strcmp(packet_buff1,comparator) == 0){ //if buffer 1 is empty, fill it strcpy(packet_buff1,packet_data); //printf("I loaded buffer 1\n\r"); } else if ((strcmp(packet_buff1,comparator) != 0) && (strcmp(packet_buff2,comparator) == 0)){ //otherwise if buffer 1 is full and 2 is empty, fill 2 strcpy(packet_buff2,packet_data); //printf("\n\rI loaded buffer 2\n\r"); } else if ((strcmp(packet_buff1,comparator) != 0) && (strcmp(packet_buff2,comparator) != 0) && (strcmp(packet_buff3,comparator) == 0)){ //otherwise if buffer 1 and 2 are full and 3 is empty, fill 3 strcpy(packet_buff3,packet_data); //printf("I loaded buffer 3\n\r"); } //while(strcmp(packet_buff1,comparator) == 0); //wait up while the first buffer is empty parsing(packet_buff1); //enter the parsing function with the next-in-line buffer //printf("I processed buffer 1\n\r"); if(strcmp(packet_buff2,comparator) != 0){ strcpy(packet_buff1,packet_buff2); //move contents from buffer 2 into buffer 1 //printf("I moved 2 into 1\n\r"); strcpy(packet_buff2,comparator); //re-initialize buffer 2 } if(strcmp(packet_buff3,comparator) != 0){ strcpy(packet_buff2,packet_buff3); //move contents from buffer 3 into buffer 2 //printf("I moved 3 into 2\n\r"); strcpy(packet_buff3,comparator); //re-initialize buffer 3 } ii=0; //reset the counter return; //end and wait for next packet } if (save_on ==1){ packet_data[ii++] = data; //since data (UDR1) is only getting 1 character at a time in serial, this sets each character of the c array to the incoming character in UDR1 before it receives the next character } __enable_interrupt(); //enable the interrupt again and wait for next packet }
int init_parsing(t_all *infos, char **av) { int i; i = 0; while (av[++i] != 0) if (parsing(infos, av[i]) == -1) return (-1); return (0); }
int main(){ // stringPrint(); // stringIO(); // StringComparision(); // stringCopy(); // stringCmp(); // stringConcat(); // scanLine(); parsing(); }
void SVGDocument::close() { bool doload = !parsing() && m_tokenizer; DocumentImpl::close(); if (doload) { document()->dispatchWindowEvent(DOM::EventImpl::LOAD_EVENT, false, false); } }
int main (int argc, char **argv) { string user; //user name char* host = (char*)malloc(300); //host name if (getlogin() != NULL) { user = getlogin(); } else { perror("Error with getting user"); } if (gethostname(host, 300) == -1) { perror("Error with getting host name"); } //cout << host << endl; while (true) { BEGINNING: string cmd; string test = "test"; string bracket = "["; cout << user << "@" << host <<"$ "; getline(cin, cmd); parsing(cmd); if(AreParenBal(cmd) == false) { perror("Parenthesis not balanced\n"); goto BEGINNING; } char* b[MEMORY]; //character array that stores commands char command[MEMORY]; //char array that holds the converted command //cout << "Copying \n"; for(unsigned i =0; cmd[i] != '\0'; i++) { command[i] = cmd[i]; } command[cmd.length()] = '\0'; for (unsigned i = 0; command[i] != '\0'; i++) //outputs user input { cout << command[i]; } cout << endl; commandsort(command, b); queue<string> connectors; cout << "Executing commands\n"; executecmd(b, connectors); cout << "Executing done\n"; } free (host); return 0; }
void manage_father(int fd_enter, char *s2, t_main **env) { int save_stdin; save_stdin = dup(0); dup2(fd_enter, 0); parsing(s2, fd_enter, env); dup2(save_stdin, 0); close(fd_enter); close(save_stdin); }
int _tmain(int argc, _TCHAR* argv[]) { printf("Enter your exprexxion\n"); std::string h; std::getline(std::cin, h); if (parsing(h.c_str())) printf("all right, input something to exit\n"); else printf("fail, input something to exit\n"); scanf("%*s"); return 0; }
int main(int args, char** argv){ map<string,Nodes*> function_map; vector<string> command_list; command_list.push_back("define"); command_list.push_back("evaluate"); command_list.push_back("numint"); command_list.push_back("mcint"); command_list.push_back("max"); command_list.push_back("min"); string shell_input; if(args==1){ while(!getline(cin,shell_input).eof()){ parsing(shell_input,command_list,function_map); } } else if(args==2){ ifstream input; input.open(argv[1]); if(input.fail()){ perror("Could not open file"); return EXIT_FAILURE; } while(!getline(input,shell_input).eof()){ parsing(shell_input,command_list,function_map); } input.close(); } else{ cerr<<"Could only enter less than one argument"<<endl; return EXIT_FAILURE; } map<string,Nodes*>::iterator it; for(it=function_map.begin();it!=function_map.end();it++){ delete it->second; } return EXIT_SUCCESS; }
int main(int argc, char **argv) { int nb_list; t_content *axx; int x; nb_list = ft_nb_list(argc, argv); axx = parsing(argc, argv, nb_list); main_pos(axx, nb_list); projection_parallele(axx, nb_list); draw(axx, nb_list); LIST_R(0); return (0); }
int main(int argc, char **argv) { t_game game; char **keys; WINDOW *win; t_board board; if ((game.list = parsing()) == NULL || options(&game, argv) == 1) return (1); data_board_initialize(&board, game.list, &game); srand(time(NULL)); if ((aff_tetris(0, &board, game.list, &game)) == -1) write(2, "The screen size must be highter\n", 32); return (0); }
void manage_son(int fd_enter, int fd_sortie, char *s1, t_main **env) { int save_stdin; int save_stdout; save_stdout = dup(1); save_stdin = dup(0); dup2(fd_sortie, 1); dup2(fd_enter, 0); parsing(s1, fd_sortie, env); dup2(save_stdin, 0); dup2(save_stdout, 1); close(save_stdin); close(save_stdout); close(fd_sortie); close(fd_enter); exit(0); }
json_object json_parse(wchar_t json[],wchar_t **message,long* error_pos) { parse_engine result; result.data.type = NONE; result.pos = json; result.json = json; if (parsing(&result, &result.data)) { if(message) *message = result.message; json_object_free(&result.data); if(error_pos) *error_pos = result.pos - result.json; json_object null_item; null_item.type = NONE; return null_item; } if(message) *message = (wchar_t *)L"SUCCEED"; if(error_pos) *error_pos = 0; return result.data; }
char lireCommande(){ char buffer[1024]; /* Lit l'entrée standard et quitte si l'utilisateur utilise CTRL + D */ if(!fgets(buffer, sizeof(buffer)-1, stdin)){ exit(1); } /* Supprime le \n a la fin du buffer */ char *p = strchr(buffer, '\n'); if(p) { *p = 0; } /* Alloue l'espace au pointeur commande et y ajoute la commande */ commande = malloc(sizeof(buffer)); strcpy(commande, buffer); parsing(); }
void UDPClient::service() { char sendBuffer[ECHOMAX] = {}; // Buffer for send string (send) this->sendString.copy(sendBuffer, sendString.length(), 0); int echoStringLen; // Length of string to echo echoStringLen = strlen(sendBuffer); if (echoStringLen > ECHOMAX) { // Check input length cerr << "Echo string too long" << endl; exit(1); } //unsigned short echoServPort = Socket::resolveService("echo", "udp"); try { UDPSocket sock; // Send the string to the server sock.sendTo(sendBuffer, echoStringLen, servAddress, echoServPort); // Receive a response respStringLen = sock.recv(echoBuffer, ECHOMAX); // Length of received response echoBuffer[respStringLen] = '\0'; // Terminate the string! //cout << "Received: " << echoBuffer << endl; // Print the echoed arg if(respStringLen > 0) { response = echoBuffer; parsing(); //string temp; //std::stringstream os(response); //os >> temp; } // Destructor closes the socket //sock.disconnect(); //sock.cleanUp(); } catch (SocketException &e) { cerr << e.what() << endl; exit(1); } }
int main(int ac, char **av) { unsigned int op; t_tree *elem; t_tree *err; struct stat tmp; op = 0; elem = NULL; err = NULL; if (ac > 1) op = parsing((const char **)av, &elem, &err); if (!elem && !err && (lstat(".", &tmp) != -1)) { elem = build_elem(op, tmp); ((t_data *)(elem->content))->arg = 0; } ft_ls(elem, op); return (0); }
int main(int ac, char **av) { t_env e; init_env(&e); parsing(&e, ac, av[1]); init_eye(&e); get_lightspot_number(&e); init_viewpoint(&e); e.v = 0; e.v2 = 0; e.nl = 1 / e.nl; e.mlx = mlx_init(); e.win = mlx_new_window(e.mlx, e.width, e.height, e.name); ray_tracer(&e); mlx_expose_hook(e.win, expose_hook, &e); mlx_key_hook(e.win, event_mlx, &e); mlx_loop(e.mlx); return (0); }
void Plazza::start() { draw_menu(); draw_log(); char buff[4096]; std::string line; while (line != "quit") { printEcrased(); move(40, 2); clrtoeol(); getstr(buff); line.assign(buff); parsing(line); distrib(); wclrtoeol(_footer); } }
/* Loop function ------------------------------*/ void loop(){ /*Local Logical Variable ------------------*/ char buf = '\0'; int spot = 0, p_code; Comand receivedcomand; //Reading cycle while(VCP_read(&buf,1) != 0){ if(buf!='\n'){ sprintf(&request[spot], "%c", buf ); spot += 1; } } if(strlen(request) != 0){ if(parsing(&receivedcomand) == 1) {/*TODO: gestione errori di ricezioni*/} execComand(receivedcomand); } //Reset the request string memset(request, '\0', strlen(request)); //TODO: Letture periodiche }
int do_include(t_all *all, t_list *list, UNUSED FILE *fd, int *err) { list = list->next; while (list != NULL && list->type != END) { if (strcmp(list->lexeme, "file") != 0 || (list = list->next) == NULL || (list = list->next) == NULL || (list = list->next) == NULL) { *err = -1; return (0); } if (parsing(all, list->lexeme) == -1 || (list = list->next) == NULL || (list = list->next) == NULL) { *err = -1; return (0); } } return (0); }