summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenis Vlasenko2006-10-26 23:21:47 +0000
committerDenis Vlasenko2006-10-26 23:21:47 +0000
commitf0ed376eda5d5c25d270e5100a881fb2d801bee6 (patch)
tree79166b700c497fbe798b6031e5bbff97e0933573 /miscutils
parent670a6626cabc1498f32b35f959591f8621d8447e (diff)
downloadbusybox-f0ed376eda5d5c25d270e5100a881fb2d801bee6.zip
busybox-f0ed376eda5d5c25d270e5100a881fb2d801bee6.tar.gz
remove bb_printf and the like
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/crond.c24
-rw-r--r--miscutils/devfsd.c8
-rw-r--r--miscutils/last.c2
-rw-r--r--miscutils/less.c39
-rw-r--r--miscutils/mountpoint.c73
-rw-r--r--miscutils/rx.c2
-rw-r--r--miscutils/strings.c2
7 files changed, 81 insertions, 69 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 4fc940b..b18e274 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -264,7 +264,7 @@ int crond_main(int ac, char **av)
}
}
}
- bb_fflush_stdout_and_exit(EXIT_SUCCESS); /* not reached */
+ return 0; /* not reached */
}
static int ChangeUser(const char *user)
@@ -278,7 +278,7 @@ static int ChangeUser(const char *user)
pas = getpwnam(user);
if (pas == 0) {
crondlog("\011failed to get uid for %s", user);
- return (-1);
+ return -1;
}
setenv("USER", pas->pw_name, 1);
setenv("HOME", pas->pw_dir, 1);
@@ -290,16 +290,16 @@ static int ChangeUser(const char *user)
err_msg = change_identity_e2str(pas);
if (err_msg) {
crondlog("\011%s for user %s", err_msg, user);
- return (-1);
+ return -1;
}
if (chdir(pas->pw_dir) < 0) {
crondlog("\011chdir failed: %s: %m", pas->pw_dir);
if (chdir(TMPDIR) < 0) {
crondlog("\011chdir failed: %s: %m", TMPDIR);
- return (-1);
+ return -1;
}
}
- return (pas->pw_uid);
+ return pas->pw_uid;
}
static void startlogger(void)
@@ -377,7 +377,7 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
int n2 = -1;
if (base == NULL) {
- return (NULL);
+ return NULL;
}
while (*ptr != ' ' && *ptr != '\t' && *ptr != '\n') {
@@ -420,7 +420,7 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
if (skip == 0) {
crondlog("\111failed user %s parsing %s\n", user, base);
- return (NULL);
+ return NULL;
}
if (*ptr == '-' && n2 < 0) {
++ptr;
@@ -460,7 +460,7 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
if (failsafe == 0) {
crondlog("\111failed user %s parsing %s\n", user, base);
- return (NULL);
+ return NULL;
}
}
if (*ptr != ',') {
@@ -473,7 +473,7 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
if (*ptr != ' ' && *ptr != '\t' && *ptr != '\n') {
crondlog("\111failed user %s parsing %s\n", user, base);
- return (NULL);
+ return NULL;
}
while (*ptr == ' ' || *ptr == '\t' || *ptr == '\n') {
@@ -490,7 +490,7 @@ static char *ParseField(char *user, char *ary, int modvalue, int off,
}
#endif
- return (ptr);
+ return ptr;
}
static void FixDayDow(CronLine * line)
@@ -777,7 +777,7 @@ static int TestJobs(time_t t1, time_t t2)
}
}
}
- return (nJobs);
+ return nJobs;
}
static void RunJobs(void)
@@ -843,7 +843,7 @@ static int CheckJobs(void)
}
nStillRunning += file->cf_Running;
}
- return (nStillRunning);
+ return nStillRunning;
}
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index f1fee2c..32973d6 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -491,9 +491,9 @@ int devfsd_main (int argc, char **argv)
if ( print_version || (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev) )
{
- bb_printf( "%s v%s\nDaemon %s:\t%d\nKernel-side %s:\t%d\n",
- applet_name,DEVFSD_VERSION,bb_msg_proto_rev,
- DEVFSD_PROTOCOL_REVISION_DAEMON,bb_msg_proto_rev, proto_rev);
+ printf( "%s v%s\nDaemon %s:\t%d\nKernel-side %s:\t%d\n",
+ applet_name,DEVFSD_VERSION,bb_msg_proto_rev,
+ DEVFSD_PROTOCOL_REVISION_DAEMON,bb_msg_proto_rev, proto_rev);
if (DEVFSD_PROTOCOL_REVISION_DAEMON != proto_rev)
bb_error_msg_and_die( "%s mismatch!",bb_msg_proto_rev);
exit(EXIT_SUCCESS); /* -v */
@@ -509,7 +509,7 @@ int devfsd_main (int argc, char **argv)
if (sigaction (SIGHUP, &new_action, NULL) != 0 || sigaction (SIGUSR1, &new_action, NULL) != 0 )
devfsd_error_msg_and_die( "sigaction");
- bb_printf("%s v%s started for %s\n",applet_name, DEVFSD_VERSION, mount_point);
+ printf("%s v%s started for %s\n",applet_name, DEVFSD_VERSION, mount_point);
/* Set umask so that mknod(2), open(2) and mkdir(2) have complete control over permissions */
umask (0);
diff --git a/miscutils/last.c b/miscutils/last.c
index 9f9f639..668f0c1 100644
--- a/miscutils/last.c
+++ b/miscutils/last.c
@@ -87,5 +87,5 @@ int last_main(int argc, char **argv)
ctime(&t_tmp) + 4);
}
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
diff --git a/miscutils/less.c b/miscutils/less.c
index 11f1d8b..de97ba6 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -76,7 +76,7 @@ static int num_files = 1;
static int past_eof;
/* Command line options */
-static unsigned long flags;
+static unsigned flags;
#define FLAG_E 1
#define FLAG_M (1<<1)
#define FLAG_m (1<<2)
@@ -185,12 +185,12 @@ static void clear_line(void)
/* This adds line numbers to every line, as the -N flag necessitates */
static void add_linenumbers(void)
{
- char current_line[256];
int i;
for (i = 0; i <= num_flines; i++) {
- safe_strncpy(current_line, flines[i], 256);
- flines[i] = xasprintf("%5d %s", i + 1, current_line);
+ char *new = xasprintf("%5d %s", i + 1, flines[i]);
+ free(flines[i]);
+ flines[i] = new;
}
}
@@ -206,7 +206,7 @@ static void data_readlines(void)
strcpy(current_line, "");
fgets(current_line, 256, fp);
if (fp != stdin)
- xferror(fp, filename);
+ die_if_ferror(fp, filename);
flines = xrealloc(flines, (i+1) * sizeof(char *));
flines[i] = xstrdup(current_line);
}
@@ -243,13 +243,18 @@ static void m_status_print(void)
if (!past_eof) {
if (!line_pos) {
if (num_files > 1)
- printf("%s%s %s%i%s%i%s%i-%i/%i ", HIGHLIGHT, filename, "(file ", current_file, " of ", num_files, ") lines ", line_pos + 1, line_pos + height - 1, num_flines + 1);
+ printf("%s%s %s%i%s%i%s%i-%i/%i ", HIGHLIGHT,
+ filename, "(file ", current_file, " of ", num_files, ") lines ",
+ line_pos + 1, line_pos + height - 1, num_flines + 1);
else {
- printf("%s%s lines %i-%i/%i ", HIGHLIGHT, filename, line_pos + 1, line_pos + height - 1, num_flines + 1);
+ printf("%s%s lines %i-%i/%i ", HIGHLIGHT,
+ filename, line_pos + 1, line_pos + height - 1,
+ num_flines + 1);
}
}
else {
- printf("%s %s lines %i-%i/%i ", HIGHLIGHT, filename, line_pos + 1, line_pos + height - 1, num_flines + 1);
+ printf("%s %s lines %i-%i/%i ", HIGHLIGHT, filename,
+ line_pos + 1, line_pos + height - 1, num_flines + 1);
}
if (line_pos == num_flines - height + 2) {
@@ -263,7 +268,8 @@ static void m_status_print(void)
}
}
else {
- printf("%s%s lines %i-%i/%i (END) ", HIGHLIGHT, filename, line_pos + 1, num_flines + 1, num_flines + 1);
+ printf("%s%s lines %i-%i/%i (END) ", HIGHLIGHT, filename,
+ line_pos + 1, num_flines + 1, num_flines + 1);
if ((num_files > 1) && (current_file != num_files))
printf("- Next: %s", files[current_file]);
printf("%s", NORMAL);
@@ -300,7 +306,8 @@ static void status_print(void)
if (!line_pos) {
printf("%s%s %s", HIGHLIGHT, filename, NORMAL);
if (num_files > 1)
- printf("%s%s%i%s%i%s%s", HIGHLIGHT, "(file ", current_file, " of ", num_files, ")", NORMAL);
+ printf("%s%s%i%s%i%s%s", HIGHLIGHT, "(file ",
+ current_file, " of ", num_files, ")", NORMAL);
}
else if (line_pos == num_flines - height + 2) {
printf("%s%s %s", HIGHLIGHT, "(END)", NORMAL);
@@ -602,7 +609,7 @@ static char *process_regex_on_line(char *line, regex_t *pattern, int action)
insert_highlights if action = 1, or has the escape sequences
removed if action = 0, and then the line is returned. */
int match_status;
- char *line2 = (char *) xmalloc((sizeof(char) * (strlen(line) + 1)) + 64);
+ char *line2 = xmalloc((sizeof(char) * (strlen(line) + 1)) + 64);
char *growline = "";
regmatch_t match_structs;
@@ -616,10 +623,16 @@ static char *process_regex_on_line(char *line, regex_t *pattern, int action)
match_found = 1;
if (action) {
- growline = xasprintf("%s%.*s%s%.*s%s", growline, match_structs.rm_so, line2, HIGHLIGHT, match_structs.rm_eo - match_structs.rm_so, line2 + match_structs.rm_so, NORMAL);
+ growline = xasprintf("%s%.*s%s%.*s%s", growline,
+ match_structs.rm_so, line2, HIGHLIGHT,
+ match_structs.rm_eo - match_structs.rm_so,
+ line2 + match_structs.rm_so, NORMAL);
}
else {
- growline = xasprintf("%s%.*s%.*s", growline, match_structs.rm_so - 4, line2, match_structs.rm_eo - match_structs.rm_so, line2 + match_structs.rm_so);
+ growline = xasprintf("%s%.*s%.*s", growline,
+ match_structs.rm_so - 4, line2,
+ match_structs.rm_eo - match_structs.rm_so,
+ line2 + match_structs.rm_so);
}
line2 += match_structs.rm_eo;
diff --git a/miscutils/mountpoint.c b/miscutils/mountpoint.c
index dbc8fe0..b1bcab6 100644
--- a/miscutils/mountpoint.c
+++ b/miscutils/mountpoint.c
@@ -13,6 +13,8 @@
int mountpoint_main(int argc, char **argv)
{
+ struct stat st;
+ char *arg;
int opt = getopt32(argc, argv, "qdx");
#define OPT_q (1)
#define OPT_d (2)
@@ -20,47 +22,44 @@ int mountpoint_main(int argc, char **argv)
if (optind != argc - 1)
bb_show_usage();
- {
- char *arg = argv[optind];
- struct stat st;
- if ( (opt & OPT_x && stat(arg, &st) == 0) || (lstat(arg, &st) == 0) ) {
- if (opt & OPT_x) {
- if (S_ISBLK(st.st_mode))
- {
- bb_printf("%u:%u\n", major(st.st_rdev),
- minor(st.st_rdev));
- return EXIT_SUCCESS;
- } else {
- if (opt & OPT_q)
- putchar('\n');
- else
- bb_error_msg("%s: not a block device", arg);
- }
- return EXIT_FAILURE;
- } else
- if (S_ISDIR(st.st_mode)) {
- dev_t st_dev = st.st_dev;
- ino_t st_ino = st.st_ino;
- char *p = xasprintf("%s/..", arg);
+ arg = argv[optind];
- if (stat(p, &st) == 0) {
- short ret = (st_dev != st.st_dev) ||
- (st_dev == st.st_dev && st_ino == st.st_ino);
- if (opt & OPT_d)
- bb_printf("%u:%u\n", major(st_dev), minor(st_dev));
- else if (!(opt & OPT_q))
- bb_printf("%s is %sa mountpoint\n", arg, ret?"":"not ");
- return !ret;
- }
+ if ( (opt & OPT_x && stat(arg, &st) == 0) || (lstat(arg, &st) == 0) ) {
+ if (opt & OPT_x) {
+ if (S_ISBLK(st.st_mode)) {
+ printf("%u:%u\n", major(st.st_rdev),
+ minor(st.st_rdev));
+ return EXIT_SUCCESS;
} else {
- if (!(opt & OPT_q))
- bb_error_msg("%s: not a directory", arg);
- return EXIT_FAILURE;
+ if (opt & OPT_q)
+ putchar('\n');
+ else
+ bb_error_msg("%s: not a block device", arg);
}
+ return EXIT_FAILURE;
+ } else
+ if (S_ISDIR(st.st_mode)) {
+ dev_t st_dev = st.st_dev;
+ ino_t st_ino = st.st_ino;
+ char *p = xasprintf("%s/..", arg);
+
+ if (stat(p, &st) == 0) {
+ int ret = (st_dev != st.st_dev) ||
+ (st_dev == st.st_dev && st_ino == st.st_ino);
+ if (opt & OPT_d)
+ printf("%u:%u\n", major(st_dev), minor(st_dev));
+ else if (!(opt & OPT_q))
+ printf("%s is %sa mountpoint\n", arg, ret?"":"not ");
+ return !ret;
+ }
+ } else {
+ if (!(opt & OPT_q))
+ bb_error_msg("%s: not a directory", arg);
+ return EXIT_FAILURE;
}
- if (!(opt & OPT_q))
- bb_perror_msg("%s", arg);
- return EXIT_FAILURE;
}
+ if (!(opt & OPT_q))
+ bb_perror_msg("%s", arg);
+ return EXIT_FAILURE;
}
diff --git a/miscutils/rx.c b/miscutils/rx.c
index 00951b7..f723c16 100644
--- a/miscutils/rx.c
+++ b/miscutils/rx.c
@@ -286,5 +286,5 @@ int rx_main(int argc, char **argv)
if (n < 0)
bb_error_msg_and_die("\nreceive failed:\n %s", error_buf);
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
diff --git a/miscutils/strings.c b/miscutils/strings.c
index 1ff41ad..dae1731 100644
--- a/miscutils/strings.c
+++ b/miscutils/strings.c
@@ -84,5 +84,5 @@ PIPE:
if (ENABLE_FEATURE_CLEAN_UP)
free(string);
- bb_fflush_stdout_and_exit(status);
+ fflush_stdout_and_exit(status);
}