#define BB_CHROOT
#define BB_CHVT
#define BB_CLEAR
+#define BB_CMP
#define BB_CP_MV
#define BB_CUT
#define BB_DATE
#define BB_PS
#define BB_PWD
#define BB_RDATE
+#define BB_READLINK
#define BB_REBOOT
#define BB_RENICE
#define BB_RESET
#ifdef BB_CHVT
{"chvt", chvt_main, _BB_DIR_USR_BIN, chvt_usage},
#endif
+#ifdef BB_CMP
+ {"cmp", cmp_main, _BB_DIR_USR_BIN, cmp_usage},
+#endif
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN, cp_usage},
#endif
#ifdef BB_RDATE
{"rdate", rdate_main, _BB_DIR_USR_BIN, rdate_usage},
#endif
+#ifdef BB_READLINK
+ {"readlink", readlink_main, _BB_DIR_USR_BIN, readlink_usage},
+#endif
#ifdef BB_REBOOT
{"reboot", reboot_main, _BB_DIR_SBIN, reboot_usage},
#endif
;
#endif
+#if defined BB_CMP
+const char cmp_usage[] =
+ "cmp FILE1 [FILE2]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCompare files.\n"
+#endif
+ ;
+#endif
+
#if defined BB_CP_MV
const char cp_usage[] =
"cp [OPTION]... SOURCE DEST\n"
;
#endif
+#if defined BB_READLINK
+const char readlink_usage[] =
+ "readlink\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRead a symbolic link.\n"
+#endif
+ ;
+#endif
+
#if defined BB_REBOOT
const char reboot_usage[] =
"reboot\n"
#endif
;
#endif
-
#if defined BB_RENICE
const char renice_usage[] =
#ifdef BB_CHVT
{"chvt", chvt_main, _BB_DIR_USR_BIN, chvt_usage},
#endif
+#ifdef BB_CMP
+ {"cmp", cmp_main, _BB_DIR_USR_BIN, cmp_usage},
+#endif
#ifdef BB_CP_MV
{"cp", cp_mv_main, _BB_DIR_BIN, cp_usage},
#endif
#ifdef BB_RDATE
{"rdate", rdate_main, _BB_DIR_USR_BIN, rdate_usage},
#endif
+#ifdef BB_READLINK
+ {"readlink", readlink_main, _BB_DIR_USR_BIN, readlink_usage},
+#endif
#ifdef BB_REBOOT
{"reboot", reboot_main, _BB_DIR_SBIN, reboot_usage},
#endif
extern int chroot_main(int argc, char** argv);
extern int chvt_main(int argc, char** argv);
extern int clear_main(int argc, char** argv);
+extern int cmp_main(int argc, char** argv);
extern int cp_mv_main(int argc, char** argv);
extern int cut_main(int argc, char** argv);
extern int date_main(int argc, char** argv);
extern int ps_main(int argc, char** argv);
extern int pwd_main(int argc, char** argv);
extern int rdate_main(int argc, char** argv);
+extern int readlink_main(int argc, char** argv);
extern int reboot_main(int argc, char** argv);
extern int renice_main(int argc, char** argv);
extern int reset_main(int argc, char** argv);
extern const char chroot_usage[];
extern const char chvt_usage[];
extern const char clear_usage[];
+extern const char cmp_usage[];
extern const char cp_usage[];
extern const char cut_usage[];
extern const char date_usage[];
extern const char ps_usage[];
extern const char pwd_usage[];
extern const char rdate_usage[];
+extern const char readlink_usage[];
extern const char reboot_usage[];
extern const char renice_usage[];
extern const char reset_usage[];
--- /dev/null
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini cmp implementation for busybox
+ *
+ *
+ * Copyright (C) 2000 by Lineo, inc.
+ * Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
+ *
+ * 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 "busybox.h"
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+int cmp_main(int argc, char **argv)
+{
+ FILE *fp1 = NULL, *fp2 = stdin;
+ char *filename1 = argv[1], *filename2 = "-";
+ int c1, c2, char_pos = 1, line_pos = 1;
+
+ /* parse argv[] */
+ if (argc < 2 || 3 < argc)
+ usage(cmp_usage);
+
+ fp1 = xfopen(argv[1], "r");
+ if (argv[2] != NULL) {
+ fp2 = xfopen(argv[2], "r");
+ filename2 = argv[2];
+ }
+
+ do {
+ c1 = fgetc(fp1);
+ c2 = fgetc(fp2);
+ if (c1 != c2) {
+ if (c1 == EOF)
+ printf("EOF on %s\n", filename1);
+ else if (c2 == EOF)
+ printf("EOF on %s\n", filename2);
+ else
+ printf("%s %s differ: char %d, line %d\n", filename1, filename2,
+ char_pos, line_pos);
+ return 1;
+ }
+ char_pos++;
+ if (c1 == '\n')
+ line_pos++;
+ } while (c1 != EOF);
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini cmp implementation for busybox
+ *
+ *
+ * Copyright (C) 2000 by Lineo, inc.
+ * Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
+ *
+ * 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 "busybox.h"
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+int cmp_main(int argc, char **argv)
+{
+ FILE *fp1 = NULL, *fp2 = stdin;
+ char *filename1 = argv[1], *filename2 = "-";
+ int c1, c2, char_pos = 1, line_pos = 1;
+
+ /* parse argv[] */
+ if (argc < 2 || 3 < argc)
+ usage(cmp_usage);
+
+ fp1 = xfopen(argv[1], "r");
+ if (argv[2] != NULL) {
+ fp2 = xfopen(argv[2], "r");
+ filename2 = argv[2];
+ }
+
+ do {
+ c1 = fgetc(fp1);
+ c2 = fgetc(fp2);
+ if (c1 != c2) {
+ if (c1 == EOF)
+ printf("EOF on %s\n", filename1);
+ else if (c2 == EOF)
+ printf("EOF on %s\n", filename2);
+ else
+ printf("%s %s differ: char %d, line %d\n", filename1, filename2,
+ char_pos, line_pos);
+ return 1;
+ }
+ char_pos++;
+ if (c1 == '\n')
+ line_pos++;
+ } while (c1 != EOF);
+
+ return EXIT_SUCCESS;
+}
extern int chroot_main(int argc, char** argv);
extern int chvt_main(int argc, char** argv);
extern int clear_main(int argc, char** argv);
+extern int cmp_main(int argc, char** argv);
extern int cp_mv_main(int argc, char** argv);
extern int cut_main(int argc, char** argv);
extern int date_main(int argc, char** argv);
extern int ps_main(int argc, char** argv);
extern int pwd_main(int argc, char** argv);
extern int rdate_main(int argc, char** argv);
+extern int readlink_main(int argc, char** argv);
extern int reboot_main(int argc, char** argv);
extern int renice_main(int argc, char** argv);
extern int reset_main(int argc, char** argv);
extern const char chroot_usage[];
extern const char chvt_usage[];
extern const char clear_usage[];
+extern const char cmp_usage[];
extern const char cp_usage[];
extern const char cut_usage[];
extern const char date_usage[];
extern const char ps_usage[];
extern const char pwd_usage[];
extern const char rdate_usage[];
+extern const char readlink_usage[];
extern const char reboot_usage[];
extern const char renice_usage[];
extern const char reset_usage[];
--- /dev/null
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini readlink implementation for busybox
+ *
+ *
+ * Copyright (C) 2000 by Lineo, inc.
+ * Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
+ *
+ * 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 "busybox.h"
+#include <errno.h>
+#include <unistd.h>
+
+int readlink_main(int argc, char **argv)
+{
+ char *buf = NULL;
+ int bufsize = 128, size = 128;
+
+ if (argc != 2)
+ usage(readlink_usage);
+
+ while (bufsize < size + 1) {
+ bufsize *= 2;
+ buf = xrealloc(buf, bufsize);
+ size = readlink(argv[1], buf, bufsize);
+ if (size == -1)
+ fatalError("%s: %s\n", argv[1], strerror(errno));
+ }
+
+ buf[size] = '\0';
+ puts(buf);
+
+ return EXIT_SUCCESS;
+}
--- /dev/null
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini readlink implementation for busybox
+ *
+ *
+ * Copyright (C) 2000 by Lineo, inc.
+ * Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
+ *
+ * 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 "busybox.h"
+#include <errno.h>
+#include <unistd.h>
+
+int readlink_main(int argc, char **argv)
+{
+ char *buf = NULL;
+ int bufsize = 128, size = 128;
+
+ if (argc != 2)
+ usage(readlink_usage);
+
+ while (bufsize < size + 1) {
+ bufsize *= 2;
+ buf = xrealloc(buf, bufsize);
+ size = readlink(argv[1], buf, bufsize);
+ if (size == -1)
+ fatalError("%s: %s\n", argv[1], strerror(errno));
+ }
+
+ buf[size] = '\0';
+ puts(buf);
+
+ return EXIT_SUCCESS;
+}
;
#endif
+#if defined BB_CMP
+const char cmp_usage[] =
+ "cmp FILE1 [FILE2]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nCompare files.\n"
+#endif
+ ;
+#endif
+
#if defined BB_CP_MV
const char cp_usage[] =
"cp [OPTION]... SOURCE DEST\n"
;
#endif
+#if defined BB_READLINK
+const char readlink_usage[] =
+ "readlink\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nRead a symbolic link.\n"
+#endif
+ ;
+#endif
+
#if defined BB_REBOOT
const char reboot_usage[] =
"reboot\n"
#endif
;
#endif
-
#if defined BB_RENICE
const char renice_usage[] =