Fixed EOF detection for encrypted packets.
[gnupg.git] / tools / crlf.c
blobecb6eecdba5ed94d2eb31fb13f2e97647056e9d3
1 /* crlf.c
2 * Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
4 * This file is free software; as a special exception the author gives
5 * unlimited permission to copy and/or distribute it, with or without
6 * modifications, as long as this notice is preserved.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 #include <stdio.h>
15 int
16 main(int argc, char **argv)
18 int c, lc;
19 int off=0;
21 if( argc > 1 ) {
22 fprintf(stderr, "no arguments, please\n");
23 return 1;
26 lc = -1;
27 while( (c=getchar()) != EOF ) {
28 #if 0
29 if( c == '\r' && lc == ' ' )
30 fprintf(stderr,"SP,CR at %d\n", off );
31 if( c == '\n' && lc == ' ' )
32 fprintf(stderr,"SP,LF at %d\n", off );
33 #endif
34 if( c == '\n' && lc == '\r' )
35 putchar(c);
36 else if( c == '\n' ) {
37 putchar('\r');
38 putchar(c);
40 else if( c != '\n' && lc == '\r' ) {
41 putchar('\n');
42 putchar(c);
44 else
45 putchar(c);
47 lc = c;
48 off++;
51 return 0;