Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(796)

Unified Diff: platform_switch.cc

Issue 3530001: first cut: establishes base helper classes and main (Closed) Base URL: http://git.chromium.org/git/cros_boot_mode.git
Patch Set: truncation is bad, m'kay. . . Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « platform_switch.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: platform_switch.cc
diff --git a/platform_switch.cc b/platform_switch.cc
new file mode 100644
index 0000000000000000000000000000000000000000..95e1e05cda64d60934d81cbbdc6aff9ac908ac6d
--- /dev/null
+++ b/platform_switch.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Implements PlatformSwitch by reading in the switch file (CHSW) and converting
+// its contents to an unsigned integer which is bitwise-ANDed with the
+// subclass-defined bitmask().
+
+#include "platform_switch.h"
+
+#include "helpers.h"
+
+namespace cros_boot_mode {
+
+const char *PlatformSwitch::kPositionText[] = { "disabled", "enabled" };
+
+PlatformSwitch::PlatformSwitch() { }
+PlatformSwitch::~PlatformSwitch() { }
+
+const char *PlatformSwitch::c_str() const {
+ return (value() >= 0 ? kPositionText[value()] : "unsupported");
+}
+
+int PlatformSwitch::Process(const char *file_contents, size_t length) {
+ int read_int = helpers::to_int(file_contents, length);
+ if (read_int < 0)
+ return kUnsupported;
+ unsigned int position = static_cast<unsigned int>(read_int);
+ return !((position & bitmask()) == 0);
+}
+
+} // namespace cros_boot_mode
« no previous file with comments | « platform_switch.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698