Deleted Added
full compact
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.

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

208 int i, n;
209 int pce, npieces;
210 unsigned claimed_cksum;
211 unsigned short cksum = 0;
212 char out_buf[200];
213 char line[200];
214 char delta[30];
215 char pname[1000];
216 char junk[2];
217
218 ifp = stdin;
219 if (input_file != NULL && (ifp = fopen(input_file, "r")) == NULL)
220 {
221 err("cannot open '%s' for reading", input_file);
222 return 1;
223 }

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

236 if (sscanf(line, "CTM_MAIL BEGIN %s %d %d %c",
237 delta, &pce, &npieces, junk) != 3)
238 continue;
239
240 while ((s = strchr(delta, '/')) != NULL)
241 *s = '_';
242
243 mk_piece_name(pname, delta, pce, npieces);
244 if ((ofp = fopen(pname, "w")) == NULL)
245 {
246 err("cannot open '%s' for writing", pname);
247 status++;
248 continue;
249 }
250
251 cksum = 0xffff;
252 decoding++;
253 continue;
254 }

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

262
263 decoding = 0;
264
265 fflush(ofp);
266 e = ferror(ofp);
267 fclose(ofp);
268
269 if (e)
270 err("error writing %s", pname);
271
272 if (cksum != claimed_cksum)
273 err("checksum: read %d, calculated %d", claimed_cksum, cksum);
274
275 if (e || cksum != claimed_cksum)
276 {
277 err("%s %d/%d discarded", delta, pce, npieces);
278 unlink(pname);
279 status++;
280 continue;
281 }
282
283 err("%s %d/%d stored", delta, pce, npieces);
284
285 if (!combine_if_complete(delta, pce, npieces))
286 status++;
287 continue;
288 }
289
290 /*

--- 202 unchanged lines hidden ---