/*
lsz - send files with x/y/zmodem
Copyright (C) until 1988 Chuck Forsberg (Omen Technology INC)
Copyright (C) 1994 Matt Porter, Michael D. Black
Copyright (C) 1996, 1997 Uwe Ohse
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, 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.
originally written by Chuck Forsberg
*/
#include "zglobal.h"
/* char *getenv(); */
#define SS_NORMAL 0
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <setjmp.h>
#include <ctype.h>
#include <errno.h>
#include <getopt.h>
#ifndef R_OK
# define R_OK 4
#endif
#if defined(HAVE_SYS_MMAN_H) && defined(HAVE_MMAP)
# include <sys/mman.h>
size_t mm_size;
void *mm_addr=NULL;
#else
# undef HAVE_MMAP
#endif
#include "timing.h"
#include "long-options.h"
#include "xstrtoul.h"
#include "error.h"
#ifndef STRICT_PROTOTYPES
extern time_t time();
extern char *strerror();
extern char *strstr();
#endif
#ifndef HAVE_ERRNO_DECLARATION
extern int errno;
#endif
unsigned Baudrate=2400; /* Default, should be set by first mode() call */
unsigned Txwindow; /* Control the size of the transmitted window */
unsigned Txwspac; /* Spacing between zcrcq requests */
unsigned Txwcnt; /* Counter used to space ack requests */
size_t Lrxpos; /* Receiver's last reported offset */
int errors;
enum zm_type_enum protocol;
int under_rsh=FALSE;
extern int turbo_escape;
static int no_unixmode;
int Canseek=1; /* 1: can; 0: only rewind, -1: neither */
static int zsendfile __P ((struct zm_fileinfo *zi, const char *buf, size_t blen));
static int getnak __P ((void));
static int wctxpn __P ((struct zm_fileinfo *));
static int wcs __P ((const char *oname, const char *remotename));
static size_t zfilbuf __P ((struct zm_fileinfo *zi));
static size_t filbuf __P ((char *buf, size_t count));
static int getzrxinit __P ((void));
static int calc_blklen __P ((long total_sent));
static int sendzsinit __P ((void));
static int wctx __P ((struct zm_fileinfo *));
static int zsendfdata __P ((struct zm_fileinfo *));
static int getinsync __P ((struct zm_fileinfo *, int flag));
static void countem __P ((int argc, char **argv));
static void chkinvok __P ((const char *s));
static void usage __P ((int exitcode, const char *what));
static int zsendcmd __P ((const char *buf, size_t blen));
static void saybibi __P ((void));
static int wcsend __P ((int argc, char *argp[]));
static int wcputsec __P ((char *buf, int sectnum, size_t cseclen));
static void usage1 __P ((int exitcode));
#ifdef ENABLE_SYSLOG
#define DO_SYSLOG(message) do { \
if (enable_syslog) { \
const char *shortname; \
if (!zi->fname) \
shortname="no.name"; \
else { \
shortname=strrchr(zi->fname,'/'); \
if (!shortname) \
shortname=zi->fname; \
else \
shortname++; \
} \
lsyslog message ; \
} \
} while(0)
#else
#define DO_SYSLOG(message) do { } while(0)
#endif
#define ZSDATA(x,y,z) \
do { if (Crc32t) {zsda32(x,y,z); } else {zsdata(x,y,z);}} while(0)
#ifdef HAVE_MMAP
#define DATAADR (mm_addr ? ((char *)mm_addr)+zi->bytes_sent : txbuf)
#else
#define DATAADR (txbuf)
#endif
int Filesleft;
long Totalleft;
size_t buffersize=16384;
#ifdef HAVE_MMAP
int use_mmap=1;
#endif
/*
* Attention string to be executed by receiver to interrupt streaming data
* when an error is detected. A pause (0336) may be needed before the
* ^C (03) or after it.
*/
#ifdef READCHECK
char Myattn[] = { 0 };
#else
char Myattn[] = { 03, 0336, 0 };
#endif
FILE *input_f;
#define MAX_BLOCK 8192
char txbuf[MAX_BLOCK];
long vpos = 0; /* Number of bytes read from file */
char Lastrx;
char Crcflg;
int Verbose=0;
int Restricted=0; /* restricted; no /.. or ../ in filenames */
int Quiet=0; /* overrides logic that would otherwise set verbose */
int Ascii=0; /* Add CR's for brain damaged programs */
int Fullname=0; /* transmit full pathname */
int Unlinkafter=0; /* Unlink file after it is sent */
int Dottoslash=0; /* Change foo.bar.baz to foo/bar/baz */
int firstsec;
int errcnt=0; /* number of files unreadable */
size_t blklen=128; /* length of transmitted records */
int Optiong; /* Let it rip no wait for sector ACK's */
int Totsecs; /* total number of sectors this file */
int Filcnt=0; /* count of number of files opened */
int Lfseen=0;
unsigned Rxbuflen = 16384; /* Receiver's max buffer length */
unsigned Tframlen = 0; /* Override for tx frame length */
unsigned blkopt=0; /* Override value for zmodem blklen */
int Rxflags = 0;
int Rxflags2 = 0;
size_t bytcnt;
int Wantfcs32 = TRUE; /* want to send 32 bit FCS */
char Lzconv; /* Local ZMODEM file conversion request */
char Lzmanag; /* Local ZMODEM file management request */
int Lskipnocor;
char Lztrans;
char zconv; /* ZMODEM file conversion request */
char zmanag; /* ZMODEM file management request */
char ztrans; /* ZMODEM file transport request */
int command_mode; /* Send a command, then exit. */
int Cmdtries = 11;
int Cmdack1; /* Rx ACKs command, then do it */
int Exitcode;
int enable_timesync=0;
size_t Lastsync; /* Last offset to which we got a ZRPOS */
int Beenhereb4; /* How many times we've been ZRPOS'd same place */
int no_timeout=FALSE;
size_t max_blklen=1024;
size_t start_blklen=0;
int zmodem_requested;
time_t stop_time=0;
int tcp_flag=0;
char *tcp_server_address=0;
int tcp_socket=-1;
int error_count;
#define OVERHEAD 18
#define OVER_ERR 20
#define MK_STRING(x) #x
#ifdef ENABLE_SYSLOG
# if defined(ENABLE_SYSLOG_FORCE) || defined(ENABLE_SYSLOG_DEFAULT)
int enable_syslog=TRUE;
# else
int enable_syslog=FALSE;
# endif
#endif
jmp_buf intrjmp; /* For the interrupt on RX CAN */
static long min_bps;
static long min_bps_time;
static int io_mode_fd=0;
static int zrqinits_sent=0;
static int play_with_sigint=0;
/* called by signal interrupt or terminate to clean things up */
RETSIGTYPE
bibi (int n)
{
canit(STDOUT_FILENO);
fflush (stdout);
io_mode (io_mode_fd,0);
if (n == 99)
error (0, 0, _ ("io_mode(,2) in rbsb.c not implemented\n"));
else
error (0, 0, _ ("caught signal %d; exiting"), n);
if (n == SIGQUIT)
abort ();
exit (128 + n);
}
/* Called when ZMODEM gets an interrupt (^C) */
static RETSIGTYPE
onintr(int n LRZSZ_ATTRIB_UNUSED)
{
signal(SIGINT, SIG_IGN);
longjmp(intrjmp, -1);
}
int Zctlesc; /* Encode control characters */
const char *program_name = "sz";
int Zrwindow = 1400; /* RX window size (controls garbage count) */
static struct option const long_options[] =
{
{"append", no_argument, NULL, '+'},
{"twostop", no_argument, NULL, '2'},
{"try-8k", no_argument, NULL, '8'},
{"start-8k", no_argument, NULL, '9'},
{"try-4k", no_argument, NULL, '4'},
{"start-4k", no_argument, NULL, '5'},
{"ascii", no_argument, NULL, 'a'},
{"binary", no_argument, NULL, 'b'},
{"bufsize", required_argument, NULL, 'B'},
{"cmdtries", required_argument, NULL, 'C'},
{"command", required_argument, NULL, 'c'},
{"immediate-command", required_argument, NULL, 'i'},
{"dot-to-slash", no_argument, NULL, 'd'},
{"full-path", no_argument, NULL, 'f'},
{"escape", no_argument, NULL, 'e'},
{"rename", no_argument, NULL, 'E'},
{"help", no_argument, NULL, 'h'},
{"crc-check", no_argument, NULL, 'H'},
{"1024", no_argument, NULL, 'k'},
{"1k", no_argument, NULL, 'k'},
{"packetlen", required_argument, NULL, 'L'},
{"framelen", required_argument, NULL, 'l'},
{"min-bps", required_argument, NULL, 'm'},
{"mi
没有合适的资源?快使用搜索试试~ 我知道了~
lrz--sz 工具
4星 · 超过85%的资源 需积分: 48 125 下载量 35 浏览量
2008-12-26
15:55:47
上传
评论
收藏 274KB GZ 举报
温馨提示
共143个文件
c:46个
exp:19个
in:16个
搞驱动开发时需要的工具,可以下到开发板上,来测试驱动。需要先编译。
资源推荐
资源详情
资源评论
收起资源包目录
lrz--sz 工具 (143个子文件)
lsz.1 18KB
lrz.1 13KB
ansi2knr.1 1KB
ansi2knr.1 1KB
ABOUT-NLS 11KB
Makefile.am 2KB
Makefile.am 2KB
Makefile.am 478B
Makefile.am 343B
Makefile.am 49B
AUTHORS 250B
fastcheck.beos 1KB
buildrpm 367B
lsz.c 59KB
lrz.c 54KB
getopt.c 22KB
strftime.c 20KB
zm.c 19KB
dcgettext.c 15KB
ansi2knr.c 15KB
ansi2knr.c 15KB
mktime.c 14KB
alloca.c 14KB
rbsb.c 11KB
cat-id-tbl.c 10KB
l10nflist.c 10KB
localealias.c 9KB
crctab.c 9KB
strtol.c 8KB
cat-compat.c 6KB
loadmsgcat.c 6KB
finddomain.c 5KB
bindtextdom.c 5KB
error.c 5KB
explodename.c 4KB
timing.c 4KB
getopt1.c 4KB
vasprintf.c 4KB
tcp.c 4KB
xstrtol.c 3KB
textdomain.c 3KB
zreadline.c 3KB
mkdir.c 3KB
zperr.c 2KB
long-options.c 2KB
lsyslog.c 2KB
gettext.c 2KB
dgettext.c 2KB
intl-compat.c 2KB
canit.c 1KB
strstr.c 1KB
strpbrk.c 1KB
strdup.c 1KB
beos-runpiped.c 1KB
stpcpy.c 1KB
protname.c 1KB
strerror.c 957B
strtoul.c 868B
xstrtoul.c 50B
ChangeLog 39KB
ChangeLog 32KB
ChangeLog 5KB
changelog 367B
COMPATABILITY 1KB
configure 140KB
control 316B
COPYING 18KB
copyright 1KB
README.cvs 647B
lrzsz.exp 8KB
crc.exp 7KB
manage.exp 3KB
newer.exp 3KB
command.exp 2KB
compatability.exp 2KB
zmodem.exp 1KB
timing.exp 669B
uppercase.exp 605B
path.exp 543B
zmodem-tcp.exp 444B
xmodem.exp 420B
window.exp 401B
zmodem-escape.exp 395B
ymodem.exp 277B
abuse.exp 266B
resume.exp 231B
unix.exp 223B
zmodem-crc16.exp 222B
README.gettext 2KB
de.gmo 13KB
config.guess 17KB
zglobal.h 12KB
zmodem.h 6KB
libgettext.h 6KB
getopt.h 4KB
gettext.h 3KB
error.h 2KB
acconfig.h 2KB
hash-string.h 2KB
gettextP.h 2KB
共 143 条
- 1
- 2
资源评论
- Katton2020-02-03很喜欢这,超赞。
- 躺着睡的蜗牛2018-03-09太复杂,还没来得及看懂 编译后是个dll文件,如果带可执行文件的话,理解起来可能更容易一些
zh281013996
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 5uonly.apk
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
- 基于MIC+NE555光敏电阻的声光控电路Multisim仿真原理图
- 基于JSP毕业设计-基于WEB操作系统课程教学网站的设计与实现(源代码+论文).zip
- 基于LM324和LM386的音响放大器Multisim仿真+PCB电路原理图
- Python机器学习与数据挖掘环境配置与库验证
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功