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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « platform_switch.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // Implements PlatformSwitch by reading in the switch file (CHSW) and converting
6 // its contents to an unsigned integer which is bitwise-ANDed with the
7 // subclass-defined bitmask().
8
9 #include "platform_switch.h"
10
11 #include "helpers.h"
12
13 namespace cros_boot_mode {
14
15 const char *PlatformSwitch::kPositionText[] = { "disabled", "enabled" };
16
17 PlatformSwitch::PlatformSwitch() { }
18 PlatformSwitch::~PlatformSwitch() { }
19
20 const char *PlatformSwitch::c_str() const {
21 return (value() >= 0 ? kPositionText[value()] : "unsupported");
22 }
23
24 int PlatformSwitch::Process(const char *file_contents, size_t length) {
25 int read_int = helpers::to_int(file_contents, length);
26 if (read_int < 0)
27 return kUnsupported;
28 unsigned int position = static_cast<unsigned int>(read_int);
29 return !((position & bitmask()) == 0);
30 }
31
32 } // namespace cros_boot_mode
OLDNEW
« 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