OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 #include <iostream> | 6 #include <iostream> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 // Include once to get the type definitions | 10 // Include once to get the type definitions |
11 #include "chrome/tools/ipclist/all_messages.h" | 11 #include "chrome/tools/ipclist/all_messages.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 std::cout << "Missing message file: gap before LastIPCMsgStart\n"; | 68 std::cout << "Missing message file: gap before LastIPCMsgStart\n"; |
69 result = false; | 69 result = false; |
70 } | 70 } |
71 | 71 |
72 if (!result) | 72 if (!result) |
73 std::cout << "Please check chrome/tools/ipclist/all_messages.h.\n"; | 73 std::cout << "Please check chrome/tools/ipclist/all_messages.h.\n"; |
74 | 74 |
75 return result; | 75 return result; |
76 } | 76 } |
77 | 77 |
78 static void dump_msgtable(bool show_args, bool show_ids) { | 78 static void dump_msgtable(bool show_args, bool show_ids, |
| 79 bool show_comma, const char *prefix) { |
| 80 bool first = true; |
79 for (size_t i = 0; i < MSGTABLE_SIZE; ++i) { | 81 for (size_t i = 0; i < MSGTABLE_SIZE; ++i) { |
80 if (show_ids) { | 82 if ((!prefix) || strstr(msgtable[i].name, prefix) == msgtable[i].name) { |
81 std::cout << "{" << IPC_MESSAGE_ID_CLASS(msgtable[i].id) << ", " << | 83 if (show_comma) { |
82 IPC_MESSAGE_ID_LINE(msgtable[i].id) << "}: "; | 84 if (!first) |
| 85 std::cout << ","; |
| 86 first = false; |
| 87 std::cout << msgtable[i].id; |
| 88 } else { |
| 89 if (show_ids) |
| 90 std::cout << msgtable[i].id << " " << |
| 91 IPC_MESSAGE_ID_CLASS(msgtable[i].id) << "," << |
| 92 IPC_MESSAGE_ID_LINE(msgtable[i].id) << " "; |
| 93 std::cout << msgtable[i].name; |
| 94 if (show_args) { |
| 95 std::cout << "(" << msgtable[i].in_count << " IN, " << |
| 96 msgtable[i].out_count << " OUT)"; |
| 97 } |
| 98 std::cout << "\n"; |
| 99 } |
83 } | 100 } |
84 std::cout << msgtable[i].name; | 101 } |
85 if (show_args) { | 102 if (show_comma) |
86 std::cout << "(" << msgtable[i].in_count << " IN, " << | |
87 msgtable[i].out_count << " OUT)"; | |
88 } | |
89 std::cout << "\n"; | 103 std::cout << "\n"; |
90 } | |
91 } | 104 } |
92 | 105 |
93 int main(int argc, char **argv) { | 106 int main(int argc, char **argv) { |
94 bool show_args = false; | 107 bool show_args = false; |
95 bool show_ids = false; | 108 bool show_ids = false; |
96 bool skip_check = false; | 109 bool skip_check = false; |
| 110 bool show_comma = false; |
| 111 const char *filter = NULL; |
97 | 112 |
98 while (--argc > 0) { | 113 while (--argc > 0) { |
99 ++argv; | 114 ++argv; |
100 if (std::string("--args") == *argv) { | 115 if (std::string("--args") == *argv) { |
101 show_args = true; | 116 show_args = true; |
| 117 } else if (std::string("--comma") == *argv) { |
| 118 show_comma = true; |
| 119 } else if (std::string("--filter") == *argv) { |
| 120 filter = *(++argv); --argc; |
102 } else if (std::string("--ids") == *argv) { | 121 } else if (std::string("--ids") == *argv) { |
103 show_ids = true; | 122 show_ids = true; |
104 } else if (std::string("--no-check") == *argv) { | 123 } else if (std::string("--no-check") == *argv) { |
105 skip_check = true; | 124 skip_check = true; |
106 } else { | 125 } else { |
107 std::cout << "usage: ipclist [--args] [--ids] [--no-check]\n"; | 126 std::cout << |
| 127 "usage: ipclist [--args] [--ids] [--no-check] [--filter prefix] " |
| 128 "[--comma]\n"; |
108 return 1; | 129 return 1; |
109 } | 130 } |
110 } | 131 } |
111 | 132 |
112 std::sort(msgtable, msgtable + MSGTABLE_SIZE); | 133 std::sort(msgtable, msgtable + MSGTABLE_SIZE); |
113 | 134 |
114 if (!skip_check && check_msgtable() == false) | 135 if (!skip_check && check_msgtable() == false) |
115 return 1; | 136 return 1; |
116 | 137 |
117 dump_msgtable(show_args, show_ids); | 138 dump_msgtable(show_args, show_ids, show_comma, filter); |
118 return 0; | 139 return 0; |
119 } | 140 } |
120 | 141 |
OLD | NEW |