diff options
author | Rob Landley <rob@landley.net> | 2006-08-03 15:41:12 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-08-03 15:41:12 +0000 |
commit | d921b2ecc0d294ad4bf8c7458fc52a60c28727d2 (patch) | |
tree | e4a2769349867c441cf2983d83097bb66701a733 /procps | |
parent | 6dce0b6fa79f2d4bb7e9d90e1fbc0f6beb25f855 (diff) | |
download | busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.gz busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.bz2 busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.zip |
Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only
had one user), clean up lots of #includes... General cleanup pass. What I've
been doing for the last couple days.
And it conflicts! I've removed httpd.c from this checkin due to somebody else
touching that file. It builds for me. I have to catch a bus. (Now you know
why I'm looking forward to Mercurial.)
Diffstat (limited to 'procps')
-rw-r--r-- | procps/sysctl.c | 17 | ||||
-rw-r--r-- | procps/top.c | 21 |
2 files changed, 8 insertions, 30 deletions
diff --git a/procps/sysctl.c b/procps/sysctl.c index 5673d293f..03a03889e 100644 --- a/procps/sysctl.c +++ b/procps/sysctl.c | |||
@@ -15,15 +15,6 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include "busybox.h" | 17 | #include "busybox.h" |
18 | #include <stdio.h> | ||
19 | #include <stdlib.h> | ||
20 | #include <unistd.h> | ||
21 | #include <sys/stat.h> | ||
22 | #include <sys/types.h> | ||
23 | #include <dirent.h> | ||
24 | #include <string.h> | ||
25 | #include <errno.h> | ||
26 | #include <fcntl.h> | ||
27 | 18 | ||
28 | /* | 19 | /* |
29 | * Function Prototypes | 20 | * Function Prototypes |
@@ -202,8 +193,8 @@ int sysctl_write_setting(const char *setting, int output) | |||
202 | return -2; | 193 | return -2; |
203 | } | 194 | } |
204 | 195 | ||
205 | tmpname = bb_xasprintf("%s%.*s", PROC_PATH, (int)(equals - name), name); | 196 | tmpname = xasprintf("%s%.*s", PROC_PATH, (int)(equals - name), name); |
206 | outname = bb_xstrdup(tmpname + strlen(PROC_PATH)); | 197 | outname = xstrdup(tmpname + strlen(PROC_PATH)); |
207 | 198 | ||
208 | while ((cptr = strchr(tmpname, '.')) != NULL) | 199 | while ((cptr = strchr(tmpname, '.')) != NULL) |
209 | *cptr = '/'; | 200 | *cptr = '/'; |
@@ -258,7 +249,7 @@ int sysctl_read_setting(const char *setting, int output) | |||
258 | bb_error_msg(ERR_INVALID_KEY, setting); | 249 | bb_error_msg(ERR_INVALID_KEY, setting); |
259 | 250 | ||
260 | tmpname = concat_path_file(PROC_PATH, name); | 251 | tmpname = concat_path_file(PROC_PATH, name); |
261 | outname = bb_xstrdup(tmpname + strlen(PROC_PATH)); | 252 | outname = xstrdup(tmpname + strlen(PROC_PATH)); |
262 | 253 | ||
263 | while ((cptr = strchr(tmpname, '.')) != NULL) | 254 | while ((cptr = strchr(tmpname, '.')) != NULL) |
264 | *cptr = '/'; | 255 | *cptr = '/'; |
@@ -309,7 +300,7 @@ int sysctl_display_all(const char *path, int output, int show_table) | |||
309 | char *tmpdir; | 300 | char *tmpdir; |
310 | struct stat ts; | 301 | struct stat ts; |
311 | 302 | ||
312 | if (!(dp = bb_opendir(path))) { | 303 | if (!(dp = opendir(path))) { |
313 | retval = -1; | 304 | retval = -1; |
314 | } else { | 305 | } else { |
315 | while ((de = readdir(dp)) != NULL) { | 306 | while ((de = readdir(dp)) != NULL) { |
diff --git a/procps/top.c b/procps/top.c index bf30c23f6..1b6f7072f 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -29,22 +29,9 @@ | |||
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "busybox.h" | 31 | #include "busybox.h" |
32 | #include <sys/types.h> | ||
33 | #include <stdio.h> | ||
34 | #include <stdlib.h> | ||
35 | #include <unistd.h> | ||
36 | #include <string.h> | ||
37 | #include <sys/ioctl.h> | ||
38 | 32 | ||
39 | //#define CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE /* + 2k */ | 33 | //#define CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE /* + 2k */ |
40 | 34 | ||
41 | #ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE | ||
42 | #include <time.h> | ||
43 | #include <fcntl.h> | ||
44 | #include <netinet/in.h> /* htons */ | ||
45 | #endif | ||
46 | |||
47 | |||
48 | typedef int (*cmp_t)(procps_status_t *P, procps_status_t *Q); | 35 | typedef int (*cmp_t)(procps_status_t *P, procps_status_t *Q); |
49 | 36 | ||
50 | static procps_status_t *top; /* Hehe */ | 37 | static procps_status_t *top; /* Hehe */ |
@@ -116,7 +103,7 @@ static struct jiffy_counts jif, prev_jif; | |||
116 | 103 | ||
117 | static void get_jiffy_counts(void) | 104 | static void get_jiffy_counts(void) |
118 | { | 105 | { |
119 | FILE* fp = bb_xfopen("stat", "r"); | 106 | FILE* fp = xfopen("stat", "r"); |
120 | prev_jif = jif; | 107 | prev_jif = jif; |
121 | if (fscanf(fp, "cpu %lld %lld %lld %lld %lld %lld %lld %lld", | 108 | if (fscanf(fp, "cpu %lld %lld %lld %lld %lld %lld %lld %lld", |
122 | &jif.usr,&jif.nic,&jif.sys,&jif.idle, | 109 | &jif.usr,&jif.nic,&jif.sys,&jif.idle, |
@@ -196,7 +183,7 @@ static unsigned long display_generic(int scr_width) | |||
196 | unsigned int needs_conversion = 1; | 183 | unsigned int needs_conversion = 1; |
197 | 184 | ||
198 | /* read memory info */ | 185 | /* read memory info */ |
199 | fp = bb_xfopen("meminfo", "r"); | 186 | fp = xfopen("meminfo", "r"); |
200 | 187 | ||
201 | /* | 188 | /* |
202 | * Old kernels (such as 2.4.x) had a nice summary of memory info that | 189 | * Old kernels (such as 2.4.x) had a nice summary of memory info that |
@@ -238,7 +225,7 @@ static unsigned long display_generic(int scr_width) | |||
238 | fclose(fp); | 225 | fclose(fp); |
239 | 226 | ||
240 | /* read load average as a string */ | 227 | /* read load average as a string */ |
241 | fp = bb_xfopen("loadavg", "r"); | 228 | fp = xfopen("loadavg", "r"); |
242 | buf[0] = '\0'; | 229 | buf[0] = '\0'; |
243 | fgets(buf, sizeof(buf), fp); | 230 | fgets(buf, sizeof(buf), fp); |
244 | end = strchr(buf, ' '); | 231 | end = strchr(buf, ' '); |
@@ -414,7 +401,7 @@ int top_main(int argc, char **argv) | |||
414 | } | 401 | } |
415 | 402 | ||
416 | /* change to /proc */ | 403 | /* change to /proc */ |
417 | bb_xchdir("/proc"); | 404 | xchdir("/proc"); |
418 | #ifdef CONFIG_FEATURE_USE_TERMIOS | 405 | #ifdef CONFIG_FEATURE_USE_TERMIOS |
419 | tcgetattr(0, (void *) &initial_settings); | 406 | tcgetattr(0, (void *) &initial_settings); |
420 | memcpy(&new_settings, &initial_settings, sizeof(struct termios)); | 407 | memcpy(&new_settings, &initial_settings, sizeof(struct termios)); |