blob: 5ecc721d1f934b46f6160f82de674602cd445eb8 [file] [log] [blame]
Eric Carusocc7106c2017-04-27 14:22:42 -07001// 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
7namespace debugd {
8
Nicole Anderson-Aud9f0aed2020-12-22 17:16:25 +00009bool AddIntOption(SandboxedProcess* process,
Eric Carusocc7106c2017-04-27 14:22:42 -070010 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-Au296864c2020-12-22 17:52:31 +000022bool 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 Carusocc7106c2017-04-27 14:22:42 -070035} // namespace debugd