Deleted Added
full compact
ctm_smail.c (18110) ctm_smail.c (18120)
1/*
2 * Send a compressed CTM delta to a recipient mailing list by encoding it
3 * in safe ASCII characters, in mailer-friendly chunks, and passing it
4 * to sendmail. The encoding is almost the same as MIME BASE64, and is
5 * protected by a simple checksum.
6 *
7 * Author: Stephen McKay
8 *
9 * NOTICE: This is free software. I hope you get some use from this program.
10 * In return you should think about all the nice people who give away software.
11 * Maybe you should write some free software too.
12 *
1/*
2 * Send a compressed CTM delta to a recipient mailing list by encoding it
3 * in safe ASCII characters, in mailer-friendly chunks, and passing it
4 * to sendmail. The encoding is almost the same as MIME BASE64, and is
5 * protected by a simple checksum.
6 *
7 * Author: Stephen McKay
8 *
9 * NOTICE: This is free software. I hope you get some use from this program.
10 * In return you should think about all the nice people who give away software.
11 * Maybe you should write some free software too.
12 *
13 * $Id: ctm_smail.c,v 1.6 1996/07/01 20:54:11 gpalmer Exp $
13 * $Id: ctm_smail.c,v 1.7 1996/09/07 18:48:44 peter Exp $
14 */
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19#include <unistd.h>
20#include <fcntl.h>
21#include <sys/types.h>

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

99 {
100 int npieces;
101 long msg_size;
102 long exp_size;
103 int pce;
104 FILE *sfp;
105 FILE *dfp;
106 unsigned sum;
14 */
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19#include <unistd.h>
20#include <fcntl.h>
21#include <sys/types.h>

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

99 {
100 int npieces;
101 long msg_size;
102 long exp_size;
103 int pce;
104 FILE *sfp;
105 FILE *dfp;
106 unsigned sum;
107 char *deltaname;
107
108#ifdef howmany
109#undef howmany
110#endif
111
112#define howmany(x, y) (((x) + ((y) - 1)) / (y))
113
114 /*

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

125#undef howmany
126
127 if ((dfp = fopen(delta, "r")) == NULL)
128 {
129 err("cannot open '%s' for reading.", delta);
130 exit(1);
131 }
132
108
109#ifdef howmany
110#undef howmany
111#endif
112
113#define howmany(x, y) (((x) + ((y) - 1)) / (y))
114
115 /*

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

126#undef howmany
127
128 if ((dfp = fopen(delta, "r")) == NULL)
129 {
130 err("cannot open '%s' for reading.", delta);
131 exit(1);
132 }
133
134 deltaname = strrchr(delta, '/');
135 if (deltaname)
136 deltaname++; /* skip slash */
137 else
138 deltaname = delta;
139
133 for (pce = 1; pce <= npieces; pce++)
134 {
135 sfp = open_sendmail();
136 if (sfp == NULL)
137 exit(1);
138 write_header(sfp, mail_alias, delta, pce, npieces);
139 sum = encode_body(sfp, dfp, msg_size);
140 write_trailer(sfp, sum);
141 if (!close_sendmail(sfp))
142 exit(1);
140 for (pce = 1; pce <= npieces; pce++)
141 {
142 sfp = open_sendmail();
143 if (sfp == NULL)
144 exit(1);
145 write_header(sfp, mail_alias, delta, pce, npieces);
146 sum = encode_body(sfp, dfp, msg_size);
147 write_trailer(sfp, sum);
148 if (!close_sendmail(sfp))
149 exit(1);
143 err("%s %d/%d sent to %s", delta, pce, npieces, mail_alias);
150 err("%s %d/%d sent to %s", deltaname, pce, npieces, mail_alias);
144 }
145
146 fclose(dfp);
147 }
148
149/*
150 * Carve our CTM delta into pieces, encode them, and drop them in the
151 * queue dir.

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

573 if (stat(queuefile, &sb) == 0)
574 {
575 err("WOAH! Queue file `%s' already exists! Bailing out.", queuefile);
576 free_lock(lockf, queue_dir);
577 exit(1);
578 }
579
580 rename(tempnames[pce], queuefile);
151 }
152
153 fclose(dfp);
154 }
155
156/*
157 * Carve our CTM delta into pieces, encode them, and drop them in the
158 * queue dir.

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

580 if (stat(queuefile, &sb) == 0)
581 {
582 err("WOAH! Queue file `%s' already exists! Bailing out.", queuefile);
583 free_lock(lockf, queue_dir);
584 exit(1);
585 }
586
587 rename(tempnames[pce], queuefile);
581 err("Queue file %s now exists", queuefile);
582 }
583
584 free_lock(lockf, queue_dir);
585
586 free(queuefile);
587}
588 }
589
590 free_lock(lockf, queue_dir);
591
592 free(queuefile);
593}