| OLD | NEW |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 #include <errno.h> | 15 #include <errno.h> |
| 16 #include <getopt.h> | 16 #include <getopt.h> |
| 17 #include <stdio.h> | 17 #include <stdio.h> |
| 18 #include <stdlib.h> | 18 #include <stdlib.h> |
| 19 #include <string.h> | 19 #include <string.h> |
| 20 #include <strings.h> |
| 20 #include <sys/types.h> | 21 #include <sys/types.h> |
| 21 #include <time.h> | 22 #include <time.h> |
| 22 | 23 |
| 23 #include <string> | 24 #include <string> |
| 24 #include <vector> | 25 #include <vector> |
| 25 | 26 |
| 26 #include "base/basictypes.h" | 27 #include "base/basictypes.h" |
| 27 #include "base/files/file_path.h" | 28 #include "base/files/file_path.h" |
| 28 #include "base/logging.h" | 29 #include "base/logging.h" |
| 29 #include "base/memory/scoped_ptr.h" | 30 #include "base/memory/scoped_ptr.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 const char* const kTrueWords[] = { | 100 const char* const kTrueWords[] = { |
| 100 "1", | 101 "1", |
| 101 "true", | 102 "true", |
| 102 "yes", | 103 "yes", |
| 103 "on", | 104 "on", |
| 104 "enabled", | 105 "enabled", |
| 105 "set", | 106 "set", |
| 106 }; | 107 }; |
| 107 | 108 |
| 108 for (size_t index = 0; index < arraysize(kFalseWords); ++index) { | 109 for (size_t index = 0; index < arraysize(kFalseWords); ++index) { |
| 109 if (base::strcasecmp(string, kFalseWords[index]) == 0) { | 110 if (strcasecmp(string, kFalseWords[index]) == 0) { |
| 110 *boolean = false; | 111 *boolean = false; |
| 111 return true; | 112 return true; |
| 112 } | 113 } |
| 113 } | 114 } |
| 114 | 115 |
| 115 for (size_t index = 0; index < arraysize(kTrueWords); ++index) { | 116 for (size_t index = 0; index < arraysize(kTrueWords); ++index) { |
| 116 if (base::strcasecmp(string, kTrueWords[index]) == 0) { | 117 if (strcasecmp(string, kTrueWords[index]) == 0) { |
| 117 *boolean = true; | 118 *boolean = true; |
| 118 return true; | 119 return true; |
| 119 } | 120 } |
| 120 } | 121 } |
| 121 | 122 |
| 122 return false; | 123 return false; |
| 123 } | 124 } |
| 124 | 125 |
| 125 // Converts |boolean| to a string, either "true" or "false". | 126 // Converts |boolean| to a string, either "true" or "false". |
| 126 std::string BoolToString(bool boolean) { | 127 std::string BoolToString(bool boolean) { |
| 127 return std::string(boolean ? "true" : "false"); | 128 return std::string(boolean ? "true" : "false"); |
| 128 } | 129 } |
| 129 | 130 |
| 130 // Converts |string| to |time|, returning true if a conversion could be | 131 // Converts |string| to |time|, returning true if a conversion could be |
| 131 // performed, and false without setting |boolean| if no conversion could be | 132 // performed, and false without setting |boolean| if no conversion could be |
| 132 // performed. Various time formats are recognized, including several string | 133 // performed. Various time formats are recognized, including several string |
| 133 // representations and a numeric time_t representation. The special string | 134 // representations and a numeric time_t representation. The special string |
| 134 // "never" is recognized as |string| and converts to a |time| value of 0. |utc|, | 135 // "never" is recognized as |string| and converts to a |time| value of 0. |utc|, |
| 135 // when true, causes |string| to be interpreted as a UTC time rather than a | 136 // when true, causes |string| to be interpreted as a UTC time rather than a |
| 136 // local time when the time zone is ambiguous. | 137 // local time when the time zone is ambiguous. |
| 137 bool StringToTime(const char* string, time_t* time, bool utc) { | 138 bool StringToTime(const char* string, time_t* time, bool utc) { |
| 138 if (base::strcasecmp(string, "never") == 0) { | 139 if (strcasecmp(string, "never") == 0) { |
| 139 *time = 0; | 140 *time = 0; |
| 140 return true; | 141 return true; |
| 141 } | 142 } |
| 142 | 143 |
| 143 const char* end = string + strlen(string); | 144 const char* end = string + strlen(string); |
| 144 | 145 |
| 145 const char* const kFormats[] = { | 146 const char* const kFormats[] = { |
| 146 "%Y-%m-%d %H:%M:%S %Z", | 147 "%Y-%m-%d %H:%M:%S %Z", |
| 147 "%Y-%m-%d %H:%M:%S", | 148 "%Y-%m-%d %H:%M:%S", |
| 148 "%+", | 149 "%+", |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 | 574 |
| 574 #if defined(OS_POSIX) | 575 #if defined(OS_POSIX) |
| 575 int main(int argc, char* argv[]) { | 576 int main(int argc, char* argv[]) { |
| 576 return crashpad::DatabaseUtilMain(argc, argv); | 577 return crashpad::DatabaseUtilMain(argc, argv); |
| 577 } | 578 } |
| 578 #elif defined(OS_WIN) | 579 #elif defined(OS_WIN) |
| 579 int wmain(int argc, wchar_t* argv[]) { | 580 int wmain(int argc, wchar_t* argv[]) { |
| 580 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::DatabaseUtilMain); | 581 return crashpad::ToolSupport::Wmain(argc, argv, crashpad::DatabaseUtilMain); |
| 581 } | 582 } |
| 582 #endif // OS_POSIX | 583 #endif // OS_POSIX |
| OLD | NEW |