home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume19 / fbm / part01 / pbmtitle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-08  |  1.4 KB  |  53 lines

  1. /*****************************************************************
  2.  * pbmtitle.c: FBM Library 0.9 (Beta test) 07-Mar-89  Michael Mauldin
  3.  *
  4.  * Copyright (C) 1989 by Michael Mauldin.  Permission is granted to
  5.  * use this file in whole or in part provided that you do not sell it
  6.  * for profit and that this copyright notice is retained unchanged.
  7.  *
  8.  * pbmtitle.c: Add a title to a pbm bitmap
  9.  *
  10.  * USAGE
  11.  *    % pbmtitle [ flags ] arguments
  12.  *
  13.  * EDITLOG
  14.  *    LastEditDate = Tue Mar  7 19:57:46 1989 - Michael Mauldin
  15.  *    LastFileName = /usr2/mlm/src/misc/fbm/pbmtitle.c
  16.  *
  17.  * HISTORY
  18.  * 07-Mar-89  Michael Mauldin (mlm) at Carnegie Mellon University
  19.  *    Beta release (version 0.9) mlm@cs.cmu.edu
  20.  *
  21.  * 23-Sep-88  Michael Mauldin (mlm) at Carnegie-Mellon University
  22.  *    Created.
  23.  *****************************************************************/
  24.  
  25. # include <stdio.h>
  26.  
  27. # define USAGE "Usage: pbmtitle 'new title' < pbm > pbm"
  28.  
  29. #ifndef lint
  30. static char *fbmid =
  31.     "$FBM pbmtitle.c <0.9> 07-Mar-89  (C) 1989 by Michael Mauldin$";
  32. #endif
  33.  
  34. main (argc, argv)
  35. char *argv[];
  36. { char buf[BUFSIZ];
  37.   int lines=0;
  38.  
  39.   if (argc != 2 || argv[1][0] == '-')
  40.   { fprintf (stderr, "%s\n", USAGE);
  41.     exit (1);
  42.   }
  43.   
  44.   while (fgets (buf, BUFSIZ, stdin))
  45.   { if (buf[0] != '#') { printf ("%s", buf); lines++; }
  46.     else if (strncmp (buf, "# Title: ", 9)) printf ("%s", buf);
  47.     
  48.     if (lines == 2) printf ("# Title: %s\n", argv[1]);
  49.   }
  50.   
  51.   exit (0);
  52. }
  53.