void main(int argc) { get_bin_cluster_id(); format_line(); while (1) { add_key_input(); send_display(buffer); /* give pointer to assembly function */ } }
void process_command() { int command_ptr = 0; initialize_array(command, 80, 0); copy_string(command, buffer + C(current_line, 2)); initialize_array(argument, ARGUMENT_HEAP_SIZE, 0); send_rs(command, 10); next_line(); if (str_equal(c_exit, command, 4)) { put_char('b'); put_char('y'); put_char('e'); send_display(buffer); halt(); } else if (str_equal(c_cd, command, 3)) { int length = copy_string(argument, command + 3); change_directory(argument, length); } else if (command[0] == 0) { return; } else { int ptr = 0; while (command[command_ptr] != ' ' && command[command_ptr] != 0 && command_ptr < COLS) { int byte = command[command_ptr]; if (byte >= 'a' && byte <= 'z') { byte -= 0x20; } program_name[ptr] = byte; command_ptr += 1; ptr += 1; } program_name[ptr] = 0; while (command[command_ptr] == ' ' && command_ptr < COLS) { command_ptr += 1; } ptr = 0; while (command[command_ptr] != ' ' && command[command_ptr] != 0 && command_ptr < COLS) { argument[ptr] = command[command_ptr]; command_ptr += 1; ptr += 1; } argument[ptr] = 0; argument[ARGUMENT_HEAP_SIZE-1] = current_directory_id; execute_bin(program_name, argument); } }
void Server::run_server() { //Buffer fuer Message message_t msg; //Queues erstellen initQueues(); write_msgid = w_msgid; read_msgid = r_msgid; // std::cout << "RUN SERVER" << std::endl; while (1 == 1) { if (msgrcv(r_msgid, &msg, sizeof(message_t) - sizeof(long), 0 , 0) == -1) { /* error handling */ std::cout << "Cant' receive message" << std::endl; } switch (msg.mType) { case 'R': regVehicle(msg.mText, msg.mPID); send_display(gridToString(grid)); break; case 'N': case 'W': case 'S': case 'E': moveVehicle(msg.mText, msg.mType); send_display(gridToString(grid)); break; case 'T': removeVehicle(msg.mText); send_display(gridToString(grid)); break; default: break; } } return; }
void main(int argc) { char input = 0; read(); while (1) { input = read_key(); /* blocking */ if (insert_mode == 1) { switch (input) { case '\n': insert_character(input); break_line(); break; case 0x7f: if (current_column > 0) { int current_char = 0; current_column -= 1; current_char = buffer[C(current_line, current_column)]; if (current_column >= 0 && current_char != EOF && current_char != EOL) { move_memory(buffer + C(current_line, current_column), -1, COLS - current_column - 1); buffer[C(current_line, COLS-1)] = 0; } } break; case 27: // esc insert_mode = 0; // set_string(notifications, "COMMAND"); break; default: if (input != 0) { insert_character(input); } break; } } else { if (interpret_command(input) == 1) { return 0; } } // update_notification_line(); send_display(buffer); /* give pointer to assembly function */ display(C(current_line, current_column), '_'); } }