# include "basic.h"

int help (int argc, char **argv) {

  FILE *f;
  char *helpdir, file[1024], buff[512];

  helpdir = get_variable ("HELPDIR");
  if (helpdir == (char *) NULL) {
    fprintf (stderr, "variable HELPDIR not found\n");
    return (FALSE);
  }

  if (argc == 1) {
    sprintf (buff, "ls %s", helpdir);
    system (buff);
    return (TRUE);
  }

  sprintf (file, "%s/%s", helpdir, argv[1]);

  f = fopen (file, "r");
  if (f == NULL) {
    fprintf (stderr, "No help for: %s\n", argv[1]);
    return (FALSE);
  }

  while (scan_line (f, buff) != EOF)
    fprintf (stdout, "%s\n", buff);

  fclose (f);
  return (TRUE);
}

