source: titan/titan/system_infos_sysinfo.h @ 24101

Last change on this file since 24101 was 18644, checked in by nit, 11 years ago

[titan] add usb info screen

File size: 2.9 KB
Line 
1#ifndef SYSTEM_INFOS_SYSINFO_H
2#define SYSTEM_INFOS_SYSINFO_H
3
4void screensystem_infos_sysinfo(int mode)
5{
6
7        char* tmpstr = NULL;
8        int rcret = 0;
9        struct skin* system_info = getscreen("system_infos");
10        struct skin* info = getscreennode(system_info, "info");
11
12        addscreenrc(system_info, info);
13
14        if(mode == 0)
15        {
16                changetitle(system_info, _("CPU info"));
17
18                tmpstr = command("cat /proc/cpuinfo | sed 's/\t\t/\t/'");
19                changetext(info, _(tmpstr));
20
21                free(tmpstr); tmpstr = NULL;
22        }
23
24        if(mode == 1)
25        {
26                changetitle(system_info, _("Memory info"));
27
28                tmpstr = command("cat /proc/meminfo");
29                changetext(info, _(tmpstr));
30
31                free(tmpstr); tmpstr = NULL;
32        }
33
34        if(mode == 2)
35        {
36                changetitle(system_info, _("MTD info"));
37
38                tmpstr = command("cat /proc/mtd");
39                changetext(info, _(tmpstr));
40
41                free(tmpstr); tmpstr = NULL;
42        }
43
44        if(mode == 3)
45        {
46                changetitle(system_info, _("Module info"));
47
48                tmpstr = command("cat /proc/modules");
49                changetext(info, _(tmpstr));
50
51                free(tmpstr); tmpstr = NULL;
52        }
53
54        if(mode == 4)
55        {
56                changetitle(system_info, _("Devices"));
57
58                tmpstr = command("cat /proc/devices");
59                changetext(info, _(tmpstr));
60
61                free(tmpstr); tmpstr = NULL;
62        }
63
64        if(mode == 5)
65        {
66                char* tmpstr1 = NULL, **tmpstr2 = NULL, **tmpstr3 = NULL;
67                int i = 0, ii = 0;
68                char* swap[] = {"Name: ", "Type: ", "Size: ", "Used: ", "Prio: "};
69
70                changetitle(system_info, _("Swap info"));
71
72                tmpstr1 = command("cat /proc/swaps | sed 's/\t/ /g; s/[ ]* / /g'");
73                tmpstr2 = str_split(tmpstr1, "\n");
74                if(tmpstr2 != NULL)
75                {
76                        free(tmpstr2[0]); tmpstr2[0] = NULL;
77
78                        for(i = 1; tmpstr2[i] != NULL; i++)
79                        {
80                                tmpstr3 = str_split(tmpstr2[i], " ");
81                                if(tmpstr3 != NULL)
82                                {
83
84                                        for(ii = 0; tmpstr3[ii] != NULL; ii++)
85                                        {
86                                                tmpstr = ostrcat(tmpstr, swap[ii], 1, 0);
87                                                tmpstr = ostrcat(tmpstr, tmpstr3[ii], 1, 1);
88                                                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
89                                        }
90                                }
91
92                                tmpstr = ostrcat(tmpstr, "\n", 1, 0);
93                                free(tmpstr2[i]); tmpstr2[i] = NULL;
94                                free(tmpstr3); tmpstr3 = NULL;
95                        }
96                }
97
98                changetext(info, _(tmpstr));
99
100                free(tmpstr3); tmpstr3 = NULL;
101                free(tmpstr2); tmpstr2 = NULL;
102                free(tmpstr1); tmpstr1 = NULL;
103                free(tmpstr); tmpstr = NULL;
104        }
105
106        if(mode == 6)
107        {
108                changetitle(system_info, _("Top Info"));
109
110                tmpstr = command("top -b -n1");
111                changetext(info, tmpstr);
112
113                free(tmpstr); tmpstr = NULL;
114        }
115
116        if(mode == 7)
117        {
118                changetitle(system_info, _("Prozess Info"));
119
120                tmpstr = command("ps");
121                changetext(info, tmpstr);
122
123                free(tmpstr); tmpstr = NULL;
124        }
125
126        if(mode == 8)
127        {
128                changetitle(system_info, _("USB Info"));
129
130                tmpstr = command("cat /proc/bus/usb/devices");
131                changetext(info, tmpstr);
132
133                free(tmpstr); tmpstr = NULL;
134        }
135
136        drawscreen(system_info, 0, 0);
137
138        while(1)
139        {
140                rcret = waitrc(system_info, 0, 0);
141
142                if(rcret == getrcconfigint("rcexit", NULL)) break;
143                if(rcret == getrcconfigint("rcok", NULL)) break;
144        }
145
146        delownerrc(system_info);
147        clearscreen(system_info);
148        //delscreen(system_info);
149}
150
151#endif
Note: See TracBrowser for help on using the repository browser.