comparison lib-src/mmencode.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents a5df635868b2
children b39c14581166
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
383 if (!*++s) break; 383 if (!*++s) break;
384 c2 = hexchar(*s); 384 c2 = hexchar(*s);
385 putc(c1<<4 | c2, outfile); 385 putc(c1<<4 | c2, outfile);
386 } 386 }
387 } else { 387 } else {
388 #ifdef MSDOS 388 #ifdef WIN32_NATIVE
389 if (*s == '\n') 389 if (*s == '\n')
390 putc('\r', outfile); /* insert CR for binary-mode write */ 390 putc('\r', outfile); /* insert CR for binary-mode write */
391 #endif 391 #endif
392 putc(*s, outfile); 392 putc(*s, outfile);
393 } 393 }
440 of an authorized representative of Bellcore. BELLCORE 440 of an authorized representative of Bellcore. BELLCORE
441 MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 441 MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
442 OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS", 442 OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS",
443 WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. 443 WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
444 */ 444 */
445 #ifdef MSDOS 445 #ifdef WIN32_NATIVE
446 #include <io.h>
446 #include <fcntl.h> 447 #include <fcntl.h>
447 #endif 448 #endif
448 449
449 #define BASE64 1 450 #define BASE64 1
450 #define QP 2 /* quoted-printable */ 451 #define QP 2 /* quoted-printable */
485 fprintf(stderr, 486 fprintf(stderr,
486 "Usage: mmencode [-u] [-q] [-b] [-p] [-o outputfile] [file name]\n"); 487 "Usage: mmencode [-u] [-q] [-b] [-p] [-o outputfile] [file name]\n");
487 exit(-1); 488 exit(-1);
488 } 489 }
489 } else { 490 } else {
490 #ifdef MSDOS 491 #ifdef WIN32_NATIVE
491 if (encode) 492 if (encode)
492 fp = fopen(argv[i], "rb"); 493 fp = fopen(argv[i], "rb");
493 else 494 else
494 { 495 {
495 fp = fopen(argv[i], "rt"); 496 fp = fopen(argv[i], "rt");
496 setmode(fileno(fpo), O_BINARY); 497 setmode(fileno(fpo), O_BINARY);
497 } /* else */ 498 } /* else */
498 #else 499 #else
499 fp = fopen(argv[i], "r"); 500 fp = fopen(argv[i], "r");
500 #endif /* MSDOS */ 501 #endif /* WIN32_NATIVE */
501 if (!fp) { 502 if (!fp) {
502 perror(argv[i]); 503 perror(argv[i]);
503 exit(-1); 504 exit(-1);
504 } 505 }
505 } 506 }
506 } 507 }
507 #ifdef MSDOS 508 #ifdef WIN32_NATIVE
508 if (fp == stdin) setmode(fileno(fp), O_BINARY); 509 if (fp == stdin) setmode(fileno(fp), O_BINARY);
509 #endif /* MSDOS */ 510 #endif /* WIN32_NATIVE */
510 if (which == BASE64) { 511 if (which == BASE64) {
511 if (encode) { 512 if (encode) {
512 to64(fp, fpo, portablenewlines); 513 to64(fp, fpo, portablenewlines);
513 } else { 514 } else {
514 from64(fp,fpo, (char **) NULL, (int *) 0, portablenewlines); 515 from64(fp,fpo, (char **) NULL, (int *) 0, portablenewlines);