puts(s);
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
day_array(month, year, dp);
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
- bb_printf("%*s%s\n%s\n",
+ printf("%*s%s\n%s\n",
((7*julian + WEEK_LEN) - len) / 2, "",
lineout, day_headings);
for (row = 0; row < 6; row++) {
center(month_names[month + 1], week_len, HEAD_SEP);
}
center(month_names[month + 2 - julian], week_len, 0);
- bb_printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings);
+ printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings);
if (!julian) {
- bb_printf("%*s%s", HEAD_SEP, "", day_headings);
+ printf("%*s%s", HEAD_SEP, "", day_headings);
}
putchar('\n');
for (row = 0; row < (6*7); row += 7) {
}
}
- bb_fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(0);
}
/*
{
int n = strlen(str);
len -= n;
- bb_printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
+ printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
}
static void blank_string(char *buf, size_t buflen)
if (c > 126 && (flags & CATV_OPT_v)) {
if (c == 127) {
- bb_printf("^?");
+ printf("^?");
continue;
} else {
- bb_printf("M-");
+ printf("M-");
c -= 128;
}
}
if (flags & CATV_OPT_e)
putchar('$');
} else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) {
- bb_printf("^%c", c+'@');
+ printf("^%c", c+'@');
continue;
}
}
close(fd);
} while (*++argv);
- return retval;
+ fflush_stdout_and_exit(retval);
}
crc ^= 0xffffffffL;
if (inp_stdin) {
- bb_printf("%" PRIu32 " %li\n", crc, filesize);
+ printf("%" PRIu32 " %li\n", crc, filesize);
break;
}
- bb_printf("%" PRIu32 " %li %s\n", crc, filesize, *argv);
+ printf("%" PRIu32 " %li %s\n", crc, filesize, *argv);
fclose(fp);
} while (*(argv + 1));
- return EXIT_SUCCESS;
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
c1 = c2;
}
if (c1 == EOF) {
- xferror(fp1, filename1);
+ die_if_ferror(fp1, filename1);
fmt = fmt_eof; /* Well, no error, so it must really be EOF. */
outfile = stderr;
/* There may have been output to stdout (option -l), so
if (opt & CMP_OPT_l) {
line_pos = c1; /* line_pos is unused in the -l case. */
}
- bb_fprintf(outfile, fmt, filename1, filename2, char_pos, line_pos, c2);
+ fprintf(outfile, fmt, filename1, filename2, char_pos, line_pos, c2);
if (opt) { /* This must be -l since not -s. */
/* If we encountered an EOF,
* the while check will catch it. */
}
} while (c1 != EOF);
- xferror(fp1, filename1);
- xferror(fp2, filename2);
+ die_if_ferror(fp1, filename1);
+ die_if_ferror(fp2, filename2);
- bb_fflush_stdout_and_exit(retval);
+ fflush_stdout_and_exit(retval);
}
static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal)
{
- bb_fprintf(stderr, OFF_FMT"+"OFF_FMT" records in\n"
+ fprintf(stderr, OFF_FMT"+"OFF_FMT" records in\n"
OFF_FMT"+"OFF_FMT" records out\n",
in_full, in_part,
out_full, out_part);
#ifdef CONFIG_FEATURE_HUMAN_READABLE
opt_complementary = "h-km:k-hm:m-hk";
opt = getopt32(argc, argv, "hmk");
- if(opt & 1) {
- df_disp_hr = 0;
- disp_units_hdr = " Size";
+ if (opt & 1) {
+ df_disp_hr = 0;
+ disp_units_hdr = " Size";
}
- if(opt & 2) {
- df_disp_hr = MEGABYTE;
- disp_units_hdr = "1M-blocks";
+ if (opt & 2) {
+ df_disp_hr = MEGABYTE;
+ disp_units_hdr = "1M-blocks";
}
#else
opt = getopt32(argc, argv, "k");
#endif
- bb_printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
+ printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
"", disp_units_hdr);
mount_table = NULL;
argv += optind;
if (optind >= argc) {
- if (!(mount_table = setmntent(bb_path_mtab_file, "r"))) {
+ mount_table = setmntent(bb_path_mtab_file, "r");
+ if (!mount_table) {
bb_perror_msg_and_die(bb_path_mtab_file);
}
}
const char *mount_point;
if (mount_table) {
- if (!(mount_entry = getmntent(mount_table))) {
+ mount_entry = getmntent(mount_table);
+ if (!mount_entry) {
endmntent(mount_table);
break;
}
} else {
- if (!(mount_point = *argv++)) {
+ mount_point = *argv++;
+ if (!mount_point) {
break;
}
- if (!(mount_entry = find_mount_point(mount_point, bb_path_mtab_file))) {
- bb_error_msg("%s: can't find mount point.", mount_point);
+ mount_entry = find_mount_point(mount_point, bb_path_mtab_file);
+ if (!mount_entry) {
+ bb_error_msg("%s: can't find mount point", mount_point);
SET_ERROR:
status = EXIT_FAILURE;
continue;
blocks_percent_used = 0;
if (blocks_used + s.f_bavail) {
blocks_percent_used = (((long long) blocks_used) * 100
- + (blocks_used + s.f_bavail)/2
- ) / (blocks_used + s.f_bavail);
+ + (blocks_used + s.f_bavail)/2
+ ) / (blocks_used + s.f_bavail);
}
if (strcmp(device, "rootfs") == 0) {
} else if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
- if ((device = find_block_device("/")) == NULL) {
+ device = find_block_device("/");
+ if (!device) {
goto SET_ERROR;
}
}
#ifdef CONFIG_FEATURE_HUMAN_READABLE
- bb_printf("%-20s %9s ", device,
- make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
+ printf("%-20s %9s ", device,
+ make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
- bb_printf("%9s ",
- make_human_readable_str( (s.f_blocks - s.f_bfree),
- s.f_bsize, df_disp_hr));
+ printf("%9s ",
+ make_human_readable_str( (s.f_blocks - s.f_bfree),
+ s.f_bsize, df_disp_hr));
- bb_printf("%9s %3ld%% %s\n",
+ printf("%9s %3ld%% %s\n",
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
#else
- bb_printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
+ printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
kscale(s.f_blocks, s.f_bsize),
kscale(s.f_blocks-s.f_bfree, s.f_bsize),
} while (1);
- bb_fflush_stdout_and_exit(status);
+ fflush_stdout_and_exit(status);
}
puts(dirname(argv[1]));
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
{
/* TODO - May not want to defer error checking here. */
#ifdef CONFIG_FEATURE_HUMAN_READABLE
- bb_printf("%s\t%s\n", make_human_readable_str(size, 512, disp_hr),
+ printf("%s\t%s\n", make_human_readable_str(size, 512, disp_hr),
filename);
#else
if (disp_k) {
size++;
size >>= 1;
}
- bb_printf("%ld\t%s\n", size, filename);
+ printf("%ld\t%s\n", size, filename);
#endif
}
print(total, "total");
}
- bb_fflush_stdout_and_exit(status);
+ fflush_stdout_and_exit(status);
}
int echo_main(int argc, char** argv)
{
(void)bb_echo(argc, argv);
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
/*-
puts(*ep);
}
- bb_fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(0);
}
/*
bb_error_msg_and_die("syntax error");
if (v->type == integer)
- bb_printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
+ printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
else
puts(v->u.s);
- exit(null(v));
+ fflush_stdout_and_exit(null(v));
}
/* Return a VALUE for I. */
}
} while (*++argv);
- bb_fflush_stdout_and_exit(errs);
+ fflush_stdout_and_exit(errs);
}
#endif
do {
- if ((fp = bb_wfopen_input(*argv)) != NULL) {
+ fp = bb_wfopen_input(*argv);
+ if (fp) {
if (fp == stdin) {
*argv = (char *) bb_msg_standard_input;
}
if (header_threshhold) {
- bb_printf(fmt, *argv);
+ printf(fmt, *argv);
}
i = count;
while (i && ((c = getc(fp)) != EOF)) {
bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */
retval = EXIT_FAILURE;
}
- xferror_stdout();
+ die_if_ferror_stdout();
}
fmt = header_fmt_str;
} while (*++argv);
- bb_fflush_stdout_and_exit(retval);
+ fflush_stdout_and_exit(retval);
}
bb_show_usage();
}
- bb_printf("%lx\n", gethostid());
+ printf("%lx\n", gethostid());
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
fmt = "%cid=%u(%s)";
status = EXIT_SUCCESS;
}
- bb_printf(fmt, prefix, id, arg);
+ printf(fmt, prefix, id, arg);
return status;
}
/* bb_getpwuid and bb_getgrgid exit on failure so puts cannot segfault */
puts((flags & JUST_USER) ? bb_getpwuid(NULL, uid, -1 ) : bb_getgrgid(NULL, gid, -1 ));
} else {
- bb_printf("%u\n", (flags & JUST_USER) ? uid : gid);
+ printf("%u\n", (flags & JUST_USER) ? uid : gid);
}
/* exit */
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
/* Print full info like GNU id */
getcon(&mysid);
context[0] = '\0';
if (mysid) {
- len = strlen(mysid)+1;
- safe_strncpy(context, mysid, len);
- freecon(mysid);
+ len = strlen(mysid)+1;
+ safe_strncpy(context, mysid, len);
+ freecon(mysid);
} else {
- safe_strncpy(context, "unknown", 8);
+ safe_strncpy(context, "unknown", 8);
}
- bb_printf(" context=%s", context);
+ printf(" context=%s", context);
}
#endif
putchar('\n');
- bb_fflush_stdout_and_exit(status);
+ fflush_stdout_and_exit(status);
}
if ((p = getlogin()) != NULL) {
puts(p);
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
bb_perror_msg_and_die("getlogin");
old_priority = getpriority(PRIO_PROCESS, 0);
if (!*++argv) { /* No args, so (GNU) output current nice value. */
- bb_printf("%d\n", old_priority);
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ printf("%d\n", old_priority);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
adjustment = 10; /* Set default adjustment. */
}
}
- bb_fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(0);
}
if ((buf = xgetcwd(NULL)) != NULL) {
puts(buf);
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
return EXIT_FAILURE;
RELEASE_CONFIG_BUFFER(resolved_path);
#endif
- bb_fflush_stdout_and_exit(retval);
+ fflush_stdout_and_exit(retval);
}
/* Print it */
if(!outfile) outfile=stdout;
for(i=0;i<linecount;i++) fprintf(outfile,"%s\n",lines[i]);
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
* output files. Since we know that the first entry in the output
* file table is stdout, we can save one "if ferror" test by
* setting the first entry to stdin and checking stdout error
- * status with bb_fflush_stdout_and_exit()... although fflush()ing
+ * status with fflush_stdout_and_exit()... although fflush()ing
* is unnecessary here. */
p = files;
do { /* Now check for (input and) output errors. */
/* Checking ferror should be sufficient, but we may want to fclose.
* If we do, remember not to close stdin! */
- xferror(*p, filenames[(int)(p - files)]);
+ die_if_ferror(*p, filenames[(int)(p - files)]);
} while (*++p);
- bb_fflush_stdout_and_exit(retval);
+ fflush_stdout_and_exit(retval);
}
puts(s);
}
- bb_fflush_stdout_and_exit(retval);
+ fflush_stdout_and_exit(retval);
}
strcpy(uname_info.processor, "unknown");
- delta=utsname_offset;
+ delta = utsname_offset;
do {
if (toprint & 1) {
- bb_printf(((char *)(&uname_info)) + *delta);
+ printf(((char *)(&uname_info)) + *delta);
if (toprint > 1) {
putchar(' ');
}
} while (toprint >>= 1);
putchar('\n');
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
while ((opt = getopt(argc, argv, uniq_opts)) > 0) {
if ((opt == 'f') || (opt == 's')) {
- int t = xatoul(optarg);
+ unsigned long t = xatoul(optarg);
if (opt == 'f') {
skip_fields = t;
} else {
/* gnu uniq ignores newlines */
while ((s1 = xmalloc_getline(in)) != NULL) {
e1 = s1;
- for (i=skip_fields ; i ; i--) {
+ for (i = skip_fields; i; i--) {
e1 = skip_whitespace(e1);
while (*e1 && !isspace(*e1)) {
++e1;
}
}
- for (i = skip_chars ; *e1 && i ; i--) {
+ for (i = skip_chars; *e1 && i; i--) {
++e1;
}
if (s0) {
if (!(uniq_flags & (2 << !!dups))) {
- bb_fprintf(out, "\0%d " + (uniq_flags & 1), dups + 1);
- bb_fprintf(out, "%s\n", s0);
+ fprintf(out, "\0%d " + (uniq_flags & 1), dups + 1);
+ fprintf(out, "%s\n", s0);
}
free((void *)s0);
}
} while (s1);
- xferror(in, input_filename);
+ die_if_ferror(in, input_filename);
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
bb_show_usage();
}
- bb_printf("begin%s %o %s", tbl == bb_uuenc_tbl_std ? "" : "-base64", mode, argv[argc - 1]);
+ printf("begin%s %o %s", tbl == bb_uuenc_tbl_std ? "" : "-base64", mode, argv[argc - 1]);
while ((size = fread(src_buf, 1, src_buf_size, src_stream)) > 0) {
if (size != src_buf_size) {
/* write_size is always 60 until the last line */
- write_size=(4 * ((size + 2) / 3));
+ write_size = (4 * ((size + 2) / 3));
/* pad with 0s so we can just encode extra bits */
memset(&src_buf[size], 0, src_buf_size - size);
}
bb_perror_msg_and_die(bb_msg_write_error);
}
}
- bb_printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n");
+ printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n");
- xferror(src_stream, "source"); /* TODO - Fix this! */
+ die_if_ferror(src_stream, "source"); /* TODO - Fix this! */
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
u = 0;
do {
if (print_type & (1 << u)) {
- bb_printf(s, pcounts[u]);
+ printf(s, pcounts[u]);
s = " %9"COUNT_FMT; /* Ok... restore the leading space. */
}
totals[u] += pcounts[u];
} while (++u < 4);
- bb_printf(fname_fmt, arg);
+ printf(fname_fmt, arg);
}
/* If more than one file was processed, we want the totals. To save some
goto OUTPUT;
}
- bb_fflush_stdout_and_exit(status);
+ fflush_stdout_and_exit(status);
}
puts(bb_getpwuid(NULL, geteuid(), -1));
/* exits on error */
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
* Size reductions and removed redundant applet name prefix from error messages.
*/
-#include <stdio.h>
-#include <stdlib.h>
#include "busybox.h"
int yes_main(int argc, char **argv)
do {
fmt = fmt_str + 1;
do {
- bb_printf(fmt, *argv);
+ printf(fmt, *argv);
fmt = fmt_str;
} while (*++argv);
argv = first_arg;
if (ENABLE_FEATURE_CLEAN_UP && buf != bb_common_bufsiz1)
free(buf);
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
status = EXIT_FAILURE;
}
- bb_fflush_stdout_and_exit(status);
+ fflush_stdout_and_exit(status);
}
if (retval) {
va_start(ap, fmt);
- bb_fprintf(stderr,"\nCould not ");
- bb_vfprintf(stderr, fmt, ap);
- bb_fprintf(stderr, "\n");
+ fprintf(stderr,"\nCould not ");
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
va_end(ap);
exit(EXIT_FAILURE);
}
if (!quiet) {
va_start(ap, fmt);
- bb_vfprintf(stdout, fmt, ap);
+ vfprintf(stdout, fmt, ap);
fflush(stdout);
va_end(ap);
}
if (retval) {
va_start(ap, fmt);
- bb_fprintf(stderr,"\nWarning: ");
- bb_vfprintf(stderr, fmt, ap);
- bb_fprintf(stderr, "\n");
+ fprintf(stderr,"\nWarning: ");
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
va_end(ap);
}
}
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
void* userData);
-extern int bb_parse_mode( const char* s, mode_t* theMode);
+extern int bb_parse_mode(const char* s, mode_t* theMode);
extern unsigned int tty_baud_to_value(speed_t speed);
extern speed_t tty_value_to_baud(unsigned int value);
extern FILE *xfopen(const char *path, const char *mode);
extern int bb_fclose_nonstdin(FILE *f);
-extern void bb_fflush_stdout_and_exit(int retval) ATTRIBUTE_NORETURN;
+extern void fflush_stdout_and_exit(int retval) ATTRIBUTE_NORETURN;
extern void xstat(char *filename, struct stat *buf);
extern int xsocket(int domain, int type, int protocol);
extern uint32_t option_mask32;
extern uint32_t getopt32(int argc, char **argv, const char *applet_opts, ...);
-extern int bb_vfprintf(FILE * __restrict stream, const char * __restrict format,
- va_list arg) __attribute__ ((format (printf, 2, 0)));
-extern int bb_vprintf(const char * __restrict format, va_list arg)
- __attribute__ ((format (printf, 1, 0)));
-extern int bb_fprintf(FILE * __restrict stream, const char * __restrict format, ...)
- __attribute__ ((format (printf, 2, 3)));
-extern int bb_printf(const char * __restrict format, ...)
- __attribute__ ((format (printf, 1, 2)));
-
-extern void xferror(FILE *fp, const char *fn);
-extern void xferror_stdout(void);
+extern void die_if_ferror(FILE *fp, const char *fn);
+extern void die_if_ferror_stdout(void);
extern void xfflush_stdout(void);
extern void bb_warn_ignoring_args(int n);
lib-y += messages.o
lib-y += xfuncs.o
-lib-y += printf.o
lib-y += xatol.o
lib-y += safe_strtol.o
lib-y += bb_pwd.o
* in an error state.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <libbb.h>
+#include "libbb.h"
-void bb_fflush_stdout_and_exit(int retval)
+void fflush_stdout_and_exit(int retval)
{
if (fflush(stdout)) {
retval = xfunc_error_retval;
while (my_b) { dosomething_with(my_b->data); my_b = my_b->link; }
if (my_b) // but llist is stored if -b is specified
free_llist(my_b);
- if (verbose_level) bb_printf("verbose level is %d\n", verbose_level);
+ if (verbose_level) printf("verbose level is %d\n", verbose_level);
Special characters:
}
// Die with supplied error message if this FILE * has ferror set.
-void xferror(FILE *fp, const char *fn)
+void die_if_ferror(FILE *fp, const char *fn)
{
if (ferror(fp)) {
bb_error_msg_and_die("%s", fn);
}
// Die with an error message if stdout has ferror set.
-void xferror_stdout(void)
+void die_if_ferror_stdout(void)
{
- xferror(stdout, bb_msg_standard_output);
+ die_if_ferror(stdout, bb_msg_standard_output);
}
// Die with an error message if we have trouble flushing stdout.
}
}
}
- bb_fflush_stdout_and_exit(EXIT_SUCCESS); /* not reached */
+ return 0; /* not reached */
}
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);
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)
int n2 = -1;
if (base == NULL) {
- return (NULL);
+ return NULL;
}
while (*ptr != ' ' && *ptr != '\t' && *ptr != '\n') {
if (skip == 0) {
crondlog("\111failed user %s parsing %s\n", user, base);
- return (NULL);
+ return NULL;
}
if (*ptr == '-' && n2 < 0) {
++ptr;
if (failsafe == 0) {
crondlog("\111failed user %s parsing %s\n", user, base);
- return (NULL);
+ return NULL;
}
}
if (*ptr != ',') {
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') {
}
#endif
- return (ptr);
+ return ptr;
}
static void FixDayDow(CronLine * line)
}
}
}
- return (nJobs);
+ return nJobs;
}
static void RunJobs(void)
}
nStillRunning += file->cf_Running;
}
- return (nStillRunning);
+ return nStillRunning;
}
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 */
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);
ctime(&t_tmp) + 4);
}
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
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)
/* 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;
}
}
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);
}
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) {
}
}
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);
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);
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;
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;
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)
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;
}
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);
}
if (ENABLE_FEATURE_CLEAN_UP)
free(string);
- bb_fflush_stdout_and_exit(status);
+ fflush_stdout_and_exit(status);
}
FILE *fp = xfopen("/proc/net/route", "r");
- bb_printf("Kernel IP routing table\n"
+ printf("Kernel IP routing table\n"
"Destination Gateway Genmask"
" Flags %s Iface\n",
netstatfmt ? " MSS Window irtt" : "Metric Ref Use");
(noresolve | 0x4000), m); /* Host instead of net. */
mask.s_addr = m;
- bb_printf("%-16s%-16s%-16s%-6s", sdest, sgw, inet_ntoa(mask), flags);
+ printf("%-16s%-16s%-16s%-6s", sdest, sgw, inet_ntoa(mask), flags);
if (netstatfmt) {
- bb_printf("%5d %-5d %6d %s\n", mtu, win, ir, devname);
+ printf("%5d %-5d %6d %s\n", mtu, win, ir, devname);
} else {
- bb_printf("%-6d %-2d %7d %s\n", metric, ref, use, devname);
+ printf("%-6d %-2d %7d %s\n", metric, ref, use, devname);
}
}
}
FILE *fp = xfopen("/proc/net/ipv6_route", "r");
- bb_printf("Kernel IPv6 routing table\n%-44s%-40s"
+ printf("Kernel IPv6 routing table\n%-44s%-40s"
"Flags Metric Ref Use Iface\n",
"Destination", "Next Hop");
r += 40;
} else { /* 2nd pass */
/* Print the info. */
- bb_printf("%-43s %-39s %-5s %-6d %-2d %7d %-8s\n",
+ printf("%-43s %-39s %-5s %-6d %-2d %7d %-8s\n",
addr6, naddr6, flags, metric, refcnt, use, iface);
break;
}
unsigned opt;
int what;
char *family;
+ char **p;
/* First, remap '-net' and '-host' to avoid getopt problems. */
- {
- char **p = argv;
-
- while (*++p) {
- if ((strcmp(*p, "-net") == 0) || (strcmp(*p, "-host") == 0)) {
- p[0][0] = '#';
- }
+ p = argv;
+ while (*++p) {
+ if ((strcmp(*p, "-net") == 0) || (strcmp(*p, "-host") == 0)) {
+ p[0][0] = '#';
}
}
#endif
displayroutes(noresolve, opt & ROUTE_OPT_e);
- xferror_stdout();
- bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
/* Check verb. At the moment, must be add, del, or delete. */
what = SEM;
if (remove_ids(what, argc-2, &argv[2]))
- bb_fflush_stdout_and_exit(1);
- bb_printf("resource(s) deleted\n");
+ fflush_stdout_and_exit(1);
+ printf("resource(s) deleted\n");
return 0;
}
}
struct passwd *pw;
struct group *gr;
- bb_printf("%-10d %-10o", id, ipcp->mode & 0777);
+ printf("%-10d %-10o", id, ipcp->mode & 0777);
if ((pw = getpwuid(ipcp->cuid)))
- bb_printf(" %-10s", pw->pw_name);
+ printf(" %-10s", pw->pw_name);
else
- bb_printf(" %-10d", ipcp->cuid);
+ printf(" %-10d", ipcp->cuid);
if ((gr = getgrgid(ipcp->cgid)))
- bb_printf(" %-10s", gr->gr_name);
+ printf(" %-10s", gr->gr_name);
else
- bb_printf(" %-10d", ipcp->cgid);
+ printf(" %-10d", ipcp->cgid);
if ((pw = getpwuid(ipcp->uid)))
- bb_printf(" %-10s", pw->pw_name);
+ printf(" %-10s", pw->pw_name);
else
- bb_printf(" %-10d", ipcp->uid);
+ printf(" %-10d", ipcp->uid);
if ((gr = getgrgid(ipcp->gid)))
- bb_printf(" %-10s\n", gr->gr_name);
+ printf(" %-10s\n", gr->gr_name);
else
- bb_printf(" %-10d\n", ipcp->gid);
+ printf(" %-10d\n", ipcp->gid);
}
maxid = shmctl(0, SHM_INFO, (struct shmid_ds *) (void *) &shm_info);
if (maxid < 0) {
- bb_printf("kernel not configured for %s\n", "shared memory");
+ printf("kernel not configured for %s\n", "shared memory");
return;
}
switch (format) {
case LIMITS:
- bb_printf("------ Shared Memory %s --------\n", "Limits");
+ printf("------ Shared Memory %s --------\n", "Limits");
if ((shmctl(0, IPC_INFO, (struct shmid_ds *) (void *) &shminfo)) < 0)
return;
/* glibc 2.1.3 and all earlier libc's have ints as fields
of struct shminfo; glibc 2.1.91 has unsigned long; ach */
- bb_printf("max number of segments = %lu\n"
+ printf("max number of segments = %lu\n"
"max seg size (kbytes) = %lu\n"
"max total shared memory (pages) = %lu\n"
"min seg size (bytes) = %lu\n",
return;
case STATUS:
- bb_printf("------ Shared Memory %s --------\n", "Status");
- bb_printf( "segments allocated %d\n"
+ printf("------ Shared Memory %s --------\n", "Status");
+ printf( "segments allocated %d\n"
"pages allocated %ld\n"
"pages resident %ld\n"
"pages swapped %ld\n"
return;
case CREATOR:
- bb_printf("------ Shared Memory %s --------\n", "Segment Creators/Owners");
- bb_printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n",
+ printf("------ Shared Memory %s --------\n", "Segment Creators/Owners");
+ printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n",
"shmid", "perms", "cuid", "cgid", "uid", "gid");
break;
case TIME:
- bb_printf("------ Shared Memory %s --------\n", "Attach/Detach/Change Times");
- bb_printf( "%-10s %-10s %-20s %-20s %-20s\n",
+ printf("------ Shared Memory %s --------\n", "Attach/Detach/Change Times");
+ printf( "%-10s %-10s %-20s %-20s %-20s\n",
"shmid", "owner", "attached", "detached", "changed");
break;
case PID:
- bb_printf("------ Shared Memory %s --------\n", "Creator/Last-op");
- bb_printf( "%-10s %-10s %-10s %-10s\n",
+ printf("------ Shared Memory %s --------\n", "Creator/Last-op");
+ printf( "%-10s %-10s %-10s %-10s\n",
"shmid", "owner", "cpid", "lpid");
break;
default:
- bb_printf("------ Shared Memory %s --------\n", "Segments");
- bb_printf( "%-10s %-10s %-10s %-10s %-10s %-10s %-12s\n",
+ printf("------ Shared Memory %s --------\n", "Segments");
+ printf( "%-10s %-10s %-10s %-10s %-10s %-10s %-12s\n",
"key", "shmid", "owner", "perms", "bytes", "nattch",
"status");
break;
switch (format) {
case TIME:
if (pw)
- bb_printf("%-10d %-10.10s", shmid, pw->pw_name);
+ printf("%-10d %-10.10s", shmid, pw->pw_name);
else
- bb_printf("%-10d %-10d", shmid, ipcp->uid);
+ printf("%-10d %-10d", shmid, ipcp->uid);
/* ctime uses static buffer: use separate calls */
- bb_printf(" %-20.16s", shmseg.shm_atime
+ printf(" %-20.16s", shmseg.shm_atime
? ctime(&shmseg.shm_atime) + 4 : "Not set");
- bb_printf(" %-20.16s", shmseg.shm_dtime
+ printf(" %-20.16s", shmseg.shm_dtime
? ctime(&shmseg.shm_dtime) + 4 : "Not set");
- bb_printf(" %-20.16s\n", shmseg.shm_ctime
+ printf(" %-20.16s\n", shmseg.shm_ctime
? ctime(&shmseg.shm_ctime) + 4 : "Not set");
break;
case PID:
if (pw)
- bb_printf("%-10d %-10.10s", shmid, pw->pw_name);
+ printf("%-10d %-10.10s", shmid, pw->pw_name);
else
- bb_printf("%-10d %-10d", shmid, ipcp->uid);
- bb_printf(" %-10d %-10d\n", shmseg.shm_cpid, shmseg.shm_lpid);
+ printf("%-10d %-10d", shmid, ipcp->uid);
+ printf(" %-10d %-10d\n", shmseg.shm_cpid, shmseg.shm_lpid);
break;
default:
- bb_printf("0x%08x ", ipcp->KEY);
+ printf("0x%08x ", ipcp->KEY);
if (pw)
- bb_printf("%-10d %-10.10s", shmid, pw->pw_name);
+ printf("%-10d %-10.10s", shmid, pw->pw_name);
else
- bb_printf("%-10d %-10d", shmid, ipcp->uid);
- bb_printf(" %-10o %-10lu %-10ld %-6s %-6s\n", ipcp->mode & 0777,
+ printf("%-10d %-10d", shmid, ipcp->uid);
+ printf(" %-10o %-10lu %-10ld %-6s %-6s\n", ipcp->mode & 0777,
/*
* earlier: int, Austin has size_t
*/
arg.array = (ushort *) (void *) &seminfo;
maxid = semctl(0, 0, SEM_INFO, arg);
if (maxid < 0) {
- bb_printf("kernel not configured for %s\n", "semaphores");
+ printf("kernel not configured for %s\n", "semaphores");
return;
}
switch (format) {
case LIMITS:
- bb_printf("------ Semaphore %s --------\n", "Limits");
+ printf("------ Semaphore %s --------\n", "Limits");
arg.array = (ushort *) (void *) &seminfo; /* damn union */
if ((semctl(0, 0, IPC_INFO, arg)) < 0)
return;
- bb_printf("max number of arrays = %d\n"
+ printf("max number of arrays = %d\n"
"max semaphores per array = %d\n"
"max semaphores system wide = %d\n"
"max ops per semop call = %d\n"
return;
case STATUS:
- bb_printf("------ Semaphore %s --------\n", "Status");
- bb_printf( "used arrays = %d\n"
+ printf("------ Semaphore %s --------\n", "Status");
+ printf( "used arrays = %d\n"
"allocated semaphores = %d\n",
seminfo.semusz, seminfo.semaem);
return;
case CREATOR:
- bb_printf("------ Semaphore %s --------\n", "Arrays Creators/Owners");
- bb_printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n",
+ printf("------ Semaphore %s --------\n", "Arrays Creators/Owners");
+ printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n",
"semid", "perms", "cuid", "cgid", "uid", "gid");
break;
case TIME:
- bb_printf("------ Shared Memory %s --------\n", "Operation/Change Times");
- bb_printf( "%-8s %-10s %-26.24s %-26.24s\n",
+ printf("------ Shared Memory %s --------\n", "Operation/Change Times");
+ printf( "%-8s %-10s %-26.24s %-26.24s\n",
"shmid", "owner", "last-op", "last-changed");
break;
break;
default:
- bb_printf("------ Semaphore %s --------\n", "Arrays");
- bb_printf( "%-10s %-10s %-10s %-10s %-10s\n",
+ printf("------ Semaphore %s --------\n", "Arrays");
+ printf( "%-10s %-10s %-10s %-10s %-10s\n",
"key", "semid", "owner", "perms", "nsems");
break;
}
switch (format) {
case TIME:
if (pw)
- bb_printf("%-8d %-10.10s", semid, pw->pw_name);
+ printf("%-8d %-10.10s", semid, pw->pw_name);
else
- bb_printf("%-8d %-10d", semid, ipcp->uid);
+ printf("%-8d %-10d", semid, ipcp->uid);
/* ctime uses static buffer: use separate calls */
- bb_printf(" %-26.24s", semary.sem_otime
+ printf(" %-26.24s", semary.sem_otime
? ctime(&semary.sem_otime) : "Not set");
- bb_printf(" %-26.24s\n", semary.sem_ctime
+ printf(" %-26.24s\n", semary.sem_ctime
? ctime(&semary.sem_ctime) : "Not set");
break;
case PID:
break;
default:
- bb_printf("0x%08x ", ipcp->KEY);
+ printf("0x%08x ", ipcp->KEY);
if (pw)
- bb_printf("%-10d %-10.9s", semid, pw->pw_name);
+ printf("%-10d %-10.9s", semid, pw->pw_name);
else
- bb_printf("%-10d %-9d", semid, ipcp->uid);
- bb_printf(" %-10o %-10ld\n", ipcp->mode & 0777,
+ printf("%-10d %-9d", semid, ipcp->uid);
+ printf(" %-10o %-10ld\n", ipcp->mode & 0777,
/*
* glibc-2.1.3 and earlier has unsigned short;
* glibc-2.1.91 has variation between
maxid = msgctl(0, MSG_INFO, (struct msqid_ds *) (void *) &msginfo);
if (maxid < 0) {
- bb_printf("kernel not configured for %s\n", "message queues");
+ printf("kernel not configured for %s\n", "message queues");
return;
}
case LIMITS:
if ((msgctl(0, IPC_INFO, (struct msqid_ds *) (void *) &msginfo)) < 0)
return;
- bb_printf("------ Message%s --------\n", "s: Limits");
- bb_printf( "max queues system wide = %d\n"
+ printf("------ Message%s --------\n", "s: Limits");
+ printf( "max queues system wide = %d\n"
"max size of message (bytes) = %d\n"
"default max size of queue (bytes) = %d\n",
msginfo.msgmni, msginfo.msgmax, msginfo.msgmnb);
return;
case STATUS:
- bb_printf("------ Message%s --------\n", "s: Status");
- bb_printf( "allocated queues = %d\n"
+ printf("------ Message%s --------\n", "s: Status");
+ printf( "allocated queues = %d\n"
"used headers = %d\n"
"used space = %d bytes\n",
msginfo.msgpool, msginfo.msgmap, msginfo.msgtql);
return;
case CREATOR:
- bb_printf("------ Message%s --------\n", " Queues: Creators/Owners");
- bb_printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n",
+ printf("------ Message%s --------\n", " Queues: Creators/Owners");
+ printf( "%-10s %-10s %-10s %-10s %-10s %-10s\n",
"msqid", "perms", "cuid", "cgid", "uid", "gid");
break;
case TIME:
- bb_printf("------ Message%s --------\n", " Queues Send/Recv/Change Times");
- bb_printf( "%-8s %-10s %-20s %-20s %-20s\n",
+ printf("------ Message%s --------\n", " Queues Send/Recv/Change Times");
+ printf( "%-8s %-10s %-20s %-20s %-20s\n",
"msqid", "owner", "send", "recv", "change");
break;
case PID:
- bb_printf("------ Message%s --------\n", " Queues PIDs");
- bb_printf( "%-10s %-10s %-10s %-10s\n",
+ printf("------ Message%s --------\n", " Queues PIDs");
+ printf( "%-10s %-10s %-10s %-10s\n",
"msqid", "owner", "lspid", "lrpid");
break;
default:
- bb_printf("------ Message%s --------\n", " Queues");
- bb_printf( "%-10s %-10s %-10s %-10s %-12s %-12s\n",
+ printf("------ Message%s --------\n", " Queues");
+ printf( "%-10s %-10s %-10s %-10s %-12s %-12s\n",
"key", "msqid", "owner", "perms", "used-bytes", "messages");
break;
}
switch (format) {
case TIME:
if (pw)
- bb_printf("%-8d %-10.10s", msqid, pw->pw_name);
+ printf("%-8d %-10.10s", msqid, pw->pw_name);
else
- bb_printf("%-8d %-10d", msqid, ipcp->uid);
- bb_printf(" %-20.16s", msgque.msg_stime
+ printf("%-8d %-10d", msqid, ipcp->uid);
+ printf(" %-20.16s", msgque.msg_stime
? ctime(&msgque.msg_stime) + 4 : "Not set");
- bb_printf(" %-20.16s", msgque.msg_rtime
+ printf(" %-20.16s", msgque.msg_rtime
? ctime(&msgque.msg_rtime) + 4 : "Not set");
- bb_printf(" %-20.16s\n", msgque.msg_ctime
+ printf(" %-20.16s\n", msgque.msg_ctime
? ctime(&msgque.msg_ctime) + 4 : "Not set");
break;
case PID:
if (pw)
- bb_printf("%-8d %-10.10s", msqid, pw->pw_name);
+ printf("%-8d %-10.10s", msqid, pw->pw_name);
else
- bb_printf("%-8d %-10d", msqid, ipcp->uid);
- bb_printf(" %5d %5d\n", msgque.msg_lspid, msgque.msg_lrpid);
+ printf("%-8d %-10d", msqid, ipcp->uid);
+ printf(" %5d %5d\n", msgque.msg_lspid, msgque.msg_lrpid);
break;
default:
- bb_printf("0x%08x ", ipcp->KEY);
+ printf("0x%08x ", ipcp->KEY);
if (pw)
- bb_printf("%-10d %-10.10s", msqid, pw->pw_name);
+ printf("%-10d %-10.10s", msqid, pw->pw_name);
else
- bb_printf("%-10d %-10d", msqid, ipcp->uid);
- bb_printf(" %-10o %-12ld %-12ld\n", ipcp->mode & 0777,
+ printf("%-10d %-10d", msqid, ipcp->uid);
+ printf(" %-10o %-12ld %-12ld\n", ipcp->mode & 0777,
/*
* glibc-2.1.3 and earlier has unsigned short;
* glibc-2.1.91 has variation between
return;
}
- bb_printf("\nShared memory Segment shmid=%d\n"
+ printf("\nShared memory Segment shmid=%d\n"
"uid=%d\tgid=%d\tcuid=%d\tcgid=%d\n"
"mode=%#o\taccess_perms=%#o\n"
"bytes=%ld\tlpid=%d\tcpid=%d\tnattch=%ld\n",
ipcp->mode, ipcp->mode & 0777,
(long) shmds.shm_segsz, shmds.shm_lpid, shmds.shm_cpid,
(long) shmds.shm_nattch);
- bb_printf("att_time=%-26.24s\n",
+ printf("att_time=%-26.24s\n",
shmds.shm_atime ? ctime(&shmds.shm_atime) : "Not set");
- bb_printf("det_time=%-26.24s\n",
+ printf("det_time=%-26.24s\n",
shmds.shm_dtime ? ctime(&shmds.shm_dtime) : "Not set");
- bb_printf("change_time=%-26.24s\n\n", ctime(&shmds.shm_ctime));
+ printf("change_time=%-26.24s\n\n", ctime(&shmds.shm_ctime));
}
return;
}
- bb_printf("\nMessage Queue msqid=%d\n"
+ printf("\nMessage Queue msqid=%d\n"
"uid=%d\tgid=%d\tcuid=%d\tcgid=%d\tmode=%#o\n"
"cbytes=%ld\tqbytes=%ld\tqnum=%ld\tlspid=%d\tlrpid=%d\n",
msqid, ipcp->uid, ipcp->gid, ipcp->cuid, ipcp->cgid, ipcp->mode,
(long) buf.msg_cbytes, (long) buf.msg_qbytes,
(long) buf.msg_qnum, buf.msg_lspid, buf.msg_lrpid);
- bb_printf("send_time=%-26.24s\n",
+ printf("send_time=%-26.24s\n",
buf.msg_stime ? ctime(&buf.msg_stime) : "Not set");
- bb_printf("rcv_time=%-26.24s\n",
+ printf("rcv_time=%-26.24s\n",
buf.msg_rtime ? ctime(&buf.msg_rtime) : "Not set");
- bb_printf("change_time=%-26.24s\n\n",
+ printf("change_time=%-26.24s\n\n",
buf.msg_ctime ? ctime(&buf.msg_ctime) : "Not set");
}
return;
}
- bb_printf("\nSemaphore Array semid=%d\n"
+ printf("\nSemaphore Array semid=%d\n"
"uid=%d\t gid=%d\t cuid=%d\t cgid=%d\n"
"mode=%#o, access_perms=%#o\n"
"nsems = %ld\n"
ipcp->mode, ipcp->mode & 0777,
(long) semds.sem_nsems,
semds.sem_otime ? ctime(&semds.sem_otime) : "Not set");
- bb_printf("ctime = %-26.24s\n"
+ printf("ctime = %-26.24s\n"
"%-10s %-10s %-10s %-10s %-10s\n",
ctime(&semds.sem_ctime),
"semnum", "value", "ncount", "zcount", "pid");
if (val < 0 || ncnt < 0 || zcnt < 0 || pid < 0) {
bb_perror_msg_and_die("semctl");
}
- bb_printf("%-10d %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid);
+ printf("%-10d %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid);
}
- bb_printf("\n");
+ puts("");
}
int ipcs_main(int argc, char **argv)
if (flags & flag_print) {
if (flags & flag_shm) {
print_shm(id);
- bb_fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(0);
}
if (flags & flag_sem) {
print_sem(id);
- bb_fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(0);
}
if (flags & flag_msg) {
print_msg(id);
- bb_fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(0);
}
bb_show_usage();
}
if (!(flags & (flag_shm | flag_msg | flag_sem)))
flags |= flag_msg | flag_shm | flag_sem;
- bb_printf("\n");
+ puts("");
if (flags & flag_shm) {
do_shm();
- bb_printf("\n");
+ puts("");
}
if (flags & flag_sem) {
do_sem();
- bb_printf("\n");
+ puts("");
}
if (flags & flag_msg) {
do_msg();
- bb_printf("\n");
+ puts("");
}
- return EXIT_SUCCESS;
+ fflush_stdout_and_exit(0);
}