Fix error messages.
[oweals/busybox.git] / coreutils / md5sum.c
index ffa9e6bce65b276e7232f586c72518ea6f883834..21570de9352ac8d12cded756e0e987a74f57985c 100644 (file)
 /* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
 /* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
 
-#include "internal.h"
+#include "busybox.h"
 #include <stdio.h>
 #include <errno.h>
 #include <ctype.h>
+#include <getopt.h>
+
+/* It turns out that libc5 doesn't have this in its headers
+ * even though it is actually in the lib.  Force it to work */
+#if ! defined __GLIBC__ && ! defined __UCLIBC__
+#define getline __getline
+extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
+#endif
 
 //----------------------------------------------------------------------------
 //--------md5.c
@@ -58,7 +66,7 @@
 #include <string.h>
 #include <endian.h>
 
-#include "internal.h"
+#include "busybox.h"
 //----------------------------------------------------------------------------
 //--------md5.h
 //----------------------------------------------------------------------------
@@ -88,7 +96,7 @@
 
 #include <stdio.h>
 
-#if defined HAVE_LIMITS_H || _LIBC
+#if defined HAVE_LIMITS_H || defined _LIBC
 # include <limits.h>
 #endif
 
@@ -574,23 +582,6 @@ static int status_only = 0; /* With -c, don't generate any output.
 static int warn = 0; /* With -w, print a message to standard error warning
                         about each improperly formatted MD5 checksum line */
 
-static const char md5sum_usage[] =
-    "md5sum [OPTION] [FILE]...\n"
-    "or:    md5sum [OPTION] -c [FILE]\n"
-#ifndef BB_FEATURE_TRIVIAL_HELP
-    "\nPrint or check MD5 checksums.\n\n"
-    "Options:\n"
-    "With no FILE, or when FILE is -, read standard input.\n\n"
-    "\t-b\tread files in binary mode\n"
-    "\t-c\tcheck MD5 sums against given list\n"
-    "\t-t\tread files in text mode (default)\n"
-    "\t-g\tread a string\n"
-    "\nThe following two options are useful only when verifying checksums:\n"
-    "\t-s,\tdon't output anything, status code shows success\n"
-    "\t-w,\twarn about improperly formated MD5 checksum lines\n"
-#endif
-;
-
 static int split_3(char *s,
                    size_t s_len,
                    unsigned char **u,
@@ -700,13 +691,13 @@ static int md5_file(const char *filename,
   } else {
     fp = fopen(filename, OPENOPTS(binary));
     if (fp == NULL) {
-      errorMsg("md5sum: %s: %s\n", filename, strerror(errno));
+      errorMsg("%s: %s\n", filename, strerror(errno));
       return FALSE;
     }
   }
 
   if (md5_stream(fp, md5_result)) {
-    errorMsg("md5sum: %s: %s\n", filename, strerror(errno));
+    errorMsg("%s: %s\n", filename, strerror(errno));
 
     if (fp != stdin)
       fclose(fp);
@@ -714,7 +705,7 @@ static int md5_file(const char *filename,
   }
 
   if (fp != stdin && fclose(fp) == EOF) {
-    errorMsg("md5sum: %s: %s\n", filename, strerror(errno));
+    errorMsg("%s: %s\n", filename, strerror(errno));
     return FALSE;
   }
 
@@ -738,7 +729,7 @@ static int md5_check(const char *checkfile_name)
   } else {
     checkfile_stream = fopen(checkfile_name, "r");
     if (checkfile_stream == NULL) {
-      errorMsg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
+      errorMsg("%s: %s\n", checkfile_name, strerror(errno));
       return FALSE;
     }
   }
@@ -819,7 +810,7 @@ static int md5_check(const char *checkfile_name)
     free(line);
 
   if (ferror(checkfile_stream)) {
-    errorMsg("%s: read error", checkfile_name); /* */
+    errorMsg("%s: read error\n", checkfile_name); /* */
     return FALSE;
   }
 
@@ -1000,12 +991,12 @@ int md5sum_main(int argc,
   }
 
   if (fclose (stdout) == EOF) {
-    errorMsg("write error");
+    errorMsg("write error\n");
     exit FALSE;
   }
 
   if (have_read_stdin && fclose (stdin) == EOF) {
-    errorMsg("standard input");
+    errorMsg("standard input\n");
     exit FALSE;
   }