Eric Andersen | cff3fe3 | 2000-09-20 19:22:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | Mini dos2unix implementation for busybox |
| 3 | |
| 4 | Copyright 1994,1995 Patrick Volkerding, Moorhead, Minnesota USA |
| 5 | All rights reserved. |
| 6 | |
| 7 | Redistribution and use of this source code, with or without modification, is |
| 8 | permitted provided that the following condition is met: |
| 9 | |
| 10 | 1. Redistributions of this source code must retain the above copyright |
| 11 | notice, this condition, and the following disclaimer. |
| 12 | |
| 13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 14 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 15 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 16 | EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 17 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 18 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 19 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 20 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 21 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 22 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 | */ |
| 24 | |
Eric Andersen | 3570a34 | 2000-09-25 21:45:58 +0000 | [diff] [blame] | 25 | #include "busybox.h" |
Eric Andersen | cff3fe3 | 2000-09-20 19:22:26 +0000 | [diff] [blame] | 26 | #include <stdio.h> |
Matt Kraai | ceade5c | 2001-01-29 18:41:12 +0000 | [diff] [blame^] | 27 | #include <stdlib.h> |
Eric Andersen | cff3fe3 | 2000-09-20 19:22:26 +0000 | [diff] [blame] | 28 | |
| 29 | int dos2unix_main( int argc, char **argv ) { |
| 30 | int c; |
| 31 | if (argc > 1) { |
| 32 | c = *argv[1]; |
| 33 | if (c == '-') { |
| 34 | usage(dos2unix_usage); |
| 35 | } |
| 36 | } |
| 37 | c = getchar(); |
| 38 | while (c != EOF) { |
| 39 | /* Eat any \r's... they shouldn't be here */ |
| 40 | while (c == '\r') c = getchar(); |
| 41 | if (c == EOF) break; |
| 42 | putchar(c); |
| 43 | c = getchar(); |
| 44 | } |
Matt Kraai | 3e856ce | 2000-12-01 02:55:13 +0000 | [diff] [blame] | 45 | return EXIT_SUCCESS; |
Eric Andersen | cff3fe3 | 2000-09-20 19:22:26 +0000 | [diff] [blame] | 46 | } |