void process_line(longint_t vars[], char *line) { int varnum, optype, status; longint_t second_value; /* determine the LHS variable, it * must be first character in line */ varnum = to_varnum(line[0]); if (varnum==ERROR) { printf("Invalid LHS variable\n"); return; } /* more testing for validity */ if (strlen(line)<2) { printf("No operator supplied\n"); return; } /* determine the operation to be performed, it * must be second character in line */ optype = line[1]; if (strchr(ALLOPS, optype) == NULL) { printf("Unknown operator\n"); return; } /* determine the RHS argument (if one is required), * it must start in third character of line */ if (optype != PRINT) { if (strlen(line)<3) { printf("No RHS supplied\n"); return; } status = get_second_value(vars, line+2, &second_value); if (status==ERROR) { printf("RHS argument is invalid\n"); return; } } /* finally, do the actual operation */ if (optype == PRINT) { do_print(vars+varnum); } else if (optype == ASSIGN) { do_assign(vars+varnum, &second_value); } else if (optype == PLUS) { do_plus(vars+varnum, &second_value); } else if (optype == MULT) { do_mult(vars+varnum, &second_value); } else if (optype == POWER) { do_power(vars+varnum, &second_value); } return; }
static void do_control_request(int direction) { switch (USB_ControlRequest.bRequest) { case REQUEST_REGISTER: do_register(direction, USB_ControlRequest.wValue); break; case REQUEST_FREQUENCY: do_frequency(direction, USB_ControlRequest.wValue); break; case REQUEST_RXTX_MODE: do_rxtx_mode(direction, USB_ControlRequest.wValue); break; case REQUEST_MODINDEX: do_modindex(direction, USB_ControlRequest.wValue); break; case REQUEST_CSMA_RSSI: do_csma_rssi(direction, USB_ControlRequest.wValue); break; case REQUEST_POWER: do_power(direction, USB_ControlRequest.wValue); break; case REQUEST_AFC: do_acf(direction, USB_ControlRequest.wValue); break; case REQUEST_IFBW: do_ifbw(direction, USB_ControlRequest.wValue); break; case REQUEST_TRAINING: do_training(direction, USB_ControlRequest.wValue); break; case REQUEST_SYNCWORD: do_syncword(direction, USB_ControlRequest.wValue); break; case REQUEST_BITRATE: do_bitrate(direction, USB_ControlRequest.wValue); break; case REQUEST_TX: do_tx(direction, USB_ControlRequest.wValue); break; case REQUEST_RX: do_rx(direction, USB_ControlRequest.wValue); break; case REQUEST_TX_FREQUENCY: do_tx_frequency(direction, USB_ControlRequest.wValue); break; case REQUEST_RX_FREQUENCY: do_rx_frequency(direction, USB_ControlRequest.wValue); break; case REQUEST_SERIALNUMBER: do_serialnumber(direction, USB_ControlRequest.wValue); break; case REQUEST_FWREVISION: do_fw_revision(direction, USB_ControlRequest.wValue); break; case REQUEST_RESET: reboot(); break; case REQUEST_DFU: jump_to_bootloader(); break; } }