Vladimir N. Oleynik.
static void clean_up_and_die(int sig)
{
cmdedit_reset_term();
- fprintf(stdout, "\n");
+ printf("\n");
if (sig!=SIGINT)
exit(EXIT_SUCCESS);
}
static void print_normal(long size, char *filename)
{
- fprintf(stdout, "%ld\t%s\n", size, filename);
+ printf("%ld\t%s\n", size, filename);
}
static void print_summary(long size, char *filename)
return status;
}
-/* $Id: du.c,v 1.32 2000/12/12 23:17:26 andersen Exp $ */
+/* $Id: du.c,v 1.33 2001/01/18 02:57:08 kraai Exp $ */
/*
Local Variables:
c-file-style: "linux"
}
if (fp) {
if (need_headers) {
- fprintf(stdout, "==> %s <==\n", argv[optind]);
+ printf("==> %s <==\n", argv[optind]);
}
head(len, fp);
if (errno) {
errno = 0;
}
if (optind < argc - 1)
- fprintf(stdout, "\n");
+ putchar('\n');
if (fp != stdin)
fclose(fp);
}
static void newline(void)
{
if (column > 0) {
- fprintf(stdout, "\n");
+ putchar('\n');
column = 0;
}
}
n= nexttab - column;
if (n < 1) n= 1;
while (n--) {
- fprintf(stdout, " ");
+ putchar(' ');
column++;
}
}
for (i=0; i<ndirs; i++) {
if (disp_opts & (DISP_DIRNAME | DISP_RECURSIVE)) {
- fprintf(stdout, "\n%s:\n", dn[i]->fullname);
+ printf("\n%s:\n", dn[i]->fullname);
}
subdnp= list_dir(dn[i]->fullname);
nfiles= countfiles(subdnp);
for (i=0; i<=31; i++) {
switch (list_fmt & (1<<i)) {
case LIST_INO:
- fprintf(stdout, "%7ld ", dn->dstat.st_ino);
+ printf("%7ld ", dn->dstat.st_ino);
column += 8;
break;
case LIST_BLOCKS:
#if _FILE_OFFSET_BITS == 64
- fprintf(stdout, "%4lld ", dn->dstat.st_blocks>>1);
+ printf("%4lld ", dn->dstat.st_blocks>>1);
#else
- fprintf(stdout, "%4ld ", dn->dstat.st_blocks>>1);
+ printf("%4ld ", dn->dstat.st_blocks>>1);
#endif
column += 5;
break;
case LIST_MODEBITS:
- fprintf(stdout, "%10s", (char *)mode_string(dn->dstat.st_mode));
+ printf("%10s", (char *)mode_string(dn->dstat.st_mode));
column += 10;
break;
case LIST_NLINKS:
- fprintf(stdout, "%4d ", dn->dstat.st_nlink);
+ printf("%4d ", dn->dstat.st_nlink);
column += 10;
break;
case LIST_ID_NAME:
#ifdef BB_FEATURE_LS_USERNAME
my_getpwuid(scratch, dn->dstat.st_uid);
if (*scratch)
- fprintf(stdout, "%-8.8s ", scratch);
+ printf("%-8.8s ", scratch);
else
- fprintf(stdout, "%-8d ", dn->dstat.st_uid);
+ printf("%-8d ", dn->dstat.st_uid);
my_getgrgid(scratch, dn->dstat.st_gid);
if (*scratch)
- fprintf(stdout, "%-8.8s", scratch);
+ printf("%-8.8s", scratch);
else
- fprintf(stdout, "%-8d", dn->dstat.st_gid);
+ printf("%-8d", dn->dstat.st_gid);
column += 17;
break;
#endif
case LIST_ID_NUMERIC:
- fprintf(stdout, "%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
+ printf("%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
column += 17;
break;
case LIST_SIZE:
case LIST_DEV:
if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
- fprintf(stdout, "%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
+ printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
} else {
#if _FILE_OFFSET_BITS == 64
- fprintf(stdout, "%9lld ", dn->dstat.st_size);
+ printf("%9lld ", dn->dstat.st_size);
#else
- fprintf(stdout, "%9ld ", dn->dstat.st_size);
+ printf("%9ld ", dn->dstat.st_size);
#endif
}
column += 10;
case LIST_FULLTIME:
case LIST_DATE_TIME:
if (list_fmt & LIST_FULLTIME) {
- fprintf(stdout, "%24.24s ", filetime);
+ printf("%24.24s ", filetime);
column += 25;
break;
}
age = time(NULL) - ttime;
- fprintf(stdout, "%6.6s ", filetime+4);
+ printf("%6.6s ", filetime+4);
if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
/* hh:mm if less than 6 months old */
- fprintf(stdout, "%5.5s ", filetime+11);
+ printf("%5.5s ", filetime+11);
} else {
- fprintf(stdout, " %4.4s ", filetime+20);
+ printf(" %4.4s ", filetime+20);
}
column += 13;
break;
#endif
case LIST_FILENAME:
- fprintf(stdout, "%s", dn->name);
+ printf("%s", dn->name);
column += strlen(dn->name);
break;
case LIST_SYMLINK:
len= readlink(dn->fullname, scratch, (sizeof scratch)-1);
if (len > 0) {
scratch[len]= '\0';
- fprintf(stdout, " -> %s", scratch);
+ printf(" -> %s", scratch);
#ifdef BB_FEATURE_LS_FILETYPES
if (!stat(dn->fullname, &info)) {
append = append_char(info.st_mode);
#ifdef BB_FEATURE_LS_FILETYPES
case LIST_FILETYPE:
if (append != '\0') {
- fprintf(stdout, "%1c", append);
+ printf("%1c", append);
column++;
}
break;
static void print_normal(long size, char *filename)
{
- fprintf(stdout, "%ld\t%s\n", size, filename);
+ printf("%ld\t%s\n", size, filename);
}
static void print_summary(long size, char *filename)
return status;
}
-/* $Id: du.c,v 1.32 2000/12/12 23:17:26 andersen Exp $ */
+/* $Id: du.c,v 1.33 2001/01/18 02:57:08 kraai Exp $ */
/*
Local Variables:
c-file-style: "linux"
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (pattern == NULL)
- fprintf(stdout, "%s\n", fileName);
+ puts(fileName);
else {
char *tmp = strrchr(fileName, '/');
else
tmp++;
if (check_wildcard_match(tmp, pattern) == TRUE)
- fprintf(stdout, "%s\n", fileName);
+ puts(fileName);
}
return (TRUE);
}
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (pattern == NULL)
- fprintf(stdout, "%s\n", fileName);
+ puts(fileName);
else {
char *tmp = strrchr(fileName, '/');
else
tmp++;
if (check_wildcard_match(tmp, pattern) == TRUE)
- fprintf(stdout, "%s\n", fileName);
+ puts(fileName);
}
return (TRUE);
}
}
if (fp) {
if (need_headers) {
- fprintf(stdout, "==> %s <==\n", argv[optind]);
+ printf("==> %s <==\n", argv[optind]);
}
head(len, fp);
if (errno) {
errno = 0;
}
if (optind < argc - 1)
- fprintf(stdout, "\n");
+ putchar('\n');
if (fp != stdin)
fclose(fp);
}
static void newline(void)
{
if (column > 0) {
- fprintf(stdout, "\n");
+ putchar('\n');
column = 0;
}
}
n= nexttab - column;
if (n < 1) n= 1;
while (n--) {
- fprintf(stdout, " ");
+ putchar(' ');
column++;
}
}
for (i=0; i<ndirs; i++) {
if (disp_opts & (DISP_DIRNAME | DISP_RECURSIVE)) {
- fprintf(stdout, "\n%s:\n", dn[i]->fullname);
+ printf("\n%s:\n", dn[i]->fullname);
}
subdnp= list_dir(dn[i]->fullname);
nfiles= countfiles(subdnp);
for (i=0; i<=31; i++) {
switch (list_fmt & (1<<i)) {
case LIST_INO:
- fprintf(stdout, "%7ld ", dn->dstat.st_ino);
+ printf("%7ld ", dn->dstat.st_ino);
column += 8;
break;
case LIST_BLOCKS:
#if _FILE_OFFSET_BITS == 64
- fprintf(stdout, "%4lld ", dn->dstat.st_blocks>>1);
+ printf("%4lld ", dn->dstat.st_blocks>>1);
#else
- fprintf(stdout, "%4ld ", dn->dstat.st_blocks>>1);
+ printf("%4ld ", dn->dstat.st_blocks>>1);
#endif
column += 5;
break;
case LIST_MODEBITS:
- fprintf(stdout, "%10s", (char *)mode_string(dn->dstat.st_mode));
+ printf("%10s", (char *)mode_string(dn->dstat.st_mode));
column += 10;
break;
case LIST_NLINKS:
- fprintf(stdout, "%4d ", dn->dstat.st_nlink);
+ printf("%4d ", dn->dstat.st_nlink);
column += 10;
break;
case LIST_ID_NAME:
#ifdef BB_FEATURE_LS_USERNAME
my_getpwuid(scratch, dn->dstat.st_uid);
if (*scratch)
- fprintf(stdout, "%-8.8s ", scratch);
+ printf("%-8.8s ", scratch);
else
- fprintf(stdout, "%-8d ", dn->dstat.st_uid);
+ printf("%-8d ", dn->dstat.st_uid);
my_getgrgid(scratch, dn->dstat.st_gid);
if (*scratch)
- fprintf(stdout, "%-8.8s", scratch);
+ printf("%-8.8s", scratch);
else
- fprintf(stdout, "%-8d", dn->dstat.st_gid);
+ printf("%-8d", dn->dstat.st_gid);
column += 17;
break;
#endif
case LIST_ID_NUMERIC:
- fprintf(stdout, "%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
+ printf("%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
column += 17;
break;
case LIST_SIZE:
case LIST_DEV:
if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
- fprintf(stdout, "%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
+ printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
} else {
#if _FILE_OFFSET_BITS == 64
- fprintf(stdout, "%9lld ", dn->dstat.st_size);
+ printf("%9lld ", dn->dstat.st_size);
#else
- fprintf(stdout, "%9ld ", dn->dstat.st_size);
+ printf("%9ld ", dn->dstat.st_size);
#endif
}
column += 10;
case LIST_FULLTIME:
case LIST_DATE_TIME:
if (list_fmt & LIST_FULLTIME) {
- fprintf(stdout, "%24.24s ", filetime);
+ printf("%24.24s ", filetime);
column += 25;
break;
}
age = time(NULL) - ttime;
- fprintf(stdout, "%6.6s ", filetime+4);
+ printf("%6.6s ", filetime+4);
if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
/* hh:mm if less than 6 months old */
- fprintf(stdout, "%5.5s ", filetime+11);
+ printf("%5.5s ", filetime+11);
} else {
- fprintf(stdout, " %4.4s ", filetime+20);
+ printf(" %4.4s ", filetime+20);
}
column += 13;
break;
#endif
case LIST_FILENAME:
- fprintf(stdout, "%s", dn->name);
+ printf("%s", dn->name);
column += strlen(dn->name);
break;
case LIST_SYMLINK:
len= readlink(dn->fullname, scratch, (sizeof scratch)-1);
if (len > 0) {
scratch[len]= '\0';
- fprintf(stdout, " -> %s", scratch);
+ printf(" -> %s", scratch);
#ifdef BB_FEATURE_LS_FILETYPES
if (!stat(dn->fullname, &info)) {
append = append_char(info.st_mode);
#ifdef BB_FEATURE_LS_FILETYPES
case LIST_FILETYPE:
if (append != '\0') {
- fprintf(stdout, "%1c", append);
+ printf("%1c", append);
column++;
}
break;
static void gotsig(int sig)
{
setTermSettings(fileno(cin), &initial_settings);
- fprintf(stdout, "\n");
- exit(TRUE);
+ putchar('\n');
+ exit(EXIT_FAILURE);
}
#endif /* BB_FEATURE_USE_TERMIOS */
please_display_more_prompt = 0;
lines = 0;
- len = fprintf(stdout, "--More-- ");
+ len = printf("--More-- ");
if (file != stdin) {
#if _FILE_OFFSET_BITS == 64
- len += fprintf(stdout, "(%d%% of %lld bytes)",
+ len += printf("(%d%% of %lld bytes)",
#else
- len += fprintf(stdout, "(%d%% of %ld bytes)",
+ len += printf("(%d%% of %ld bytes)",
#endif
(int) (100 *
((double) ftell(file) /
(double) st.st_size)),
st.st_size);
}
- len += fprintf(stdout, "%s",
+ len += printf("%s",
#ifdef BB_FEATURE_USE_TERMIOS
""
#else
{
if (G.charmode == CHM_TRY) {
G.charmode = CHM_ON;
- fprintf(stdout, "\r\nEntering character mode%s'^]'.\r\n", escapecharis);
+ printf("\r\nEntering character mode%s'^]'.\r\n", escapecharis);
rawmode();
}
}
{
if (G.charmode != CHM_OFF) {
G.charmode = CHM_OFF;
- fprintf(stdout, "\r\nEntering line mode%s'^C'.\r\n", escapecharis);
+ printf("\r\nEntering line mode%s'^C'.\r\n", escapecharis);
cookmode();
}
}
terminal_width = win.ws_col - 1;
#endif
- fprintf(stdout, "%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid",
- "State", "Command");
+ printf("%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid", "State", "Command");
while ((entry = readdir(dir)) != NULL) {
if (!isdigit(*entry->d_name))
continue;
if (file == NULL)
continue;
i = 0;
- len = fprintf(stdout, "%5d %-8s %-8s %c ", p.pid, uidName, groupName,
- p.state);
+ len = printf("%5d %-8s %-8s %c ", p.pid, uidName, groupName, p.state);
while (((c = getc(file)) != EOF) && (i < (terminal_width-len))) {
i++;
if (c == '\0')
}
fclose(file);
if (i == 0)
- fprintf(stdout, "[%s]", p.cmd);
- fprintf(stdout, "\n");
+ printf("[%s]", p.cmd);
+ putchar('\n');
}
closedir(dir);
return EXIT_SUCCESS;
#endif
/* Print up a ps listing */
- fprintf(stdout, "%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid",
- "State", "Command");
+ printf("%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid", "State", "Command");
for (i=1; i<pid_array[0] ; i++) {
info.pid = pid_array[i];
if (*groupName == '\0')
sprintf(groupName, "%ld", info.egid);
- len = fprintf(stdout, "%5d %-8s %-8s %c ", info.pid, uidName, groupName, info.state);
+ len = printf("%5d %-8s %-8s %c ", info.pid, uidName, groupName, info.state);
if (strlen(info.command_line) > 1) {
for( j=0; j<(sizeof(info.command_line)-1) && j < (terminal_width-len); j++) {
}
}
*(info.command_line+j) = '\0';
- fprintf(stdout, "%s\n", info.command_line);
+ puts(info.command_line);
} else {
- fprintf(stdout, "[%s]\n", info.name);
+ printf("[%s]\n", info.name);
}
}
sysinfo(&info);
- fprintf(stdout, " %2d:%02d%s up ",
+ printf(" %2d:%02d%s up ",
current_time->tm_hour%12 ? current_time->tm_hour%12 : 12,
current_time->tm_min, current_time->tm_hour > 11 ? "pm" : "am");
updays = (int) info.uptime / (60*60*24);
if (updays)
- fprintf(stdout, "%d day%s, ", updays, (updays != 1) ? "s" : "");
+ printf("%d day%s, ", updays, (updays != 1) ? "s" : "");
upminutes = (int) info.uptime / 60;
uphours = (upminutes / 60) % 24;
upminutes %= 60;
if(uphours)
- fprintf(stdout, "%2d:%02d, ", uphours, upminutes);
+ printf("%2d:%02d, ", uphours, upminutes);
else
- fprintf(stdout, "%d min, ", upminutes);
+ printf("%d min, ", upminutes);
printf("load average: %ld.%02ld, %ld.%02ld, %ld.%02ld\n",
LOAD_INT(info.loads[0]), LOAD_FRAC(info.loads[0]),
terminal_width = win.ws_col - 1;
#endif
- fprintf(stdout, "%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid",
- "State", "Command");
+ printf("%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid", "State", "Command");
while ((entry = readdir(dir)) != NULL) {
if (!isdigit(*entry->d_name))
continue;
if (file == NULL)
continue;
i = 0;
- len = fprintf(stdout, "%5d %-8s %-8s %c ", p.pid, uidName, groupName,
- p.state);
+ len = printf("%5d %-8s %-8s %c ", p.pid, uidName, groupName, p.state);
while (((c = getc(file)) != EOF) && (i < (terminal_width-len))) {
i++;
if (c == '\0')
}
fclose(file);
if (i == 0)
- fprintf(stdout, "[%s]", p.cmd);
- fprintf(stdout, "\n");
+ printf("[%s]", p.cmd);
+ putchar('\n');
}
closedir(dir);
return EXIT_SUCCESS;
#endif
/* Print up a ps listing */
- fprintf(stdout, "%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid",
- "State", "Command");
+ printf("%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid", "State", "Command");
for (i=1; i<pid_array[0] ; i++) {
info.pid = pid_array[i];
if (*groupName == '\0')
sprintf(groupName, "%ld", info.egid);
- len = fprintf(stdout, "%5d %-8s %-8s %c ", info.pid, uidName, groupName, info.state);
+ len = printf("%5d %-8s %-8s %c ", info.pid, uidName, groupName, info.state);
if (strlen(info.command_line) > 1) {
for( j=0; j<(sizeof(info.command_line)-1) && j < (terminal_width-len); j++) {
}
}
*(info.command_line+j) = '\0';
- fprintf(stdout, "%s\n", info.command_line);
+ puts(info.command_line);
} else {
- fprintf(stdout, "[%s]\n", info.name);
+ printf("[%s]\n", info.name);
}
}
perror_msg_and_die("Could not set time of day");
}
if (printdate) {
- fprintf(stdout, "%s", ctime(&time));
+ printf("%s", ctime(&time));
}
return EXIT_SUCCESS;
static void clean_up_and_die(int sig)
{
cmdedit_reset_term();
- fprintf(stdout, "\n");
+ printf("\n");
if (sig!=SIGINT)
exit(EXIT_SUCCESS);
}
{
if (G.charmode == CHM_TRY) {
G.charmode = CHM_ON;
- fprintf(stdout, "\r\nEntering character mode%s'^]'.\r\n", escapecharis);
+ printf("\r\nEntering character mode%s'^]'.\r\n", escapecharis);
rawmode();
}
}
{
if (G.charmode != CHM_OFF) {
G.charmode = CHM_OFF;
- fprintf(stdout, "\r\nEntering line mode%s'^C'.\r\n", escapecharis);
+ printf("\r\nEntering line mode%s'^C'.\r\n", escapecharis);
cookmode();
}
}
sysinfo(&info);
- fprintf(stdout, " %2d:%02d%s up ",
+ printf(" %2d:%02d%s up ",
current_time->tm_hour%12 ? current_time->tm_hour%12 : 12,
current_time->tm_min, current_time->tm_hour > 11 ? "pm" : "am");
updays = (int) info.uptime / (60*60*24);
if (updays)
- fprintf(stdout, "%d day%s, ", updays, (updays != 1) ? "s" : "");
+ printf("%d day%s, ", updays, (updays != 1) ? "s" : "");
upminutes = (int) info.uptime / 60;
uphours = (upminutes / 60) % 24;
upminutes %= 60;
if(uphours)
- fprintf(stdout, "%2d:%02d, ", uphours, upminutes);
+ printf("%2d:%02d, ", uphours, upminutes);
else
- fprintf(stdout, "%d min, ", upminutes);
+ printf("%d min, ", upminutes);
printf("load average: %ld.%02ld, %ld.%02ld, %ld.%02ld\n",
LOAD_INT(info.loads[0]), LOAD_FRAC(info.loads[0]),
static void gotsig(int sig)
{
setTermSettings(fileno(cin), &initial_settings);
- fprintf(stdout, "\n");
- exit(TRUE);
+ putchar('\n');
+ exit(EXIT_FAILURE);
}
#endif /* BB_FEATURE_USE_TERMIOS */
please_display_more_prompt = 0;
lines = 0;
- len = fprintf(stdout, "--More-- ");
+ len = printf("--More-- ");
if (file != stdin) {
#if _FILE_OFFSET_BITS == 64
- len += fprintf(stdout, "(%d%% of %lld bytes)",
+ len += printf("(%d%% of %lld bytes)",
#else
- len += fprintf(stdout, "(%d%% of %ld bytes)",
+ len += printf("(%d%% of %ld bytes)",
#endif
(int) (100 *
((double) ftell(file) /
(double) st.st_size)),
st.st_size);
}
- len += fprintf(stdout, "%s",
+ len += printf("%s",
#ifdef BB_FEATURE_USE_TERMIOS
""
#else
perror_msg_and_die("Could not set time of day");
}
if (printdate) {
- fprintf(stdout, "%s", ctime(&time));
+ printf("%s", ctime(&time));
}
return EXIT_SUCCESS;