Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8121ba0 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Support arbitrary-length properties in property_list."

parents ff21dba1 4eacd70f
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -98,7 +98,7 @@ cc_library {
                "ashmem-dev.c",
                "ashmem-dev.c",
                "klog.cpp",
                "klog.cpp",
                "partition_utils.c",
                "partition_utils.c",
                "properties.c",
                "properties.cpp",
                "qtaguid.c",
                "qtaguid.c",
                "trace-dev.c",
                "trace-dev.c",
                "uevent.c",
                "uevent.c",
+12 −14
Original line number Original line Diff line number Diff line
@@ -112,9 +112,7 @@ int property_set(const char *key, const char *value) {
}
}


int property_get(const char *key, char *value, const char *default_value) {
int property_get(const char *key, char *value, const char *default_value) {
    int len;
    int len = __system_property_get(key, value);

    len = __system_property_get(key, value);
    if (len > 0) {
    if (len > 0) {
        return len;
        return len;
    }
    }
@@ -126,21 +124,21 @@ int property_get(const char *key, char *value, const char *default_value) {
    return len;
    return len;
}
}


struct property_list_callback_data {
struct callback_data {
    void (*propfn)(const char *key, const char *value, void *cookie);
    void (*callback)(const char* name, const char* value, void* cookie);
    void* cookie;
    void* cookie;
};
};


static void property_list_callback(const prop_info *pi, void *cookie) {
static void trampoline(void* raw_data, const char* name, const char* value) {
    char name[PROP_NAME_MAX];
    callback_data* data = reinterpret_cast<callback_data*>(raw_data);
    char value[PROP_VALUE_MAX];
    data->callback(name, value, data->cookie);
    struct property_list_callback_data *data = cookie;
}


    __system_property_read(pi, name, value);
static void property_list_callback(const prop_info* pi, void* data) {
    data->propfn(name, value, data->cookie);
    __system_property_read_callback(pi, trampoline, data);
}
}


int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie) {
int property_list(void (*fn)(const char* name, const char* value, void* cookie), void* cookie) {
    struct property_list_callback_data data = {propfn, cookie};
    callback_data data = { fn, cookie };
    return __system_property_foreach(property_list_callback, &data);
    return __system_property_foreach(property_list_callback, &data);
}
}