blob: 222c8f6a45f696b44647cdcfb5868ff9bf923633 [file] [log] [blame]
Eric Andersencff3fe32000-09-20 19:22:26 +00001/*
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 Andersencff3fe32000-09-20 19:22:26 +000025#include <stdio.h>
Matt Kraaiceade5c2001-01-29 18:41:12 +000026#include <stdlib.h>
Eric Andersencbe31da2001-02-20 06:14:08 +000027#include "busybox.h"
Eric Andersencff3fe32000-09-20 19:22:26 +000028
29int dos2unix_main( int argc, char **argv ) {
30 int c;
31 if (argc > 1) {
32 c = *argv[1];
33 if (c == '-') {
Eric Andersen67991cf2001-02-14 21:23:06 +000034 show_usage();
Eric Andersencff3fe32000-09-20 19:22:26 +000035 }
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 Kraai3e856ce2000-12-01 02:55:13 +000045 return EXIT_SUCCESS;
Eric Andersencff3fe32000-09-20 19:22:26 +000046}