diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2016-01-11 05:26:51 +0100 |
---|---|---|
committer | Dees Troy <dees_troy@teamw.in> | 2016-01-15 01:27:45 +0100 |
commit | 6bb26b5f14258c9fa0ed2b31d8cc0f25e0b24e1b (patch) | |
tree | 6d971c658a3ca67fae74178fae46a250ad2ad604 /toolbox/getprop.c | |
parent | Improve sdcard partitioning process (diff) | |
download | android_bootable_recovery-6bb26b5f14258c9fa0ed2b31d8cc0f25e0b24e1b.tar android_bootable_recovery-6bb26b5f14258c9fa0ed2b31d8cc0f25e0b24e1b.tar.gz android_bootable_recovery-6bb26b5f14258c9fa0ed2b31d8cc0f25e0b24e1b.tar.bz2 android_bootable_recovery-6bb26b5f14258c9fa0ed2b31d8cc0f25e0b24e1b.tar.lz android_bootable_recovery-6bb26b5f14258c9fa0ed2b31d8cc0f25e0b24e1b.tar.xz android_bootable_recovery-6bb26b5f14258c9fa0ed2b31d8cc0f25e0b24e1b.tar.zst android_bootable_recovery-6bb26b5f14258c9fa0ed2b31d8cc0f25e0b24e1b.zip |
Diffstat (limited to '')
-rw-r--r-- | toolbox/getprop.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/toolbox/getprop.c b/toolbox/getprop.c new file mode 100644 index 000000000..dcc0ea030 --- /dev/null +++ b/toolbox/getprop.c @@ -0,0 +1,50 @@ +#include <stdio.h> +#include <stdlib.h> + +#include <cutils/properties.h> + +#include "dynarray.h" + +static void record_prop(const char* key, const char* name, void* opaque) +{ + strlist_t* list = opaque; + char temp[PROP_VALUE_MAX + PROP_NAME_MAX + 16]; + snprintf(temp, sizeof temp, "[%s]: [%s]", key, name); + strlist_append_dup(list, temp); +} + +static void list_properties(void) +{ + strlist_t list[1] = { STRLIST_INITIALIZER }; + + /* Record properties in the string list */ + (void)property_list(record_prop, list); + + /* Sort everything */ + strlist_sort(list); + + /* print everything */ + STRLIST_FOREACH(list, str, printf("%s\n", str)); + + /* voila */ + strlist_done(list); +} + +int getprop_main(int argc, char *argv[]) +{ + if (argc == 1) { + list_properties(); + } else { + char value[PROPERTY_VALUE_MAX]; + char *default_value; + if(argc > 2) { + default_value = argv[2]; + } else { + default_value = ""; + } + + property_get(argv[1], value, default_value); + printf("%s\n", value); + } + return 0; +} |