From 3b11b18c588f59757c9cdb863cf969f0b8594c95 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 10 Feb 1995 05:25:00 +0000 Subject: Clean up some details, to make it clear to gcc that we do not try to do something stupid. --- usr.sbin/ctm/ctm_rmail/ctm_rmail.c | 41 ++++++++++++++++++++++---------------- usr.sbin/ctm/ctm_rmail/options.h | 1 - usr.sbin/ctm/ctm_smail/ctm_smail.c | 3 ++- 3 files changed, 26 insertions(+), 19 deletions(-) (limited to 'usr.sbin/ctm') diff --git a/usr.sbin/ctm/ctm_rmail/ctm_rmail.c b/usr.sbin/ctm/ctm_rmail/ctm_rmail.c index 859b0ed..e4be5a4 100644 --- a/usr.sbin/ctm/ctm_rmail/ctm_rmail.c +++ b/usr.sbin/ctm/ctm_rmail/ctm_rmail.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -46,6 +47,8 @@ int decode_line(char *line, char *out_buf); * reflected in the exit status. In this case, the delta is left in * 'deltadir'. */ + +int main(int argc, char **argv) { char *log_file = NULL; @@ -61,7 +64,10 @@ main(int argc, char **argv) STRING('l', log_file) ENDOPTS - if (delta_dir == NULL || piece_dir == NULL && (base_dir == NULL || argc>1)) + if (delta_dir == NULL) + usage(); + + if (piece_dir == NULL && (base_dir == NULL || argc>1)) usage(); if (log_file != NULL) @@ -197,13 +203,13 @@ int read_piece(char *input_file) { int status = 0; - FILE *ifp, *ofp; + FILE *ifp, *ofp = 0; int decoding = 0; int line_no = 0; int i, n; int pce, npieces; unsigned claimed_cksum; - unsigned short cksum; + unsigned short cksum = 0; char out_buf[200]; char line[200]; char delta[30]; @@ -226,24 +232,25 @@ read_piece(char *input_file) */ if (!decoding) { - if (sscanf(line, "CTM_MAIL BEGIN %s %d %d %c", delta, &pce, &npieces, junk) == 3) - { - char *s; + char *s; - while ((s = strchr(delta, '/')) != NULL) - *s = '_'; + if (sscanf(line, "CTM_MAIL BEGIN %s %d %d %c", + delta, &pce, &npieces, junk) != 3) + continue; - mk_piece_name(pname, delta, pce, npieces); - if ((ofp = fopen(pname, "w")) == NULL) - { - err("cannot open '%s' for writing", pname); - status++; - continue; - } + while ((s = strchr(delta, '/')) != NULL) + *s = '_'; - cksum = 0xffff; - decoding++; + mk_piece_name(pname, delta, pce, npieces); + if ((ofp = fopen(pname, "w")) == NULL) + { + err("cannot open '%s' for writing", pname); + status++; + continue; } + + cksum = 0xffff; + decoding++; continue; } diff --git a/usr.sbin/ctm/ctm_rmail/options.h b/usr.sbin/ctm/ctm_rmail/options.h index 829a913..2106199 100644 --- a/usr.sbin/ctm/ctm_rmail/options.h +++ b/usr.sbin/ctm/ctm_rmail/options.h @@ -134,6 +134,5 @@ pusage() usage(); \ } \ } \ -O_end: \ *--argv = O_name; \ } diff --git a/usr.sbin/ctm/ctm_smail/ctm_smail.c b/usr.sbin/ctm/ctm_smail/ctm_smail.c index b0379a2..28fd8d9 100644 --- a/usr.sbin/ctm/ctm_smail/ctm_smail.c +++ b/usr.sbin/ctm/ctm_smail/ctm_smail.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -35,7 +36,7 @@ void apologise(char *delta, off_t ctm_size, long max_ctm_size, FILE *open_sendmail(void); int close_sendmail(FILE *fp); - +int main(int argc, char **argv) { char *delta_file; -- cgit v1.1