OLD | NEW |
1 /* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2011 The Chromium OS 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 * Chrome OS firmware/system interface utility | 5 * Chrome OS firmware/system interface utility |
6 */ | 6 */ |
7 | 7 |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 /* Terminate with null name */ | 74 /* Terminate with null name */ |
75 {NULL, 0, NULL} | 75 {NULL, 0, NULL} |
76 }; | 76 }; |
77 | 77 |
78 | 78 |
79 /* Print help */ | 79 /* Print help */ |
80 void PrintHelp(const char *progname) { | 80 void PrintHelp(const char *progname) { |
81 const Param *p; | 81 const Param *p; |
82 | 82 |
83 printf("\nUsage:\n" | 83 printf("\nUsage:\n" |
84 " %s\n" | 84 " %s [--all]\n" |
85 " Prints all parameters with descriptions and current values.\n" | 85 " Prints all parameters with descriptions and current values.\n" |
| 86 " If --all is specified, prints even normally hidden fields.\n" |
86 " %s [param1 [param2 [...]]]\n" | 87 " %s [param1 [param2 [...]]]\n" |
87 " Prints the current value(s) of the parameter(s).\n" | 88 " Prints the current value(s) of the parameter(s).\n" |
88 " %s [param1=value1] [param2=value2 [...]]]\n" | 89 " %s [param1=value1] [param2=value2 [...]]]\n" |
89 " Sets the parameter(s) to the specified value(s).\n" | 90 " Sets the parameter(s) to the specified value(s).\n" |
90 " %s [param1?value1] [param2?value2 [...]]]\n" | 91 " %s [param1?value1] [param2?value2 [...]]]\n" |
91 " Checks if the parameter(s) all contain the specified value(s).\n" | 92 " Checks if the parameter(s) all contain the specified value(s).\n" |
92 "Stops at the first error." | 93 "Stops at the first error." |
93 "\n" | 94 "\n" |
94 "Valid parameters:\n", progname, progname, progname, progname); | 95 "Valid parameters:\n", progname, progname, progname, progname); |
95 for (p = sys_param_list; p->name; p++) | 96 for (p = sys_param_list; p->name; p++) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } else { | 167 } else { |
167 int v = VbGetSystemPropertyInt(p->name); | 168 int v = VbGetSystemPropertyInt(p->name); |
168 if (v == -1) | 169 if (v == -1) |
169 return 1; | 170 return 1; |
170 printf(p->format ? p->format : "%d", v); | 171 printf(p->format ? p->format : "%d", v); |
171 } | 172 } |
172 return 0; | 173 return 0; |
173 } | 174 } |
174 | 175 |
175 | 176 |
176 /* Print all parameters with descriptions, | 177 /* Print all parameters with descriptions. If force_all!=0, prints even |
| 178 * parameters that specify the NO_PRINT_ALL flag. |
177 * | 179 * |
178 * Returns 0 if success, non-zero if error. */ | 180 * Returns 0 if success, non-zero if error. */ |
179 int PrintAllParams(void) { | 181 int PrintAllParams(int force_all) { |
180 const Param* p; | 182 const Param* p; |
181 int retval = 0; | 183 int retval = 0; |
182 char buf[MAX_STRING]; | 184 char buf[MAX_STRING]; |
183 const char* value; | 185 const char* value; |
184 | 186 |
185 for (p = sys_param_list; p->name; p++) { | 187 for (p = sys_param_list; p->name; p++) { |
186 if (p->flags & NO_PRINT_ALL) | 188 if (0 == force_all && (p->flags & NO_PRINT_ALL)) |
187 continue; | 189 continue; |
188 if (p->flags & IS_STRING) { | 190 if (p->flags & IS_STRING) { |
189 value = VbGetSystemPropertyString(p->name, buf, sizeof(buf)); | 191 value = VbGetSystemPropertyString(p->name, buf, sizeof(buf)); |
190 } else { | 192 } else { |
191 int v = VbGetSystemPropertyInt(p->name); | 193 int v = VbGetSystemPropertyInt(p->name); |
192 if (v == -1) | 194 if (v == -1) |
193 value = NULL; | 195 value = NULL; |
194 else { | 196 else { |
195 snprintf(buf, sizeof(buf), p->format ? p->format : "%d", v); | 197 snprintf(buf, sizeof(buf), p->format ? p->format : "%d", v); |
196 value = buf; | 198 value = buf; |
(...skipping 11 matching lines...) Expand all Loading... |
208 int i; | 210 int i; |
209 | 211 |
210 char* progname = strrchr(argv[0], '/'); | 212 char* progname = strrchr(argv[0], '/'); |
211 if (progname) | 213 if (progname) |
212 progname++; | 214 progname++; |
213 else | 215 else |
214 progname = argv[0]; | 216 progname = argv[0]; |
215 | 217 |
216 /* If no args specified, print all params */ | 218 /* If no args specified, print all params */ |
217 if (argc == 1) | 219 if (argc == 1) |
218 return PrintAllParams(); | 220 return PrintAllParams(0); |
| 221 /* --all or -a prints all params including normally hidden ones */ |
| 222 if (!strcasecmp(argv[1], "--all") || !strcmp(argv[1], "-a")) |
| 223 return PrintAllParams(1); |
219 | 224 |
220 /* Print help if needed */ | 225 /* Print help if needed */ |
221 if (!strcasecmp(argv[1], "-h") || !strcmp(argv[1], "-?")) { | 226 if (!strcasecmp(argv[1], "-h") || !strcmp(argv[1], "-?")) { |
222 PrintHelp(progname); | 227 PrintHelp(progname); |
223 return 0; | 228 return 0; |
224 } | 229 } |
225 | 230 |
226 /* Otherwise, loop through params and get/set them */ | 231 /* Otherwise, loop through params and get/set them */ |
227 for (i = 1; i < argc && retval == 0; i++) { | 232 for (i = 1; i < argc && retval == 0; i++) { |
228 char* has_set = strchr(argv[i], '='); | 233 char* has_set = strchr(argv[i], '='); |
(...skipping 29 matching lines...) Expand all Loading... |
258 if (has_set) | 263 if (has_set) |
259 retval = SetParam(p, value); | 264 retval = SetParam(p, value); |
260 else if (has_expect) | 265 else if (has_expect) |
261 retval = CheckParam(p, value); | 266 retval = CheckParam(p, value); |
262 else | 267 else |
263 retval = PrintParam(p); | 268 retval = PrintParam(p); |
264 } | 269 } |
265 | 270 |
266 return retval; | 271 return retval; |
267 } | 272 } |
OLD | NEW |