/* 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 "libbb.h"
#define SOH 0x01
#define STX 0x02
#define TIMEOUT_LONG 10
#define MAXERRORS 10
-static int read_byte(int fd, unsigned int timeout) {
+static int read_byte(int fd, unsigned int timeout)
+{
char buf[1];
int n;
{
}
+int rx_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int rx_main(int argc, char **argv)
{
char *fn;
bb_show_usage();
fn = argv[1];
- ttyfd = xopen3(CURRENT_TTY, O_RDWR, 0);
- filefd = 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_perror_msg_and_die("%s: tcgetattr failed", argv[0]);
+ bb_perror_msg_and_die("tcgetattr");
orig_tty = tty;
tcsetattr(ttyfd, TCSAFLUSH, &orig_tty);
if (n < 0)
- bb_error_msg_and_die("\n%s: receive failed:\n %s",
- 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);
}