diff options
author | Elliott Hughes <enh@google.com> | 2016-12-27 12:17:50 -0800 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-12-28 22:49:26 -0600 |
commit | 45c6b12a0a0f09054ab1fee9197860aee27b2e8a (patch) | |
tree | b7344397bfec65ea96d8f0ef6220bde442e661ec /toys/android/getprop.c | |
parent | 6bce3be4a3fcb1c3b01d86ffaec2b605c692822d (diff) | |
download | toybox-45c6b12a0a0f09054ab1fee9197860aee27b2e8a.tar.gz |
Switch to bionic <sys/system_properties.h>.
Removes the dependency on libcutils for everything except ps.
Diffstat (limited to 'toys/android/getprop.c')
-rw-r--r-- | toys/android/getprop.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/toys/android/getprop.c b/toys/android/getprop.c index 2df6c0a8..305a7a96 100644 --- a/toys/android/getprop.c +++ b/toys/android/getprop.c @@ -17,7 +17,7 @@ config GETPROP #define FOR_getprop #include "toys.h" -#include <cutils/properties.h> +#include <sys/system_properties.h> #include <selinux/android.h> #include <selinux/label.h> @@ -39,8 +39,13 @@ static char *get_property_context(char *property) return context; } -static void add_property(char *name, char *value, void *unused) +static void add_property(const prop_info *pi, void *unused) { + char name[PROP_NAME_MAX]; + char value[PROP_VALUE_MAX]; + + __system_property_read(pi, name, value); + if (!(TT.size&31)) TT.nv = xrealloc(TT.nv, (TT.size+32)*2*sizeof(char *)); TT.nv[2*TT.size] = xstrdup(name); @@ -58,7 +63,7 @@ static int selinux_log_callback_local(int type, const char *fmt, ...) if (type == SELINUX_INFO) return 0; va_start(ap, fmt); - verror_msg(fmt, 0, ap); + verror_msg((char *)fmt, 0, ap); va_end(ap); return 0; } @@ -81,13 +86,15 @@ void getprop_main(void) puts(context); if (CFG_TOYBOX_FREE) free(context); } else { - property_get(*toys.optargs, toybuf, toys.optargs[1] ? toys.optargs[1] : ""); + if (__system_property_get(*toys.optargs, toybuf) <= 0) + strcpy(toybuf, toys.optargs[1] ? toys.optargs[1] : ""); puts(toybuf); } } else { size_t i; - if (property_list((void *)add_property, 0)) error_exit("property_list"); + if (__system_property_foreach(add_property, NULL)) + error_exit("property_list"); qsort(TT.nv, TT.size, 2*sizeof(char *), qstrcmp); for (i = 0; i<TT.size; i++) printf("[%s]: [%s]\n", TT.nv[i*2],TT.nv[1+i*2]); if (CFG_TOYBOX_FREE) { |