int main(int argc, char* argv[]) { PaError err = paNoError; int device_id; BOOL rv; err = Pa_Initialize(); if (err != paNoError) { fprintf(stderr, "Pa_Initialize() failed...\n"); exit(1); } if (argc != 3) { printf("usage: %s devide_id wav_file\n\n", argv[0]); print_deviceinfo(); Pa_Terminate(); return 1; } rv = wavfile_open(argv[2]); if (rv == FALSE) { fprintf(stderr, "wav file open failed...\n"); Pa_Terminate(); exit(1); } device_id = atoi(argv[1]); rv = audio_start(device_id); if (rv == FALSE) { fprintf(stderr, "AudioDevice initialize failed...device_id=%d\n", device_id); Pa_Terminate(); return 1; } while (1) { Pa_Sleep(100); if (finish_flag == TRUE) break; } audio_stop(); Pa_Terminate(); wavfile_close(); return 0; }
static int read_args(int argc, char **argv) { int c; opterr = 0; while (-1 != (c = getopt(argc, argv, "x:" /* <transfer,> */ "c:" #if (TC_OFFLINE) "i:" /* input pcap file */ "a:" /* accelerated times */ "I:" /* threshold interval time for acceleratation */ #endif #if (TC_PCAP) "i:" /* <device,> */ "F:" /* <filter> */ "B:" "S:" "I:" #endif #if (TC_PCAP_SND) "o:" /* <device,> */ #endif "n:" /* set the replication times */ "f:" /* use this parameter to reduce port conflications */ "m:" /* set the maximum memory allowed to use for tcpcopy */ "C:" /* parallel connections between tcpcopy and intercept */ "p:" /* target server port to listen on */ "r:" /* percentage of sessions transfered */ "M:" /* MTU sent to backend */ "S:" "U:" "R:" "D:" /* mss value sent to backend */ "t:" /* set the session timeout limit */ "k:" /* set the session keepalive timeout limit */ "s:" /* real servers running intercept*/ "l:" /* error log file */ "P:" /* save PID in file */ "L" /* lonely */ "O" "g" "h" /* help, licence info */ "v" /* version */ "d" /* daemon mode */ ))) { switch (c) { case 'x': clt_settings.raw_tf = optarg; break; case 'c': clt_settings.raw_clt_tf_ip = optarg; break; case 'H': clt_settings.localhost_tf_ip = inet_addr(optarg); break; #if (TC_OFFLINE) case 'i': clt_settings.pcap_file = optarg; break; case 'a': clt_settings.accelerated_times = atoi(optarg); break; case 'I': clt_settings.interval = atoi(optarg); break; #endif #if (TC_PCAP_SND) case 'o': clt_settings.output_if_name = optarg; break; #endif #if (TC_PCAP) case 'i': clt_settings.raw_device = optarg; break; case 'F': clt_settings.user_filter = optarg; break; case 'B': clt_settings.buffer_size = 1024 * 1024 * atoi(optarg); break; #endif case 'n': clt_settings.replica_num = atoi(optarg); break; case 'f': clt_settings.factor = atoi(optarg); break; case 'm': clt_settings.max_rss = 1024 * atoi(optarg); break; case 'C': clt_settings.par_conns = atoi(optarg); break; case 'U': clt_settings.s_pool_size = 1024 * atoi(optarg); break; case 'l': clt_settings.log_path = optarg; break; case 'R': clt_settings.default_rtt = atoi(optarg); break; case 'M': clt_settings.mtu = atoi(optarg); break; case 'D': clt_settings.mss = atoi(optarg); break; case 's': clt_settings.raw_rs_list = optarg; break; case 't': clt_settings.sess_timeout = atoi(optarg); break; case 'k': clt_settings.sess_keepalive_timeout = atoi(optarg); break; case 'g': clt_settings.gradully = 1; break; case 'h': usage(); return -1; case 'v': printf ("tcpcopy version:%s\n", VERSION); return -1; case 'd': clt_settings.do_daemonize = 1; break; case 'L': clt_settings.lonely = 1; break; case 'O': clt_settings.only_replay_full = 1; break; case 'p': clt_settings.srv_port = atoi(optarg); break; case 'P': clt_settings.pid_file = optarg; break; case 'r': clt_settings.percentage = atoi(optarg); break; case '?': switch (optopt) { case 'x': fprintf(stderr, "tcpcopy: option -%c require a string\n", optopt); break; case 'c': fprintf(stderr, "tcpcopy: option -%c require a ip address or a sub net\n", optopt); break; #if (TC_OFFLINE) case 'i': #endif case 'l': case 'P': fprintf(stderr, "tcpcopy: option -%c require a file name\n", optopt); break; #if (TC_PCAP) case 'i': fprintf(stderr, "tcpcopy: option -%c require a device name\n", optopt); break; case 'I': print_deviceinfo(); return -1; #endif #if (TC_PCAP_SND) case 'o': fprintf(stderr, "tcpcopy: option -%c require a device name\n", optopt); break; #endif case 's': fprintf(stderr, "tcpcopy: option -%c require an ip address list\n", optopt); break; case 'n': case 'f': case 'C': #if (TC_OFFLINE) case 'a': case 'I': #endif #if (TC_PCAP) case 'B': case 'S': #endif case 'm': case 'M': case 'D': case 'U': case 't': case 'k': case 'p': case 'r': fprintf(stderr, "tcpcopy: option -%c require a number\n", optopt); break; default: fprintf(stderr, "tcpcopy: illegal argument \"%c\"\n", optopt); break; } return -1; default: fprintf(stderr, "tcpcopy: illegal argument \"%c\"\n", optopt); return -1; } } return 0; }