+ /* parse command aka arg[0] */
+ if(!(strncmp(arg[0],"quit",4))) {
+ valid=1;
+ sprintf(c_str,"ivac shutdown ...");
+ ivac_shutdown(ivac);
+ }
+ if(!(strncmp(arg[0],"set",3))) {
+ valid=1;
+ if((arg[1][0]>='0')&&(arg[1][0]<='9')) channel=atoi(arg[1]);
+ else channel=-1;
+ if(!(strncmp(arg[1],"name",4))) {
+ strncpy(ivac->username,arg[2],CHAR_USERNAME);
+ sprintf(c_str,"changed username to %s",ivac->username);
+ }
+ else if((channel>=0)&&(channel<MAX_CONNECTIONS)) {
+ if(ivac->net.connection[channel].status&C_IN_USE) {
+ sprintf(c_str,"channel %02d: connection in use",channel);
+ }
+ else {
+ strncpy(ivac->net.connection[channel].ip,arg[2],IP_DIGITS);
+ ivac->net.connection[channel].port=atoi(arg[3]);
+ sprintf(c_str,"channel %02d: set connection info",channel);
+ ivac->net.connection[channel].status|=C_INFO_A;
+ }
+ } else snprintf(c_str,IVAC_CONSOLE_STRING_LEN,"unknown argument: '%s'",
+ arg[1]);
+ }
+ if(!(strncmp(arg[0],"connect",7))) {
+ valid=1;
+ if((arg[1][0]>='0')&&(arg[1][0]<='9')) channel=atoi(arg[1]);
+ else channel=-1;
+ if((channel>=0)&&(channel<MAX_CONNECTIONS)) {
+ if(!(ivac->net.connection[channel].status&C_INFO_A))
+ sprintf(c_str,"channel %02d: channel not configured",channel);
+ else {
+ if(ivac->net.connection[channel].status&C_IN_USE)
+ sprintf(c_str,"channel %02d: connection in use",channel);
+ else {
+ sprintf(c_str,"channel %02d: trying to connect to %s:%d",channel,
+ ivac->net.connection[channel].ip,
+ ivac->net.connection[channel].port);
+ ivac->net.connection[channel].status|=C_IN_USE;