home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Zodiac Super OZ
/
MEDIADEPOT.ISO
/
FILES
/
16
/
FREEDOS.ZIP
/
FD_A4PRE.ZIP
/
SOURCE
/
MICROC.ZIP
/
MAN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-06-21
|
3KB
|
130 lines
/***********************************************************************
* This program displays the help pages for Free-DOS. It assumes the
* env. variables HELPATH and PAGER have been set. HELPPATH should not
* have a trailing backslash.
*
* Author: James Hall
*/
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <file.h> /* Declares FF_block, etc. */
#include "freedos.h" /* Free-DOS stuff */
#include "getopt.c" /* For getopt */
#include "pagef.c" /* File pager */
void usage (void);
int topics (char item[MAX_STR], char path[MAX_STR]);
main (int argc, char **argv)
{
int i;
char *buf, hPager[MAX_STR], hPath[MAX_STR], hItem[MAX_STR],
hDisplay[MAX_STR];
FILE *tempfile;
/* Scan the command line */
while ((i = getopt (argc, argv, NULL, NULL )) != EOF)
{
switch (i)
{
default:
usage ();
break;
}
}
if ((argc - optind) < 1)
{
strcpy (hItem, "\0");
topics (hItem, hPath);
}
/* Get the environment variables */
if (getenv ("HELPPATH", buf))
strcpy (hPath, buf);
else
strcpy (hPath, "C:\\FREEDOS\\HELP");
/* Display the Help pages */
for (i = optind; i < argc; i++)
{
strcpy (hItem, argv[i]);
strupr (hItem);
if (getenv ("PAGER", buf))
{
strcpy (hPager, buf);
sprintf (hDisplay, "%s %s\\%s.", hPager, hPath, hItem);
if (system (hDisplay))
topics (hItem, hPath);
}
else
{
sprintf (hDisplay, "%s\\%s.", hPath, hItem);
if ((tempfile = fopen (hDisplay, "r")) != NULL)
{
pagef (tempfile);
fclose (tempfile);
}
else
topics(hItem, hPath);
}
}
exit (0);
}
void usage (void)
{
printp ("MAN", "Displays the manual pages for Free-DOS commands");
printc ("1995", "James Hall and M. \"Hannibal\" Toal");
printu ("MAN", "[topic..]");
exit (1);
}
int topics (char item[MAX_STR], char path[MAX_STR])
{
struct FF_block fbp;
char *buf;
printf ("\n");
printf (MSG_NOHELP, item, path);
printf ("\n");
sprintf (buf, "%s\\*.", path);
if (!findfirst (buf, fbp, 0))
{
printf (MSG_TOPICS);
printf ("\n");
do
{
printf ("%-20s", fbp.FF_name);
}
while (!findnext (fbp));
printf ("\n");
}
else
printf (MSG_NOTOPICS);
exit (1);
}