blob: 7e4ed9316298cb5a0f2361a236c694f6f43daf43 [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __CUTILS_PROPERTIES_H
18#define __CUTILS_PROPERTIES_H
19
Nick Kralevich53df3ad2013-05-23 09:55:41 -070020#include <sys/system_properties.h>
21
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080022#ifdef __cplusplus
23extern "C" {
24#endif
25
26/* System properties are *small* name value pairs managed by the
27** property service. If your data doesn't fit in the provided
28** space it is not appropriate for a system property.
29**
30** WARNING: system/bionic/include/sys/system_properties.h also defines
31** these, but with different names. (TODO: fix that)
32*/
Nick Kralevich53df3ad2013-05-23 09:55:41 -070033#define PROPERTY_KEY_MAX PROP_NAME_MAX
34#define PROPERTY_VALUE_MAX PROP_VALUE_MAX
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080035
36/* property_get: returns the length of the value which will never be
37** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated.
38** (the length does not include the terminating zero).
39**
40** If the property read fails or returns an empty value, the default
41** value is used (if nonnull).
42*/
43int property_get(const char *key, char *value, const char *default_value);
44
45/* property_set: returns 0 on success, < 0 on failure
46*/
47int property_set(const char *key, const char *value);
48
49int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie);
50
51
52#ifdef HAVE_SYSTEM_PROPERTY_SERVER
53/*
54 * We have an external property server instead of built-in libc support.
55 * Used by the simulator.
56 */
57#define SYSTEM_PROPERTY_PIPE_NAME "/tmp/android-sysprop"
58
59enum {
60 kSystemPropertyUnknown = 0,
61 kSystemPropertyGet,
62 kSystemPropertySet,
63 kSystemPropertyList
64};
65#endif /*HAVE_SYSTEM_PROPERTY_SERVER*/
66
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080067
68#ifdef __cplusplus
69}
70#endif
71
72#endif