| 52 | |
| 53 | |
| 54 | void |
| 55 | PubDriver::parse_args(int& argc, ACE_TCHAR* argv[]) |
| 56 | { |
| 57 | DBG_ENTRY("PubDriver","parse_args"); |
| 58 | |
| 59 | // Command-line arguments: |
| 60 | // |
| 61 | // -p <pub_id:pub_port> |
| 62 | // -s <sub_id:sub_host:sub_port> |
| 63 | // -n num_messages |
| 64 | // -c message_size |
| 65 | // -m use shared memory |
| 66 | // |
| 67 | ACE_Arg_Shifter arg_shifter(argc, argv); |
| 68 | |
| 69 | bool got_n = false; |
| 70 | bool got_p = false; |
| 71 | bool got_s = false; |
| 72 | bool got_c = false; |
| 73 | |
| 74 | const ACE_TCHAR* current_arg = 0; |
| 75 | |
| 76 | while (arg_shifter.is_anything_left()) |
| 77 | { |
| 78 | // The '-p' option |
| 79 | if ((current_arg = arg_shifter.get_the_parameter(ACE_TEXT("-p")))) { |
| 80 | if (got_p) { |
| 81 | ACE_ERROR((LM_ERROR, |
| 82 | "(%P|%t) Only one -p allowed on command-line.\n")); |
| 83 | throw TestException(); |
| 84 | } |
| 85 | |
| 86 | int result = parse_pub_arg(current_arg); |
| 87 | arg_shifter.consume_arg(); |
| 88 | |
| 89 | if (result != 0) { |
| 90 | ACE_ERROR((LM_ERROR, |
| 91 | "(%P|%t) Failed to parse -p command-line arg.\n")); |
| 92 | throw TestException(); |
| 93 | } |
| 94 | |
| 95 | got_p = true; |
| 96 | } |
| 97 | // A '-s' option |
| 98 | else if ((current_arg = arg_shifter.get_the_parameter(ACE_TEXT("-s")))) { |
| 99 | if (got_s) { |
| 100 | ACE_ERROR((LM_ERROR, |
| 101 | "(%P|%t) Only one -s allowed on command-line.\n")); |
| 102 | throw TestException(); |
| 103 | } |
| 104 | |
| 105 | int result = parse_sub_arg(current_arg); |
| 106 | arg_shifter.consume_arg(); |
| 107 | |
| 108 | if (result != 0) { |
| 109 | ACE_ERROR((LM_ERROR, |
| 110 | "(%P|%t) Failed to parse -s command-line arg.\n")); |
| 111 | throw TestException(); |