]> sbz's 6dev Repos - android-sysinfo/.git/blame - sysinfo.c
Add output section on devices
[android-sysinfo/.git] / sysinfo.c
CommitLineData
410f5cae
SB
1#include <stdio.h>
2
3#include <sys/utsname.h>
4#include <sys/system_properties.h>
5
6struct prop {
7 char *key_name;
8 char *prop_name;
9};
10
11static void system_kernel(void)
12{
13 struct utsname uts;
14 char build_host[512];
15 char build_user[512];
16
17 __system_property_get("ro.build.host", build_host);
18 __system_property_get("ro.build.user", build_user);
19
20 if (uname(&uts) != -1) {
21 printf("%-25s: %s %s %s@%s %s %s\n", "Kernel version", uts.sysname,
22 uts.release, build_user, build_host, uts.version, uts.machine);
23 }
24}
25
26static void system_properties(struct prop *array, int size)
27{
28 int i, len;
29 char value[1024] = {0};
30
31 for (i=0; i < size; i++) {
32 if (i == 4)
33 system_kernel();
34
35 len = __system_property_get(array[i].prop_name, value);
36 value[len] = '\0';
37 printf("%-25s: %s\n", array[i].key_name, value);
38 }
39
40}
41
42int
43main(void)
44{
45 struct prop props[] = {
46 {.key_name = "Model number", .prop_name = "ro.product.model"},
47 {.key_name = "Android codename", .prop_name = "ro.build.product"},
48 {.key_name = "Android version", .prop_name = "ro.build.version.release"},
49 {.key_name = "Android SDK version", .prop_name = "ro.build.version.sdk"},
50 {.key_name = "Baseband version", .prop_name = "gsm.version.baseband"},
51 {.key_name = "Build number", .prop_name = "ro.build.display.id"},
52 };
53
54 system_properties(props, sizeof(props) / sizeof(props[0]));
55
56 return (0);
57}