diff options
author | Elliott Hughes <enh@google.com> | 2015-08-10 19:27:18 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-11-14 19:54:49 +0100 |
commit | aea0d7b3b6123b353595a6f6a2a3fbb0d252d7e1 (patch) | |
tree | 1aea7129f948ebdea1e8ef3d228788010f875d38 | |
parent | 78b569a395407d13b8d571d7c73d6a46d4a99492 (diff) | |
download | system_core-aea0d7b3b6123b353595a6f6a2a3fbb0d252d7e1.zip system_core-aea0d7b3b6123b353595a6f6a2a3fbb0d252d7e1.tar.gz system_core-aea0d7b3b6123b353595a6f6a2a3fbb0d252d7e1.tar.bz2 |
Remove watchprops.
Since watchprops would have to be rewritten anyway in the upcoming properties
rewrite, there seems little point in rewriting it for toybox first. Let's
see how many people actually use watchprops and decide whether it's worth
the effort...
Change-Id: I996e7209bc81633ee66602f09f130226336d9987
-rw-r--r-- | toolbox/Android.mk | 1 | ||||
-rw-r--r-- | toolbox/watchprops.c | 92 |
2 files changed, 0 insertions, 93 deletions
diff --git a/toolbox/Android.mk b/toolbox/Android.mk index 255d348..74d69f5 100644 --- a/toolbox/Android.mk +++ b/toolbox/Android.mk @@ -56,7 +56,6 @@ OUR_TOOLS := \ stop \ top \ uptime \ - watchprops \ ALL_TOOLS = $(BSD_TOOLS) $(OUR_TOOLS) diff --git a/toolbox/watchprops.c b/toolbox/watchprops.c deleted file mode 100644 index cd62922..0000000 --- a/toolbox/watchprops.c +++ /dev/null @@ -1,92 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <errno.h> - -#include <cutils/properties.h> -#include <cutils/hashmap.h> - -#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ -#include <sys/_system_properties.h> - -static int str_hash(void *key) -{ - return hashmapHash(key, strlen(key)); -} - -static bool str_equals(void *keyA, void *keyB) -{ - return strcmp(keyA, keyB) == 0; -} - -static void announce(char *name, char *value) -{ - unsigned char *x; - - for(x = (unsigned char *)value; *x; x++) { - if((*x < 32) || (*x > 127)) *x = '.'; - } - - fprintf(stderr,"%10d %s = '%s'\n", (int) time(0), name, value); -} - -static void add_to_watchlist(Hashmap *watchlist, const char *name, - const prop_info *pi) -{ - char *key = strdup(name); - unsigned *value = malloc(sizeof(unsigned)); - if (!key || !value) - exit(1); - - *value = __system_property_serial(pi); - hashmapPut(watchlist, key, value); -} - -static void populate_watchlist(const prop_info *pi, void *cookie) -{ - Hashmap *watchlist = cookie; - char name[PROP_NAME_MAX]; - char value_unused[PROP_VALUE_MAX]; - - __system_property_read(pi, name, value_unused); - add_to_watchlist(watchlist, name, pi); -} - -static void update_watchlist(const prop_info *pi, void *cookie) -{ - Hashmap *watchlist = cookie; - char name[PROP_NAME_MAX]; - char value[PROP_VALUE_MAX]; - unsigned *serial; - - __system_property_read(pi, name, value); - serial = hashmapGet(watchlist, name); - if (!serial) { - add_to_watchlist(watchlist, name, pi); - announce(name, value); - } else { - unsigned tmp = __system_property_serial(pi); - if (*serial != tmp) { - *serial = tmp; - announce(name, value); - } - } -} - -int watchprops_main(int argc, char *argv[]) -{ - unsigned serial; - - Hashmap *watchlist = hashmapCreate(1024, str_hash, str_equals); - if (!watchlist) - exit(1); - - __system_property_foreach(populate_watchlist, watchlist); - - for(serial = 0;;) { - serial = __system_property_wait_any(serial); - __system_property_foreach(update_watchlist, watchlist); - } - return 0; -} |