| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "update_engine/update_check_action.h" | 5 #include "update_engine/update_check_action.h" |
| 6 #include <inttypes.h> |
| 6 #include <sstream> | 7 #include <sstream> |
| 7 | 8 |
| 8 #include <libxml/parser.h> | 9 #include <libxml/parser.h> |
| 9 #include <libxml/xpath.h> | 10 #include <libxml/xpath.h> |
| 10 #include <libxml/xpathInternals.h> | 11 #include <libxml/xpathInternals.h> |
| 11 | 12 |
| 12 #include "chromeos/obsolete_logging.h" | 13 #include "chromeos/obsolete_logging.h" |
| 13 #include "update_engine/action_pipe.h" | 14 #include "update_engine/action_pipe.h" |
| 14 #include "update_engine/utils.h" | 15 #include "update_engine/utils.h" |
| 15 | 16 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 xmlGetProp(node, ConstXMLStr(name))); | 166 xmlGetProp(node, ConstXMLStr(name))); |
| 166 string ret(reinterpret_cast<const char *>(str.get())); | 167 string ret(reinterpret_cast<const char *>(str.get())); |
| 167 return ret; | 168 return ret; |
| 168 } | 169 } |
| 169 | 170 |
| 170 // Parses a 64 bit base-10 int from a string and returns it. Returns 0 | 171 // Parses a 64 bit base-10 int from a string and returns it. Returns 0 |
| 171 // on error. If the string contains "0", that's indistinguishable from | 172 // on error. If the string contains "0", that's indistinguishable from |
| 172 // error. | 173 // error. |
| 173 off_t ParseInt(const string& str) { | 174 off_t ParseInt(const string& str) { |
| 174 off_t ret = 0; | 175 off_t ret = 0; |
| 175 | 176 int rc = sscanf(str.c_str(), "%" PRIi64, &ret); |
| 176 int rc = sscanf(str.c_str(), "%lld", &ret); | |
| 177 if (rc < 1) { | 177 if (rc < 1) { |
| 178 // failure | 178 // failure |
| 179 return 0; | 179 return 0; |
| 180 } | 180 } |
| 181 return ret; | 181 return ret; |
| 182 } | 182 } |
| 183 } // namespace {} | 183 } // namespace {} |
| 184 | 184 |
| 185 // If the transfer was successful, this uses libxml2 to parse the response | 185 // If the transfer was successful, this uses libxml2 to parse the response |
| 186 // and fill in the appropriate fields of the output object. Also, notifies | 186 // and fill in the appropriate fields of the output object. Also, notifies |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 output_object.hash = XmlGetProperty(updatecheck_node, "hash"); | 255 output_object.hash = XmlGetProperty(updatecheck_node, "hash"); |
| 256 output_object.size = ParseInt(XmlGetProperty(updatecheck_node, "size")); | 256 output_object.size = ParseInt(XmlGetProperty(updatecheck_node, "size")); |
| 257 output_object.needs_admin = | 257 output_object.needs_admin = |
| 258 XmlGetProperty(updatecheck_node, "needsadmin") == "true"; | 258 XmlGetProperty(updatecheck_node, "needsadmin") == "true"; |
| 259 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true"; | 259 output_object.prompt = XmlGetProperty(updatecheck_node, "Prompt") == "true"; |
| 260 SetOutputObject(output_object); | 260 SetOutputObject(output_object); |
| 261 return; | 261 return; |
| 262 } | 262 } |
| 263 | 263 |
| 264 }; // namespace chromeos_update_engine | 264 }; // namespace chromeos_update_engine |
| OLD | NEW |