home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / netpbma.zip / pnm / pnmfile.c < prev    next >
C/C++ Source or Header  |  1993-10-04  |  2KB  |  80 lines

  1. /* pnmfile.c - describe a portable anymap
  2. **
  3. ** Copyright (C) 1991 by Jef Poskanzer.
  4. **
  5. ** Permission to use, copy, modify, and distribute this software and its
  6. ** documentation for any purpose and without fee is hereby granted, provided
  7. ** that the above copyright notice appear in all copies and that both that
  8. ** copyright notice and this permission notice appear in supporting
  9. ** documentation.  This software is provided "as is" without express or
  10. ** implied warranty.
  11. */
  12.  
  13. #include "pnm.h"
  14.  
  15. static void describe_one ARGS(( char* name, FILE* file ));
  16.  
  17. int
  18. main( argc, argv )
  19.     int argc;
  20.     char* argv[];
  21.     {
  22.     int argn;
  23.     FILE* ifp;
  24.  
  25.     pnm_init( &argc, argv );
  26.  
  27.     if ( argc == 1 )
  28.     describe_one( "stdin", stdin );
  29.     else
  30.     {
  31.     for ( argn = 1; argn < argc; ++argn )
  32.         {
  33.         ifp = pm_openr( argv[argn] );
  34.         describe_one( argv[argn], ifp );
  35.         pm_close( ifp );
  36.         }
  37.     }
  38.  
  39.     exit( 0 );
  40.     }
  41.  
  42. static void
  43. describe_one( name, file )
  44.     char* name;
  45.     FILE* file;
  46.     {
  47.     xelval maxval;
  48.     int rows, cols, format;
  49.  
  50.     pnm_readpnminit( file, &cols, &rows, &maxval, &format );
  51.  
  52.     printf( "%s:\t", name );
  53.     switch ( format )
  54.     {
  55.     case PBM_FORMAT:
  56.     printf( "PBM plain, %d by %d\n", cols, rows );
  57.     break;
  58.  
  59.     case RPBM_FORMAT:
  60.     printf( "PBM raw, %d by %d\n", cols, rows );
  61.     break;
  62.  
  63.     case PGM_FORMAT:
  64.     printf( "PGM plain, %d by %d  maxval %d\n", cols, rows, maxval );
  65.     break;
  66.  
  67.     case RPGM_FORMAT:
  68.     printf( "PGM raw, %d by %d  maxval %d\n", cols, rows, maxval );
  69.     break;
  70.  
  71.     case PPM_FORMAT:
  72.     printf( "PPM plain, %d by %d  maxval %d\n", cols, rows, maxval );
  73.     break;
  74.  
  75.     case RPPM_FORMAT:
  76.     printf( "PPM raw, %d by %d  maxval %d\n", cols, rows, maxval );
  77.     break;
  78.     }
  79.     }
  80.