summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2015-08-10 21:27:18 -0500
committerElliott Hughes2015-08-10 21:27:18 -0500
commite8606c85c5c4068d445c283f1d48955c9aa81470 (patch)
tree253f4ee0c9fb80fb3a2fb67f8217024bfebac474
parent1f36ae49b97d4b72fa9aca9bb6b4131acec5bccf (diff)
downloadplatform-system-core-e8606c85c5c4068d445c283f1d48955c9aa81470.tar.gz
platform-system-core-e8606c85c5c4068d445c283f1d48955c9aa81470.tar.xz
platform-system-core-e8606c85c5c4068d445c283f1d48955c9aa81470.zip
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.mk1
-rw-r--r--toolbox/watchprops.c92
2 files changed, 0 insertions, 93 deletions
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index aa92af7e7..ae880c394 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -56,7 +56,6 @@ OUR_TOOLS := \
56 stop \ 56 stop \
57 top \ 57 top \
58 uptime \ 58 uptime \
59 watchprops \
60 59
61ALL_TOOLS = $(BSD_TOOLS) $(OUR_TOOLS) 60ALL_TOOLS = $(BSD_TOOLS) $(OUR_TOOLS)
62 61
diff --git a/toolbox/watchprops.c b/toolbox/watchprops.c
deleted file mode 100644
index cd62922cf..000000000
--- a/toolbox/watchprops.c
+++ /dev/null
@@ -1,92 +0,0 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <time.h>
5#include <errno.h>
6
7#include <cutils/properties.h>
8#include <cutils/hashmap.h>
9
10#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
11#include <sys/_system_properties.h>
12
13static int str_hash(void *key)
14{
15 return hashmapHash(key, strlen(key));
16}
17
18static bool str_equals(void *keyA, void *keyB)
19{
20 return strcmp(keyA, keyB) == 0;
21}
22
23static void announce(char *name, char *value)
24{
25 unsigned char *x;
26
27 for(x = (unsigned char *)value; *x; x++) {
28 if((*x < 32) || (*x > 127)) *x = '.';
29 }
30
31 fprintf(stderr,"%10d %s = '%s'\n", (int) time(0), name, value);
32}
33
34static void add_to_watchlist(Hashmap *watchlist, const char *name,
35 const prop_info *pi)
36{
37 char *key = strdup(name);
38 unsigned *value = malloc(sizeof(unsigned));
39 if (!key || !value)
40 exit(1);
41
42 *value = __system_property_serial(pi);
43 hashmapPut(watchlist, key, value);
44}
45
46static void populate_watchlist(const prop_info *pi, void *cookie)
47{
48 Hashmap *watchlist = cookie;
49 char name[PROP_NAME_MAX];
50 char value_unused[PROP_VALUE_MAX];
51
52 __system_property_read(pi, name, value_unused);
53 add_to_watchlist(watchlist, name, pi);
54}
55
56static void update_watchlist(const prop_info *pi, void *cookie)
57{
58 Hashmap *watchlist = cookie;
59 char name[PROP_NAME_MAX];
60 char value[PROP_VALUE_MAX];
61 unsigned *serial;
62
63 __system_property_read(pi, name, value);
64 serial = hashmapGet(watchlist, name);
65 if (!serial) {
66 add_to_watchlist(watchlist, name, pi);
67 announce(name, value);
68 } else {
69 unsigned tmp = __system_property_serial(pi);
70 if (*serial != tmp) {
71 *serial = tmp;
72 announce(name, value);
73 }
74 }
75}
76
77int watchprops_main(int argc, char *argv[])
78{
79 unsigned serial;
80
81 Hashmap *watchlist = hashmapCreate(1024, str_hash, str_equals);
82 if (!watchlist)
83 exit(1);
84
85 __system_property_foreach(populate_watchlist, watchlist);
86
87 for(serial = 0;;) {
88 serial = __system_property_wait_any(serial);
89 __system_property_foreach(update_watchlist, watchlist);
90 }
91 return 0;
92}