Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 1 | // Copyright 2017 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 | #include "debugd/src/variant_utils.h" |
| 6 | |
| 7 | namespace debugd { |
| 8 | |
Nicole Anderson-Au | d9f0aed | 2020-12-22 17:16:25 +0000 | [diff] [blame] | 9 | bool AddIntOption(SandboxedProcess* process, |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 10 | const brillo::VariantDictionary& options, |
| 11 | const std::string& key, |
| 12 | const std::string& flag_name, |
| 13 | brillo::ErrorPtr* error) { |
| 14 | int value; |
| 15 | ParseResult result = GetOption(options, key, &value, error); |
| 16 | if (result == ParseResult::PARSED) |
| 17 | process->AddIntOption(flag_name, value); |
| 18 | |
| 19 | return result != ParseResult::PARSE_ERROR; |
| 20 | } |
| 21 | |
Nicole Anderson-Au | 296864c | 2020-12-22 17:52:31 +0000 | [diff] [blame^] | 22 | bool AddBoolOption(SandboxedProcess* process, |
| 23 | const brillo::VariantDictionary& options, |
| 24 | const std::string& key, |
| 25 | const std::string& flag_name, |
| 26 | brillo::ErrorPtr* error) { |
| 27 | int value; |
| 28 | ParseResult result = GetOption(options, key, &value, error); |
| 29 | if (result == ParseResult::PARSED && value) |
| 30 | process->AddArg(flag_name); |
| 31 | |
| 32 | return result != ParseResult::PARSE_ERROR; |
| 33 | } |
| 34 | |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 35 | } // namespace debugd |