+0.28
+ mini-netcat (mnc) rewritten.
+
0.27
Mount now supports -a, and -t auto.
Mount now updates mtab correctly for 'ro'.
}
a++;
}
- return (busybox_main(argc, argv));
+ exit (busybox_main(argc, argv));
}
fprintf(stderr, "\nCurrently defined functions:\n");
while (a->name != 0) {
- col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), a->name);
- a++;
+ col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), (a++)->name);
if (col>60) {
fprintf(stderr, ",\n");
col=0;
}
a++;
}
- return (busybox_main(argc, argv));
+ exit (busybox_main(argc, argv));
}
fprintf(stderr, "\nCurrently defined functions:\n");
while (a->name != 0) {
- col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), a->name);
- a++;
+ col+=fprintf(stderr, "%s%s", ((col==0)? "\t":", "), (a++)->name);
if (col>60) {
fprintf(stderr, ",\n");
col=0;
//#define BB_MKDIR
//#define BB_MKNOD
////#define BB_MKSWAP
-//#define BB_MNC
+#define BB_MNC
//#define BB_MONADIC
#define BB_MORE
#define BB_MOUNT
#define BB_MV
//#define BB_POSTPROCESS
//#define BB_PRINTF
-//#define BB_PWD
+#define BB_PWD
//#define BB_REBOOT
//#define BB_RM
//#define BB_RMDIR
int c;
FILE *file = stdin;
- if (argc < 2) {
+ if ( (argc < 2) || (**(argv+1) == '-') ) {
fprintf(stderr, "Usage: %s %s", *argv, cat_usage);
- return(FALSE);
+ exit(FALSE);
}
argc--;
argv++;
file = fopen(*argv, "r");
if (file == NULL) {
perror(*argv);
- return(FALSE);
+ exit(FALSE);
}
while ((c = getc(file)) != EOF)
putc(c, stdout);
argc--;
argv++;
}
- return(TRUE);
+ exit(TRUE);
}
if (argc < 2) {
fprintf(stderr, "Usage: %s %s", *argv,
(chownApp==TRUE)? chown_usage : chgrp_usage);
- return( FALSE);
+ exit( FALSE);
}
invocationName=*argv;
argc--;
break;
default:
fprintf(stderr, "Unknown option: %c\n", **argv);
- return( FALSE);
+ exit( FALSE);
}
argc--;
argv++;
grp = getgrnam(groupName);
if (grp == NULL) {
fprintf(stderr, "%s: Unknown group name: %s\n", invocationName, groupName);
- return( FALSE);
+ exit( FALSE);
}
gid = grp->gr_gid;
pwd = getpwnam(*argv);
if (pwd == NULL) {
fprintf(stderr, "%s: Unknown user name: %s\n", invocationName, *argv);
- return( FALSE);
+ exit( FALSE);
}
uid = pwd->pw_uid;
}
/* Ok, ready to do the deed now */
if (argc <= 1) {
fprintf(stderr, "%s: too few arguments", invocationName);
- return( FALSE);
+ exit( FALSE);
}
while (argc-- > 1) {
argv++;
recursiveAction( *argv, recursiveFlag, TRUE, fileAction, fileAction);
}
- return(TRUE);
+ exit(TRUE);
}
*/
#include "internal.h"
+#include <stdlib.h>
#include <stdio.h>
-#include <unistd.h>
+#include <errno.h>
static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
int chroot_main(int argc, char **argv)
{
- if (argc < 2) {
+ if ( (argc < 2) || (**(argv+1) == '-') ) {
fprintf(stderr, "Usage: %s %s", *argv, chroot_usage);
- return( FALSE);
+ exit( FALSE);
}
argc--;
argv++;
- fprintf(stderr, "new root: %s\n", *argv);
-
if (chroot (*argv) || (chdir ("/"))) {
- perror("cannot chroot");
- return( FALSE);
+ fprintf(stderr, "chroot: cannot change root directory to %s: %s\n",
+ *argv, strerror(errno));
+ exit( FALSE);
}
argc--;
prog = getenv ("SHELL");
if (!prog)
prog = "/bin/sh";
- fprintf(stderr, "no command. running: %s\n", prog);
execlp (prog, prog, NULL);
}
- perror("cannot exec");
- return(FALSE);
+ fprintf(stderr, "chroot: cannot execute %s: %s\n",
+ *argv, strerror(errno));
+ exit( FALSE);
}
clear_main(int argc, char** argv)
{
printf("\033[H\033[J");
- return 0;
+ exit( TRUE);
}
clear_main(int argc, char** argv)
{
printf("\033[H\033[J");
- return 0;
+ exit( TRUE);
}
int c;
FILE *file = stdin;
- if (argc < 2) {
+ if ( (argc < 2) || (**(argv+1) == '-') ) {
fprintf(stderr, "Usage: %s %s", *argv, cat_usage);
- return(FALSE);
+ exit(FALSE);
}
argc--;
argv++;
file = fopen(*argv, "r");
if (file == NULL) {
perror(*argv);
- return(FALSE);
+ exit(FALSE);
}
while ((c = getc(file)) != EOF)
putc(c, stdout);
argc--;
argv++;
}
- return(TRUE);
+ exit(TRUE);
}
if (argc < 2) {
fprintf(stderr, "Usage: %s %s", *argv,
(chownApp==TRUE)? chown_usage : chgrp_usage);
- return( FALSE);
+ exit( FALSE);
}
invocationName=*argv;
argc--;
break;
default:
fprintf(stderr, "Unknown option: %c\n", **argv);
- return( FALSE);
+ exit( FALSE);
}
argc--;
argv++;
grp = getgrnam(groupName);
if (grp == NULL) {
fprintf(stderr, "%s: Unknown group name: %s\n", invocationName, groupName);
- return( FALSE);
+ exit( FALSE);
}
gid = grp->gr_gid;
pwd = getpwnam(*argv);
if (pwd == NULL) {
fprintf(stderr, "%s: Unknown user name: %s\n", invocationName, *argv);
- return( FALSE);
+ exit( FALSE);
}
uid = pwd->pw_uid;
}
/* Ok, ready to do the deed now */
if (argc <= 1) {
fprintf(stderr, "%s: too few arguments", invocationName);
- return( FALSE);
+ exit( FALSE);
}
while (argc-- > 1) {
argv++;
recursiveAction( *argv, recursiveFlag, TRUE, fileAction, fileAction);
}
- return(TRUE);
+ exit(TRUE);
}
*/
#include "internal.h"
+#include <stdlib.h>
#include <stdio.h>
-#include <unistd.h>
+#include <errno.h>
static const char chroot_usage[] = "NEWROOT [COMMAND...]\n"
int chroot_main(int argc, char **argv)
{
- if (argc < 2) {
+ if ( (argc < 2) || (**(argv+1) == '-') ) {
fprintf(stderr, "Usage: %s %s", *argv, chroot_usage);
- return( FALSE);
+ exit( FALSE);
}
argc--;
argv++;
- fprintf(stderr, "new root: %s\n", *argv);
-
if (chroot (*argv) || (chdir ("/"))) {
- perror("cannot chroot");
- return( FALSE);
+ fprintf(stderr, "chroot: cannot change root directory to %s: %s\n",
+ *argv, strerror(errno));
+ exit( FALSE);
}
argc--;
prog = getenv ("SHELL");
if (!prog)
prog = "/bin/sh";
- fprintf(stderr, "no command. running: %s\n", prog);
execlp (prog, prog, NULL);
}
- perror("cannot exec");
- return(FALSE);
+ fprintf(stderr, "chroot: cannot execute %s: %s\n",
+ *argv, strerror(errno));
+ exit( FALSE);
}
if (argc < 3) {
fprintf(stderr, "Usage: %s", cp_usage);
- return (FALSE);
+ exit (FALSE);
}
argc--;
argv++;
if ((argc > 3) && !dirFlag) {
fprintf(stderr, "%s: not a directory\n", destName);
- return (FALSE);
+ exit (FALSE);
}
while (argc-- >= 2) {
srcName = *(argv++);
- return recursiveAction(srcName, recursiveFlag, followLinks,
- fileAction, fileAction);
+ exit( recursiveAction(srcName, recursiveFlag, followLinks,
+ fileAction, fileAction));
}
- return( TRUE);
+ exit( TRUE);
}
+/*
+ * Mini date implementation for busybox
+ *
+ * Copyright (C) 1999 by Erik Andersen <andersee@debian.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+*/
+
#include "internal.h"
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
-#include <getopt.h>
/* This 'date' command supports only 2 time setting formats,
an RFC 822 complient date output for shell scripting
mail commands */
-const char date_usage[] = "date [-uR] [+FORMAT|+%f] [ [-s|-d] MMDDhhmm[[CC]YY]\n"
-"| [[[[CCYY.]MM.DD-]hh:mm[:ss]]]] ]";
-
-//static const char date_usage[] = "Usage: date [OPTION]... [+FORMAT]\n"
-//"or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
-//"Display the current time in the given FORMAT, or set the system date.\n";
-
-
-static struct option const long_options[] =
-{
- {"date", required_argument, NULL, 'd'},
- /* {"rfc-822", no_argument, NULL, 'R'},
- {"set", required_argument, NULL, 's'},
- {"uct", no_argument, NULL, 'u'},
- {"utc", no_argument, NULL, 'u'},
- {"universal", no_argument, NULL, 'u'}, */
- {NULL, 0, NULL, 0}
-};
-
+const char date_usage[] = "Usage: date [OPTION]... [+FORMAT]\n"
+" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
+"Display the current time in the given FORMAT, or set the system date.\n"
+"\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
+"\t-s\t\tset time described by STRING\n"
+"\t-u\t\tprint or set Coordinated Universal Time\n";
/* Input parsing code is always bulky - used heavy duty libc stuff as
if(nr < 4 || nr > 5) {
fprintf(stderr, "date: invalid date `%s'\n", t_string);
- exit(1);
+ exit( FALSE);
}
/* correct for century - minor Y2K problem here? */
fprintf(stderr, "date: invalid date `%s'\n", t_string);
- exit(1);
+ exit( FALSE);
}
void
date_err(void) {
- fprintf(stderr, "date: only one date argument can be given at a time.\n");
- exit(1);
+ fprintf (stderr, "%s\n", date_usage);
+ exit( FALSE);
}
int
char *date_str = NULL;
char *date_fmt = NULL;
char *t_buff;
+ int i;
int set_time = 0;
int rfc822 = 0;
int utc = 0;
int use_arg = 0;
- int n_args;
time_t tm;
struct tm tm_time;
- char optc;
/* Interpret command line args */
-
-
- while ((optc = getopt_long (argc, argv, "d:Rs:u", long_options, NULL))
- != EOF) {
- switch (optc) {
- case 0:
- break;
-
- case 'R':
- rfc822 = 1;
- break;
-
- case 's':
- set_time = 1;
- if(date_str != NULL) date_err();
- date_str = optarg;
- break;
-
- case 'u':
- utc = 1;
- if (putenv ("TZ=UTC0") != 0) {
- fprintf(stderr,"date: memory exhausted\n");
- return(1);
- }
-#if LOCALTIME_CACHE
- tzset ();
-#endif break;
-
- case 'd':
- use_arg = 1;
- if(date_str != NULL) date_err();
- date_str = optarg;
- break;
-
- default:
- fprintf(stderr, "Usage: %s", date_usage);
- break;
+ i = --argc;
+ argv++;
+ while (i > 0 && **argv) {
+ if (**argv == '-') {
+ while (i>0 && *++(*argv)) switch (**argv) {
+ case 'R':
+ rfc822 = 1;
+ break;
+ case 's':
+ set_time = 1;
+ if(date_str != NULL) date_err();
+ date_str = optarg;
+ break;
+ case 'u':
+ utc = 1;
+ if (putenv ("TZ=UTC0") != 0) {
+ fprintf(stderr,"date: memory exhausted\n");
+ exit( FALSE);
+ }
+ /* Look ma, no break. Don't fix it either. */
+ case 'd':
+ use_arg = 1;
+ if(date_str != NULL) date_err();
+ date_str = optarg;
+ break;
+ case '-':
+ date_err();
+ }
+ } else {
+ if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) )
+ date_fmt=*argv;
+ else if (date_str == NULL) {
+ set_time = 1;
+ date_str=*argv;
+ } else {
+ date_err();
+ }
+ }
+ i--;
+ argv++;
}
- }
-
-
- n_args = argc - optind;
-
- while (n_args--){
- switch(argv[optind][0]) {
- case '+':
- /* Date format strings */
- if(date_fmt != NULL) {
- fprintf(stderr, "date: only one date format can be given.\n");
- return(1);
- }
- date_fmt = &argv[optind][1];
- break;
-
- case '\0':
- break;
-
- default:
- /* Anything left over must be a date string to set the time */
- set_time = 1;
- if(date_str != NULL) date_err();
- date_str = argv[optind];
- break;
- }
- optind++;
- }
/* Now we have parsed all the information except the date format
tm = mktime(&tm_time);
if (tm < 0 ) {
fprintf(stderr, "date: invalid date `%s'\n", date_str);
- exit(1);
+ exit( FALSE);
}
/* if setting time, set it */
if(set_time) {
if( stime(&tm) < 0) {
fprintf(stderr, "date: can't set date.\n");
- exit(1);
+ exit( FALSE);
}
}
}
} else if ( *date_fmt == '\0' ) {
/* Imitate what GNU 'date' does with NO format string! */
printf ("\n");
- return(0);
+ exit( TRUE);
}
/* Handle special conversions */
strftime(t_buff, 200, date_fmt, &tm_time);
printf("%s\n", t_buff);
- return(0);
+ exit( TRUE);
}
+
const char pwd_usage[] = "Print the current directory.\n";
extern int
-pwd_main(struct FileInfo * i, int argc, char * * argv)
+pwd_main(int argc, char * * argv)
{
char buf[1024];
if ( getcwd(buf, sizeof(buf)) == NULL ) {
- name_and_error("get working directory");
- return 1;
+ perror("get working directory");
+ exit( FALSE);
}
printf("%s\n", buf);
- return 0;
+ exit( TRUE);
}
if (argc < 3) {
fprintf(stderr, "Usage: %s", cp_usage);
- return (FALSE);
+ exit (FALSE);
}
argc--;
argv++;
if ((argc > 3) && !dirFlag) {
fprintf(stderr, "%s: not a directory\n", destName);
- return (FALSE);
+ exit (FALSE);
}
while (argc-- >= 2) {
srcName = *(argv++);
- return recursiveAction(srcName, recursiveFlag, followLinks,
- fileAction, fileAction);
+ exit( recursiveAction(srcName, recursiveFlag, followLinks,
+ fileAction, fileAction));
}
- return( TRUE);
+ exit( TRUE);
}
+/*
+ * Mini date implementation for busybox
+ *
+ * Copyright (C) 1999 by Erik Andersen <andersee@debian.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+*/
+
#include "internal.h"
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
-#include <getopt.h>
/* This 'date' command supports only 2 time setting formats,
an RFC 822 complient date output for shell scripting
mail commands */
-const char date_usage[] = "date [-uR] [+FORMAT|+%f] [ [-s|-d] MMDDhhmm[[CC]YY]\n"
-"| [[[[CCYY.]MM.DD-]hh:mm[:ss]]]] ]";
-
-//static const char date_usage[] = "Usage: date [OPTION]... [+FORMAT]\n"
-//"or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
-//"Display the current time in the given FORMAT, or set the system date.\n";
-
-
-static struct option const long_options[] =
-{
- {"date", required_argument, NULL, 'd'},
- /* {"rfc-822", no_argument, NULL, 'R'},
- {"set", required_argument, NULL, 's'},
- {"uct", no_argument, NULL, 'u'},
- {"utc", no_argument, NULL, 'u'},
- {"universal", no_argument, NULL, 'u'}, */
- {NULL, 0, NULL, 0}
-};
-
+const char date_usage[] = "Usage: date [OPTION]... [+FORMAT]\n"
+" or: date [OPTION] [MMDDhhmm[[CC]YY][.ss]]\n"
+"Display the current time in the given FORMAT, or set the system date.\n"
+"\nOptions:\n\t-R\t\toutput RFC-822 compliant date string\n"
+"\t-s\t\tset time described by STRING\n"
+"\t-u\t\tprint or set Coordinated Universal Time\n";
/* Input parsing code is always bulky - used heavy duty libc stuff as
if(nr < 4 || nr > 5) {
fprintf(stderr, "date: invalid date `%s'\n", t_string);
- exit(1);
+ exit( FALSE);
}
/* correct for century - minor Y2K problem here? */
fprintf(stderr, "date: invalid date `%s'\n", t_string);
- exit(1);
+ exit( FALSE);
}
void
date_err(void) {
- fprintf(stderr, "date: only one date argument can be given at a time.\n");
- exit(1);
+ fprintf (stderr, "%s\n", date_usage);
+ exit( FALSE);
}
int
char *date_str = NULL;
char *date_fmt = NULL;
char *t_buff;
+ int i;
int set_time = 0;
int rfc822 = 0;
int utc = 0;
int use_arg = 0;
- int n_args;
time_t tm;
struct tm tm_time;
- char optc;
/* Interpret command line args */
-
-
- while ((optc = getopt_long (argc, argv, "d:Rs:u", long_options, NULL))
- != EOF) {
- switch (optc) {
- case 0:
- break;
-
- case 'R':
- rfc822 = 1;
- break;
-
- case 's':
- set_time = 1;
- if(date_str != NULL) date_err();
- date_str = optarg;
- break;
-
- case 'u':
- utc = 1;
- if (putenv ("TZ=UTC0") != 0) {
- fprintf(stderr,"date: memory exhausted\n");
- return(1);
- }
-#if LOCALTIME_CACHE
- tzset ();
-#endif break;
-
- case 'd':
- use_arg = 1;
- if(date_str != NULL) date_err();
- date_str = optarg;
- break;
-
- default:
- fprintf(stderr, "Usage: %s", date_usage);
- break;
+ i = --argc;
+ argv++;
+ while (i > 0 && **argv) {
+ if (**argv == '-') {
+ while (i>0 && *++(*argv)) switch (**argv) {
+ case 'R':
+ rfc822 = 1;
+ break;
+ case 's':
+ set_time = 1;
+ if(date_str != NULL) date_err();
+ date_str = optarg;
+ break;
+ case 'u':
+ utc = 1;
+ if (putenv ("TZ=UTC0") != 0) {
+ fprintf(stderr,"date: memory exhausted\n");
+ exit( FALSE);
+ }
+ /* Look ma, no break. Don't fix it either. */
+ case 'd':
+ use_arg = 1;
+ if(date_str != NULL) date_err();
+ date_str = optarg;
+ break;
+ case '-':
+ date_err();
+ }
+ } else {
+ if ( (date_fmt == NULL) && (strcmp(*argv, "+")==0) )
+ date_fmt=*argv;
+ else if (date_str == NULL) {
+ set_time = 1;
+ date_str=*argv;
+ } else {
+ date_err();
+ }
+ }
+ i--;
+ argv++;
}
- }
-
-
- n_args = argc - optind;
-
- while (n_args--){
- switch(argv[optind][0]) {
- case '+':
- /* Date format strings */
- if(date_fmt != NULL) {
- fprintf(stderr, "date: only one date format can be given.\n");
- return(1);
- }
- date_fmt = &argv[optind][1];
- break;
-
- case '\0':
- break;
-
- default:
- /* Anything left over must be a date string to set the time */
- set_time = 1;
- if(date_str != NULL) date_err();
- date_str = argv[optind];
- break;
- }
- optind++;
- }
/* Now we have parsed all the information except the date format
tm = mktime(&tm_time);
if (tm < 0 ) {
fprintf(stderr, "date: invalid date `%s'\n", date_str);
- exit(1);
+ exit( FALSE);
}
/* if setting time, set it */
if(set_time) {
if( stime(&tm) < 0) {
fprintf(stderr, "date: can't set date.\n");
- exit(1);
+ exit( FALSE);
}
}
}
} else if ( *date_fmt == '\0' ) {
/* Imitate what GNU 'date' does with NO format string! */
printf ("\n");
- return(0);
+ exit( TRUE);
}
/* Handle special conversions */
strftime(t_buff, 200, date_fmt, &tm_time);
printf("%s\n", t_buff);
- return(0);
+ exit( TRUE);
}
+
0.0.1 6K It works.
0.0.2 5K Smaller and you can also check the exit condition if you wish.
-
+ 0.0.3 Uses select()
19980918 Busy Boxed! Dave Cinege
+ 19990512 Uses Select. Charles P. Wright
+ 19990513 Fixes stdin stupidity and uses buffers. Charles P. Wright
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <sys/time.h>
#include <sys/ioctl.h>
+#define BUFSIZE 100
+
const char mnc_usage[] =
-"mini-netcat 0.0.1 -- Open pipe to IP:port\n"
+"mini-netcat 0.0.3 -- Open pipe to IP:port\n"
"\tmnc [IP] [port]\n";
int
-mnc_main(struct FileInfo * i, int argc, char **argv)
+mnc_main(int argc, char **argv)
{
-
int sfd;
int result;
int len;
- int pid;
- char ch;
+ char ch[BUFSIZE];
struct sockaddr_in address;
struct hostent *hostinfo;
-#ifdef SELECT
fd_set readfds, testfds;
-#endif
sfd = socket(AF_INET, SOCK_STREAM, 0);
exit(2);
}
-#ifdef SELECT
FD_ZERO(&readfds);
FD_SET(sfd, &readfds);
FD_SET(fileno(stdin), &readfds);
while(1)
{
int fd;
+ int ofd;
int nread;
testfds = readfds;
{
if(FD_ISSET(fd,&testfds))
{
- ioctl(fd, FIONREAD, &nread);
+ int trn = 0;
+ int rn;
- if (nread == 0)
- exit(0);
+ ioctl(fd, FIONREAD, &nread);
if(fd == sfd)
{
- read(sfd, &ch, 1);
- write(fileno(stdout), &ch, 1);
- }
- else
- {
- read(fileno(stdin), &ch, 1);
- write(sfd, &ch, 1);
- }
- }
+ if (nread == 0)
+ exit(0);
+ ofd = fileno(stdout);
+ }
+ else
+ {
+ ofd = sfd;
+ }
+
+
+
+ do
+ {
+ rn = (BUFSIZE < nread - trn) ? BUFSIZE : nread - trn;
+ trn += rn;
+ read(fd, ch, rn);
+ write(ofd, ch, rn);
+ }
+ while (trn < nread);
+ }
}
}
-#else
- pid = fork();
-
- if (!pid)
- {
- int retval;
- retval = 1;
- while(retval == 1)
- {
- retval = read(fileno(stdin), &ch, 1);
- write(sfd, &ch, 1);
- }
- }
- else
- {
- int retval;
- retval = 1;
- while(retval == 1)
- {
- retval = read(sfd, &ch, 1);
- write(fileno(stdout), &ch, 1);
- }
- }
-
- exit(0);
-#endif
}
const char pwd_usage[] = "Print the current directory.\n";
extern int
-pwd_main(struct FileInfo * i, int argc, char * * argv)
+pwd_main(int argc, char * * argv)
{
char buf[1024];
if ( getcwd(buf, sizeof(buf)) == NULL ) {
- name_and_error("get working directory");
- return 1;
+ perror("get working directory");
+ exit( FALSE);
}
printf("%s\n", buf);
- return 0;
+ exit( TRUE);
}