From: hackbard Date: Mon, 8 Nov 2004 10:13:55 +0000 (+0000) Subject: gui parsing input fixes X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=dfb3695b3cbe16607a7afa5e2eeefe4d7994c863;p=physik%2Fnlsop.git gui parsing input fixes --- diff --git a/nlsop_gui.c b/nlsop_gui.c index 94e9fd8..ec9de6d 100644 --- a/nlsop_gui.c +++ b/nlsop_gui.c @@ -145,6 +145,7 @@ int send_job(t_net *net,t_input *input,t_display *display) { char command[MAX_CONTENT]; int x,y,z; info info; + char *ptr; /* default values */ x=_X; @@ -163,51 +164,53 @@ int send_job(t_net *net,t_input *input,t_display *display) { info.dr_ac=DR_AC; strncpy(command,input->content,MAX_CONTENT); + ptr=command; - strtok(command," "); - while(strtok(NULL," ")!=NULL) { - switch(command[0]) { + ptr=strtok(command," "); + while((ptr=strtok(NULL," "))!=NULL) { + switch(ptr[0]) { case 'b': - info.b=atof(command+1); + info.b=atof(ptr+1); break; case 'c': - info.c=atof(command+1); + info.c=atof(ptr+1); break; case 's': - info.s=atof(command+1); + info.s=atof(ptr+1); break; case 'd': - info.diff_rate=atoi(command+1); + info.diff_rate=atoi(ptr+1); break; case 'D': - info.dr_ac=atof(command+1); + info.dr_ac=atof(ptr+1); break; case 'S': - info.steps=atoi(command+1); + info.steps=atoi(ptr+1); break; case 'C': - info.cpi=atoi(command+1); + info.cpi=atoi(ptr+1); break; case 'r': - info.range=atoi(command+1); + info.range=atoi(ptr+1); break; case 'R': - info.s_rate=atoi(command+1); + info.s_rate=atoi(ptr+1); break; case 'x': - info.save_rate=atoi(command+1); + info.save_rate=atoi(ptr+1); break; case 'X': - x=atoi(command+1); + x=atoi(ptr+1); break; case 'Y': - y=atoi(command+1); + y=atoi(ptr+1); break; case 'Z': - z=atoi(command+1); + z=atoi(ptr+1); break; default: display_new_line(display,input,"unknown command"); + dprintf(display->outfd,"unknown command %s\n",ptr); break; } } @@ -221,6 +224,12 @@ int send_job(t_net *net,t_input *input,t_display *display) { network_send_chan(net,0,(unsigned char *)&info,sizeof(info)); + display_new_line(display,input,"added new job:"); + snprintf(command,MAX_CONTENT,"b:%f | c:%f | s:%f | d: %d %f | %d", + info.b,info.c,info.s,info.diff_rate,info.dr_ac,info.steps); + display_new_line(display,input,command); + + return 1; }