home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / telecom / uucp_442 / src / dmail / help.c < prev    next >
C/C++ Source or Header  |  1990-10-08  |  3KB  |  149 lines

  1.  
  2. /*
  3.  * HELP.C
  4.  *
  5.  *  $Header: Beta:src/uucp/src/dmail/RCS/help.c,v 1.1 90/02/02 12:04:12 dillon Exp Locker: dillon $
  6.  *
  7.  *  (C) Copyright 1985-1990 by Matthew Dillon,  All Rights Reserved.
  8.  *
  9.  *  Global Routines:    DO_HELP()
  10.  *
  11.  */
  12.  
  13. #include <stdio.h>
  14. #include "dmail.h"
  15. #include "execom.h"
  16. #include "config.h"
  17.  
  18. #ifdef AMIGA
  19. #define HELPFILE "dmail.help"
  20. #endif
  21.  
  22. #ifndef HELPFILE
  23. static char *help[] = {
  24. #include ".dmkout"
  25. };
  26.  
  27. do_help()
  28. {
  29.     int i, j;
  30.     char *ptr;
  31.  
  32.     if (push_base()) {
  33.     push_break();
  34.     pop_base();
  35.     PAGER (-1);
  36.     pop_break();
  37.     return;
  38.     }
  39.     PAGER (0);
  40.     if (ac == 1) {
  41.     for (j = 0; help[j] && *help[j] != '.'; ++j)
  42.         PAGER (help[j]);
  43.     for (i = 0; Command[i].name != NULL; ++i) {
  44.         if (*Command[i].name && !(Command[i].stat & C_NO)) {
  45.         if (Desc[i] == NULL)
  46.             puts("Software error, premature EOF in description table");
  47.         sprintf (Puf, "%-10s %s", Command[i].name, Desc[i]);
  48.         PAGER (Puf);
  49.         }
  50.     }
  51.     }
  52.     PAGER ("");
  53.     for (i = 1; i < ac; ++i) {
  54.     j = 0;
  55. again:
  56.     while (help[j]  &&  *help[j] != '.')
  57.         ++j;
  58.     if (help[j]) {
  59.         if (strncmp (av[i], help[j] + 1, strlen(av[i]))) {
  60.         ++j;
  61.         goto again;
  62.         }
  63.         while (help[j]  &&  *help[j] == '.')
  64.         ++j;
  65.         while (help[j]  &&  *help[j] != '.')
  66.         PAGER (help[j++]);
  67.         PAGER ("");
  68.         goto again;
  69.     }
  70.     }
  71.     PAGER (-1);
  72.     pop_base();
  73. }
  74.  
  75. #else
  76.  
  77. do_help()
  78. {
  79.     int i;
  80.     FILE *fi = NULL;
  81.     char *eof;
  82.  
  83.     if (push_base()) {
  84.     push_break();
  85.     pop_base();
  86.     PAGER (-1);
  87.     if (fi != NULL) {
  88.         fclose (fi);
  89.         fi = NULL;
  90.     }
  91.     pop_break();
  92.     return (-1);
  93.     }
  94. #ifdef AMIGA
  95.     fi = fopen (MakeConfigPath(UUMAN, HELPFILE), "r");
  96. #else
  97.     fi = fopen (HELPFILE, "r");
  98. #endif
  99.     if (fi == NULL) {
  100.     printf ("Cannot open help file: %s\n", HELPFILE);
  101.     PAGER (-1);
  102.     pop_base();
  103.     return (-1);
  104.     }
  105.     PAGER (0);
  106.     if (ac == 1) {
  107.     while (fgets (Puf, MAXFIELDSIZE, fi)  &&  *Puf != '.')
  108.         FPAGER (Puf);
  109.     fclose (fi);
  110.     fi = NULL;
  111.     for (i = 0; Command[i].name != NULL; ++i) {
  112.         if (*Command[i].name) {
  113.         sprintf (Puf, "%-10s %s", Command[i].name, Desc[i]);
  114.         PAGER (Puf);
  115.         }
  116.     }
  117.     PAGER (-1);
  118.     pop_base();
  119.     return (1);
  120.     }
  121.     PAGER ("");
  122.     for (i = 1; i < ac; ++i) {
  123.     fseek (fi, 0, 0);
  124. again:
  125.     while ((eof = fgets (Puf, MAXFIELDSIZE, fi))  &&  *Puf != '.');
  126.     if (!eof)
  127.         continue;
  128.     if (strncmp (av[i], Puf + 1, strlen(av[i])))
  129.         goto again;
  130.     while ((eof = fgets (Puf, MAXFIELDSIZE, fi))  &&  *Puf == '.');
  131.     if (!eof)
  132.         continue;
  133.     FPAGER (Puf);
  134.     while ((eof = fgets (Puf, MAXFIELDSIZE, fi))  &&  *Puf != '.')
  135.         FPAGER (Puf);
  136.     PAGER ("");
  137.     if (!eof)
  138.         continue;
  139.     goto again;
  140.     }
  141.     fclose (fi);
  142.     fi = NULL;
  143.     PAGER (-1);
  144.     pop_base();
  145. }
  146.  
  147. #endif
  148.  
  149.