1/****************************************************************************** 2 * 3 * Copyright (C) 2016 Google, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19#include <string.h> 20 21#include "osi/include/properties.h" 22 23int osi_property_get(const char* key, char* value, const char* default_value) { 24#if defined(OS_GENERIC) 25 /* For linux right now just return default value, if present */ 26 int len = 0; 27 if (!default_value) return len; 28 29 len = strlen(default_value); 30 if (len >= PROPERTY_VALUE_MAX) len = PROPERTY_VALUE_MAX - 1; 31 32 memcpy(value, default_value, len); 33 value[len] = '\0'; 34 return len; 35#else 36 return property_get(key, value, default_value); 37#endif // defined(OS_GENERIC) 38} 39 40int osi_property_set(const char* key, const char* value) { 41#if defined(OS_GENERIC) 42 return -1; 43#else 44 return property_set(key, value); 45#endif // defined(OS_GENERIC) 46} 47 48int32_t osi_property_get_int32(const char* key, int32_t default_value) { 49#if defined(OS_GENERIC) 50 return default_value; 51#else 52 return property_get_int32(key, default_value); 53#endif // defined(OS_GENERIC) 54} 55