2009-03-04 11:32:55 +08:00
|
|
|
#include <stdio.h>
|
2011-01-06 15:39:44 +08:00
|
|
|
#include <stdlib.h>
|
2009-03-04 11:32:55 +08:00
|
|
|
|
|
|
|
#include <cutils/properties.h>
|
|
|
|
|
|
|
|
#include <sys/system_properties.h>
|
2011-01-06 15:39:44 +08:00
|
|
|
#include "dynarray.h"
|
2009-03-04 11:32:55 +08:00
|
|
|
|
2011-01-06 15:39:44 +08:00
|
|
|
static void record_prop(const char* key, const char* name, void* opaque)
|
2009-03-04 11:32:55 +08:00
|
|
|
{
|
2011-01-06 15:39:44 +08:00
|
|
|
strlist_t* list = opaque;
|
|
|
|
char temp[PROP_VALUE_MAX + PROP_NAME_MAX + 16];
|
2011-02-15 09:17:21 +08:00
|
|
|
snprintf(temp, sizeof temp, "[%s]: [%s]", key, name);
|
2011-01-06 15:39:44 +08:00
|
|
|
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);
|
2009-03-04 11:32:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int __system_property_wait(prop_info *pi);
|
|
|
|
|
|
|
|
int getprop_main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
if (argc == 1) {
|
2011-01-06 15:39:44 +08:00
|
|
|
list_properties();
|
2009-03-04 11:32:55 +08:00
|
|
|
} 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;
|
|
|
|
}
|