int main(void) { ssize_t ret = 0; int order_id = INITIAL_ORDER_ID; gen_result_bufs(); while (TRUE) { ret = receive_input(); if (0 > ret) { goto check_res; } send((char *)&order_id, sizeof(order_id)); if (0 == memcmp(INPUT_TYPE_PLAIN, (const char *)in->type, sizeof(INPUT_TYPE_PLAIN))) { ret = process_plain_input(in); } else { ret = process_serialized_input(in); } check_res: if (0 == ret) { send(OK, sizeof(OK)); } else { send(ERR, sizeof(ERR)); break; } free(in); order_id++; } return 0; }
/* And so it begins... */ int main (int argc, char **argv) { /***** Initializations *****/ MPI_Init (&argc, &argv); MPI_Comm_size (MPI_COMM_WORLD, &numtasks); MPI_Comm_rank (MPI_COMM_WORLD, &taskid); task_init (); /* printf ("PID of task %d : %d\n", ID, getpid()); */ /* MASTER */ if (!taskid) { dispatch_input (); receive_output (); } /* SLAVES */ else { receive_input (); send_output (Head); /* Send Blank Line to mark end of transmission */ MPI_Send ("", 50, MPI_UNSIGNED_CHAR, 0, 0, MPI_COMM_WORLD); /* printf ("Done sending output from task %d\n", ID); */ } task_close (); MPI_Finalize (); return 0; }
void Console:: receive_script(std::string script) { std::vector<std::string> lines = split(script, '\n'); std::for_each(lines.begin(), lines.end(), [&](std::string line) { receive_input(line); }); }
int main( int argc, char **argv ) { int input; display_prompt(); input = receive_input(); printf("%d\n", input); make_input_file("./datafiles"); //read_input_files("./inputfile.txt"); //print_matrix("./inputfile.txt"); //hashtable_s *hashtable = create_table(1); //insert(hashtable, "key1", "word"); //insert(hashtable, "key2", "noideawhatimdoing"); //insert(hashtable, "key3", "word"); //printf("%s\n%s\n%s\n", get(hashtable, "key1"), get(hashtable, "key2"), get(hashtable, "key3")); return 0; }
int main() { os_init(); collect_init("", "", 0); q_next(); q_next(); q_next(); receive_init("", ""); receive_input(); q_next(); send_init("", "", "", 0); q_next(); q_next(); q_next(); q_next(); return 0; }
int main (void) { short waveform[NUM_SAMPLES]; double frequency = 440.0; int octave = 1; int volume = 30000; int length = NUM_SAMPLES; char c; FILE * f = wavfile_open("music.wav"); while (c!='X') { c = receive_input(); switch (c) { default: printf("%d is not a valid input\n", c); break; case 'a': frequency = 415.30 * octave; create_note(volume, length, frequency, waveform, f); break; case 'A': frequency = 440.00 * octave; create_note(volume, length, frequency, waveform, f); break; case 'b': frequency = 466.16 * octave; create_note(volume, length, frequency, waveform, f); break; case 'B': frequency = 493.88 * octave; create_note(volume, length, frequency, waveform, f); break; case 'C': create_note(volume, length, frequency, waveform, f); frequency = 523.25 * octave; break; case 'd': frequency = 554.37 * octave; create_note(volume, length, frequency, waveform, f); break; case 'D': frequency = 587.33 * octave; create_note(volume, length, frequency, waveform, f); break; case 'e': frequency = 622.25 * octave; create_note(volume, length, frequency, waveform, f); break; case 'E': frequency = 659.26 * octave; create_note(volume, length, frequency, waveform, f); break; case 'F': frequency = 698.46 * octave; create_note(volume, length, frequency, waveform, f); break; case 'g': frequency = 739.99 * octave; create_note(volume, length, frequency, waveform, f); break; case 'G': frequency = 783.99 * octave; create_note(volume, length, frequency, waveform, f); break; case '.': frequency = 0; create_note(volume, length, frequency, waveform, f); break; case '+': octave*=2; break; case '-': octave/=2; break; case '1': length = NUM_SAMPLES; break; case '2': length = NUM_SAMPLES/2; break; case '4': length = NUM_SAMPLES/4; break; case '8': length = NUM_SAMPLES/8; break; case '6': length = NUM_SAMPLES/16; break; case 'X': wavfile_close(f); break; } } return 0; }