diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2013-10-31 09:51:29 -0700 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2013-10-31 09:51:29 -0700 |
commit | 2978367ae0c8bf2b1780f09d8724163522407424 (patch) | |
tree | f39107e15ee3cc79ba65e243338949fd5c93d6d5 /android/cutils | |
parent | 4ae773519668f0a6522e5940d9ff0e40362d1ab3 (diff) | |
download | bluez-2978367ae0c8bf2b1780f09d8724163522407424.tar.gz |
android: Add system-emulator for wrapping daemon start
Diffstat (limited to 'android/cutils')
-rw-r--r-- | android/cutils/properties.h | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/android/cutils/properties.h b/android/cutils/properties.h index f318b011a..9b7a8a0ad 100644 --- a/android/cutils/properties.h +++ b/android/cutils/properties.h @@ -14,25 +14,42 @@ * limitations under the License. */ -#ifndef __CUTILS_PROPERTIES_H -#define __CUTILS_PROPERTIES_H - -#include <stdlib.h> +#include <stdio.h> #include <string.h> - -#ifdef __cplusplus -extern "C" { -#endif +#include <sys/socket.h> +#include <sys/un.h> /* property_set: returns 0 on success, < 0 on failure */ static inline int property_set(const char *key, const char *value) { - return setenv(key, value, 0); -} + static const char SYSTEM_SOCKET_PATH[] = "\0android_system"; -#ifdef __cplusplus -} -#endif + struct sockaddr_un addr; + char msg[256]; + int fd, len; + + fd = socket(PF_LOCAL, SOCK_DGRAM, 0); + if (fd < 0) + return -1; + + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + memcpy(addr.sun_path, SYSTEM_SOCKET_PATH, sizeof(SYSTEM_SOCKET_PATH)); -#endif + if (connect(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { + close(fd); + return -1; + } + + len = snprintf(msg, sizeof(msg), "%s=%s", key, value); + + if (send(fd, msg, len + 1, 0) < 0) { + close(fd); + return -1; + } + + close(fd); + + return 0; +} |