home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / duucp-1.17 / AU-117b4-src.lha / src / dmail / dmkhelp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-18  |  1.0 KB  |  56 lines

  1. /*
  2.  * DMKHELP.C
  3.  *
  4.  *  (C) Copyright 1985-1990 by Matthew Dillon,    All Rights Reserved.
  5.  *
  6.  *  Standalone C source.
  7.  *
  8.  *  Takes the file DMAIL.HELP (or that specified), and puts quotes and
  9.  *  commas around each line, the output to stdout.  Used by Makefile to
  10.  *  place the help file on line (by making it a static array).    See the
  11.  *  Makefile.
  12.  */
  13.  
  14. #include <stdio.h>
  15. #include <string.h>
  16. #include "dmail.h"
  17.  
  18. #define HELPC "dmail.help"
  19.  
  20. static char buf[1024];
  21.  
  22. int
  23. main (int argc, char **argv)
  24. {
  25.     FILE *fi;
  26.     char *ptr;
  27.     int len;
  28.     register int i;
  29.  
  30.     if (argc == 1)
  31.     fi = fopen (HELPC, "r");
  32.     else
  33.     fi = fopen (argv[1], "r");
  34.     if (fi == NULL) {
  35.     fprintf (stderr, "CANNOT OPEN %s\n", argc == 1 ? HELPC : argv [1]);
  36.     exit (30);
  37.     }
  38.     while (fgets (buf, 1024, fi)) {
  39.     len = strlen(buf) - 1;
  40.     buf[len] = '\0';
  41.     putchar ('\"');
  42.     for (i = 0; i < len; ++i) {
  43.         if (buf[i] == '\"') {
  44.         putchar ('\\');
  45.         putchar ('\"');
  46.         } else {
  47.         putchar (buf[i]);
  48.         }
  49.     }
  50.     puts ("\",");
  51.     }
  52.     puts ("NULL");
  53.     fclose (fi);
  54.     exit (0);
  55. }
  56.