- add libbb function str_tolower to convert a string to lowercase.
[oweals/busybox.git] / miscutils / rx.c
index 41673b60e2abffa105f6e142e6009c5ce09bd854..29848b1d9f2b110433ef82b67c39a5e7c1903d8f 100644 (file)
@@ -1,7 +1,6 @@
 /* vi: set sw=4 ts=4: */
 /*-------------------------------------------------------------------------
  * Filename:      xmodem.c
- * Version:       $Id: rx.c,v 1.2 2004/03/15 08:28:46 andersen Exp $
  * Copyright:     Copyright (C) 2001, Hewlett-Packard Company
  * Author:        Christopher Hoover <ch@hpl.hp.com>
  * Description:   xmodem functionality for uploading of kernels
  */
 
 #include "busybox.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <termios.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-
 
 #define SOH 0x01
 #define STX 0x02
@@ -261,6 +248,7 @@ static void sigalrm_handler(int ATTRIBUTE_UNUSED signum)
 {
 }
 
+int rx_main(int argc, char **argv);
 int rx_main(int argc, char **argv)
 {
        char *fn;
@@ -274,11 +262,11 @@ int rx_main(int argc, char **argv)
                        bb_show_usage();
 
        fn = argv[1];
-       ttyfd = bb_xopen3(CURRENT_TTY, O_RDWR, 0);
-       filefd = bb_xopen3(fn, O_RDWR|O_CREAT|O_TRUNC, 0666);
+       ttyfd = xopen(CURRENT_TTY, O_RDWR);
+       filefd = xopen(fn, O_RDWR|O_CREAT|O_TRUNC);
 
        if (tcgetattr(ttyfd, &tty) < 0)
-                       bb_error_msg_and_die("%s: tcgetattr failed: %m\n", argv[0]);
+                       bb_perror_msg_and_die("tcgetattr");
 
        orig_tty = tty;
 
@@ -296,8 +284,7 @@ int rx_main(int argc, char **argv)
        tcsetattr(ttyfd, TCSAFLUSH, &orig_tty);
 
        if (n < 0)
-                       bb_error_msg_and_die("\n%s: receive failed:\n  %s\n",
-                                                          argv[0], error_buf);
+               bb_error_msg_and_die("\nreceive failed:\n  %s", error_buf);
 
-       bb_fflush_stdout_and_exit(EXIT_SUCCESS);
+       fflush_stdout_and_exit(EXIT_SUCCESS);
 }