home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 32 / hot34.iso / ficheros / DUTI / CASES002.ZIP / UCASE.C < prev    next >
C/C++ Source or Header  |  1998-04-01  |  2KB  |  68 lines

  1. //<c>   Copyright 1995-1998 by Gerry J. Danen; all rights reserved.
  2.  
  3. //<t>   Convert to all uppercase
  4. //
  5. //              Usage:  UCASE file_in file_out
  6. //
  7. //      Full pathnames are supported for the filenames.
  8. //
  9. #include"gd_tools.h"
  10.  
  11.  
  12. #define pgVERS_ "V1.10"
  13. #define pgTITL_ "Convert to All Uppercase"
  14. #define pgCOPR_ "1995"
  15.  
  16.  
  17. #define BUFSIZE 10000
  18. UCHAR   iFile[FS_LEN], oFile[FS_LEN], work[BUFSIZE+2], *w ;
  19. long    lines = 0 ;
  20. FILE    *iFh, *oFh ;
  21.  
  22.  
  23. void    show_help_and_quit( void )
  24. {
  25.     logon(1);
  26.     fprintf( stderr,
  27.              "\nThis program converts a file to all uppercase characters\n\n"
  28.              "\tUsage:  %s file_in file_out\n\n", get_global_program_name() );
  29.     exit( GD_ERROR_HELP );
  30. }
  31.  
  32.  
  33. void    main( int argc, char *argv[] )
  34. {
  35.     tt_init( SHAREWARE_VERSION, 0, pgVERS_, pgTITL_, pgCOPR_ );
  36.     logon(0);
  37.  
  38.     if ( argc != 3 )
  39.         show_help_and_quit();
  40.  
  41.     st_cpy( iFile, (UCHAR *) argv[1], FS_LEN );
  42.     st_cpy( oFile, (UCHAR *) argv[2], FS_LEN );
  43.     strupr( (char *) iFile );
  44.     strupr( (char *) oFile );
  45.  
  46.     if ( ( iFh = fopen( iFile, "r" ) ) == NULL )
  47.     {
  48.         logon(1);
  49.         fprintf( stderr, "\n\nFile %s not found\a\n", iFile );
  50.         show_help_and_quit();
  51.     }
  52.  
  53.     oFh = fl_create_or_replace_tty( oFh, oFile, "w", YES, YES );
  54.  
  55.     fprintf( stderr, "%s: reading %s ...", get_global_program_name(), iFile );
  56.  
  57.     while ( (w = fgets( work, BUFSIZE, iFh )) )
  58.     {
  59.         strupr( work );
  60.         fprintf( oFh, "%s", work );
  61.         lines ++ ;
  62.     }
  63.     _fcloseall();
  64.     fprintf( stderr, " %ld lines\n", lines );
  65.  
  66.     exit( GD_ERROR_NONE );
  67. }
  68.