Deleted Added
full compact
ctm_rmail.c (76300) ctm_rmail.c (89675)
1/*
2 * Accept one (or more) ASCII encoded chunks that together make a compressed
3 * CTM delta. Decode them and reconstruct the deltas. Any completed
4 * deltas may be passed to ctm for unpacking.
5 *
6 * Author: Stephen McKay
7 *
8 * NOTICE: This is free software. I hope you get some use from this program.
9 * In return you should think about all the nice people who give away software.
10 * Maybe you should write some free software too.
11 *
1/*
2 * Accept one (or more) ASCII encoded chunks that together make a compressed
3 * CTM delta. Decode them and reconstruct the deltas. Any completed
4 * deltas may be passed to ctm for unpacking.
5 *
6 * Author: Stephen McKay
7 *
8 * NOTICE: This is free software. I hope you get some use from this program.
9 * In return you should think about all the nice people who give away software.
10 * Maybe you should write some free software too.
11 *
12 * $FreeBSD: head/usr.sbin/ctm/ctm_rmail/ctm_rmail.c 76300 2001-05-06 03:03:45Z kris $
12 * $FreeBSD: head/usr.sbin/ctm/ctm_rmail/ctm_rmail.c 89675 2002-01-22 22:54:52Z iedowse $
13 */
14
15#include <stdio.h>
16#include <stdlib.h>
17#include <string.h>
18#include <ctype.h>
19#include <errno.h>
20#include <unistd.h>

--- 7 unchanged lines hidden (view full) ---

28#define CTM_STATUS ".ctm_status"
29
30char *piece_dir = NULL; /* Where to store pieces of deltas. */
31char *delta_dir = NULL; /* Where to store completed deltas. */
32char *base_dir = NULL; /* The tree to apply deltas to. */
33int delete_after = 0; /* Delete deltas after ctm applies them. */
34int apply_verbose = 0; /* Run with '-v' */
35int set_time = 0; /* Set the time of the files that is changed. */
13 */
14
15#include <stdio.h>
16#include <stdlib.h>
17#include <string.h>
18#include <ctype.h>
19#include <errno.h>
20#include <unistd.h>

--- 7 unchanged lines hidden (view full) ---

28#define CTM_STATUS ".ctm_status"
29
30char *piece_dir = NULL; /* Where to store pieces of deltas. */
31char *delta_dir = NULL; /* Where to store completed deltas. */
32char *base_dir = NULL; /* The tree to apply deltas to. */
33int delete_after = 0; /* Delete deltas after ctm applies them. */
34int apply_verbose = 0; /* Run with '-v' */
35int set_time = 0; /* Set the time of the files that is changed. */
36int mask = 0; /* The current umask */
36
37void apply_complete(void);
38int read_piece(char *input_file);
39int combine_if_complete(char *delta, int pce, int npieces);
40int combine(char *delta, int npieces, char *dname, char *pname, char *tname);
41int decode_line(char *line, char *out_buf);
42int lock_file(char *name);
43

--- 13 unchanged lines hidden (view full) ---

57 */
58int
59main(int argc, char **argv)
60 {
61 char *log_file = NULL;
62 int status = 0;
63 int fork_ctm = 0;
64
37
38void apply_complete(void);
39int read_piece(char *input_file);
40int combine_if_complete(char *delta, int pce, int npieces);
41int combine(char *delta, int npieces, char *dname, char *pname, char *tname);
42int decode_line(char *line, char *out_buf);
43int lock_file(char *name);
44

--- 13 unchanged lines hidden (view full) ---

58 */
59int
60main(int argc, char **argv)
61 {
62 char *log_file = NULL;
63 int status = 0;
64 int fork_ctm = 0;
65
66 mask = umask(0);
67 umask(mask);
68
65 err_prog_name(argv[0]);
66
67 OPTIONS("[-Dfuv] [-p piecedir] [-d deltadir] [-b basedir] [-l log] [file ...]")
68 FLAG('D', delete_after)
69 FLAG('f', fork_ctm)
70 FLAG('u', set_time)
71 FLAG('v', apply_verbose)
72 STRING('p', piece_dir)

--- 366 unchanged lines hidden (view full) ---

439 * We can probably just rename() it into place if it is a small delta.
440 */
441 if (npieces == 1)
442 {
443 mk_delta_name(dname, delta);
444 mk_piece_name(pname, delta, 1, 1);
445 if (rename(pname, dname) == 0)
446 {
69 err_prog_name(argv[0]);
70
71 OPTIONS("[-Dfuv] [-p piecedir] [-d deltadir] [-b basedir] [-l log] [file ...]")
72 FLAG('D', delete_after)
73 FLAG('f', fork_ctm)
74 FLAG('u', set_time)
75 FLAG('v', apply_verbose)
76 STRING('p', piece_dir)

--- 366 unchanged lines hidden (view full) ---

443 * We can probably just rename() it into place if it is a small delta.
444 */
445 if (npieces == 1)
446 {
447 mk_delta_name(dname, delta);
448 mk_piece_name(pname, delta, 1, 1);
449 if (rename(pname, dname) == 0)
450 {
451 chmod(dname, 0666 & ~mask);
447 err("%s complete", delta);
448 return 1;
449 }
450 }
451
452 /*
453 * Grab a lock on the reassembly mutex file so that we can be sure we are
454 * working alone, not fighting another ctm_rmail!

--- 95 unchanged lines hidden (view full) ---

550
551 mk_delta_name(dname, delta);
552 if (rename(tname, dname) < 0)
553 {
554 err("*rename: '%s' to '%s'", tname, dname);
555 unlink(tname);
556 return 0;
557 }
452 err("%s complete", delta);
453 return 1;
454 }
455 }
456
457 /*
458 * Grab a lock on the reassembly mutex file so that we can be sure we are
459 * working alone, not fighting another ctm_rmail!

--- 95 unchanged lines hidden (view full) ---

555
556 mk_delta_name(dname, delta);
557 if (rename(tname, dname) < 0)
558 {
559 err("*rename: '%s' to '%s'", tname, dname);
560 unlink(tname);
561 return 0;
562 }
563 chmod(dname, 0666 & ~mask);
558
559 /*
560 * Throw the pieces away.
561 */
562 for (i = 1; i <= npieces; i++)
563 {
564 mk_piece_name(pname, delta, i, npieces);
565 if (unlink(pname) < 0)

--- 101 unchanged lines hidden ---
564
565 /*
566 * Throw the pieces away.
567 */
568 for (i = 1; i <= npieces; i++)
569 {
570 mk_piece_name(pname, delta, i, npieces);
571 if (unlink(pname) < 0)

--- 101 unchanged lines hidden ---