home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / A / BASE / TODOS.TAR / todos / todos.c
Encoding:
C/C++ Source or Header  |  1994-12-27  |  1.9 KB  |  56 lines

  1. /*  Copyright 1994, Patrick Volkerding, Moorhead, Minnesota USA
  2.     All rights reserved.
  3.  
  4.  Redistribution and use of this source code, with or without modification, is
  5.  permitted provided that the following condition is met:
  6.  
  7.  1. Redistributions of this source code must retain the above copyright
  8.     notice, this condition, and the following disclaimer.
  9.  
  10.   THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  11.   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  12.   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  13.   EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  14.   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  15.   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  16.   OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  17.   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  18.   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  19.   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. */
  21.  
  22. #include <stdio.h>
  23.  
  24. int main( int argc, char **argv ) {
  25.      char *name, c;
  26.         name = argv[0];
  27.         if (rindex(name,'/') != NULL ) name = rindex(name,'/') + 1;
  28.     if (strcmp(name,"fromdos") && strcmp(name,"todos")) {
  29.         printf("This utility must be run as 'todos' or 'fromdos'\n");
  30.         exit(1);
  31.     }
  32.     if (!strcmp(argv[1],"-?")) {
  33.             if (!strcmp(name,"fromdos")) {
  34.              printf("Usage: fromdos < dostextfile > unixtextfile\n");
  35.             exit(1);
  36.             } else if (!strcmp(name,"todos")) {
  37.              printf("Usage: todos < unixtextfile > dostextfile\n");
  38.             exit(1);
  39.                 }
  40.     }
  41.         if (!strcmp(name,"fromdos")) {
  42.         c = getchar();
  43.         while (c != EOF) {
  44.             if (c != '\r') putchar(c);
  45.             c = getchar();
  46.         }
  47.     } else {
  48.         c = getchar();
  49.         while (c != EOF) {
  50.             if (c == '\n') putchar('\r');
  51.             putchar(c);
  52.             c = getchar();
  53.         }
  54.     }
  55. }
  56.