ctm_rmail.c (6576) | ctm_rmail.c (6658) |
---|---|
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]; | 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 tname[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); | 217 char junk[2]; 218 219 ifp = stdin; 220 if (input_file != NULL && (ifp = fopen(input_file, "r")) == NULL) 221 { 222 err("cannot open '%s' for reading", input_file); 223 return 1; 224 } --- 12 unchanged lines hidden (view full) --- 237 if (sscanf(line, "CTM_MAIL BEGIN %s %d %d %c", 238 delta, &pce, &npieces, junk) != 3) 239 continue; 240 241 while ((s = strchr(delta, '/')) != NULL) 242 *s = '_'; 243 244 mk_piece_name(pname, delta, pce, npieces); |
244 if ((ofp = fopen(pname, "w")) == NULL) | 245 sprintf(tname,"tmp.%s",pname); 246 if ((ofp = fopen(tname, "w")) == NULL) |
245 { | 247 { |
246 err("cannot open '%s' for writing", pname); | 248 err("cannot open '%s' for writing", tname); |
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) | 249 status++; 250 continue; 251 } 252 253 cksum = 0xffff; 254 decoding++; 255 continue; 256 } --- 7 unchanged lines hidden (view full) --- 264 265 decoding = 0; 266 267 fflush(ofp); 268 e = ferror(ofp); 269 fclose(ofp); 270 271 if (e) |
270 err("error writing %s", pname); | 272 err("error writing %s", tname); |
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); | 273 274 if (cksum != claimed_cksum) 275 err("checksum: read %d, calculated %d", claimed_cksum, cksum); 276 277 if (e || cksum != claimed_cksum) 278 { 279 err("%s %d/%d discarded", delta, pce, npieces); |
278 unlink(pname); | 280 unlink(tname); |
279 status++; 280 continue; 281 } 282 | 281 status++; 282 continue; 283 } 284 |
285 if (rename(tname, pname) < 0) 286 { 287 err("error renaming %s to %s",tname,pname); 288 unlink(tname); 289 status++; 290 continue; 291 } 292 |
|
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 --- | 293 err("%s %d/%d stored", delta, pce, npieces); 294 295 if (!combine_if_complete(delta, pce, npieces)) 296 status++; 297 continue; 298 } 299 300 /* --- 202 unchanged lines hidden --- |