1 // Copyright 2018 The Fuchsia 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 "env.h" 6 7 #include <stdlib.h> 8 #include <string.h> 9 10 namespace devmgr { 11 getenv_bool(const char * key,bool default_value)12bool getenv_bool(const char* key, bool default_value) { 13 const char* value = getenv(key); 14 if (value == nullptr) { 15 return default_value; 16 } 17 if ((strcmp(value, "0") == 0) || 18 (strcmp(value, "false") == 0) || 19 (strcmp(value, "off") == 0)) { 20 return false; 21 } 22 return true; 23 } 24 25 } // namespace devmgr 26