home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 10
/
Fresh_Fish_10_2352.bin
/
fishdisks
/
d1053.lha
/
Programs
/
Man
/
Man.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-03-05
|
25KB
|
991 lines
/*
Auto: sc <file>
*/
/* $Revision Header built automatically *************** (do not edit) ************
**
** © Copyright by GuntherSoft
**
** File : SnakeSYS:CPrgs/Utils/Man.c
** Created on : Friday, 16.07.93 18:00:23
** Created by : Kai Iske
** Current revision : V1.11
**
**
** Purpose
** -------
** - This is a man program, which may scan different directories
** for man-pages. These directories are set within an ENV-VAR
** called MANPATHS. Additionally a VIEWER may be set using
** ENV-VAR MANVIEW (for plain ASCII) or MANVIEWAG (for
** AMIGAGUIDE). THIS ONE`S PURE AND IN THE PUBLIC DOMAIN
**
** Revision V1.11
** --------------
** created on Monday, 28.02.94 19:33:29 by Kai Iske. LogMessage :
** -*- changed on Saturday, 05.03.94 02:30:54 by Kai Iske. LogMessage :
** - Man produced an enforcer hit when no manpage was supplied
** (Reported by : Michael van Elst)
** -*- changed on Monday, 28.02.94 20:03:34 by Kai Iske. LogMessage :
** - Man will no longer issue an error if you a) didn`t specify a
** manpage and b) set the MANGETFILE attribute for the File
** Requester. This way the Requester will popup if you
** call MAN without any arguments
** (Requested by : Bill Hogsett)
** -*- changed on Monday, 28.02.94 20:02:39 by Kai Iske. LogMessage :
** - The FileRequester will pop up on the default PubScreen now
** (Requested by : Bill Hogsett)
** - The default path for the FileRequester will be set to the
** first Dir of the MANPATHS now
** (Requested by : Bill Hogsett)
** -*- created on Monday, 28.02.94 19:33:29 by Kai Iske. LogMessage :
** - Support for DVI files added
** - MAN will set the Viewer`s current dir of that where the
** man page resides in
**
** Revision V1.10
** --------------
** created on Tuesday, 25.01.94 14:41:58 by Kai Iske. LogMessage :
** - Mike Barsoom added MANBASENAME attribute for stripping
** off any path names from the manpage name. Useful when
** launching MAN from within (ie) ToolsDaemon
** (Submitted by : Mike Barsoom)
**
** Revision V1.9
** --------------
** created on Sunday, 23.01.94 21:36:26 by Kai Iske. LogMessage :
** - Recompiled using SAS/C 6.51
** - Added MANGETFILE parameter
** (Requested by : Bill Hogsett)
**
** Revision V1.8
** --------------
** created on Saturday, 15.01.94 01:14:17 by Kai Iske. LogMessage :
** - Man now correctly handles multi-assigns, since ExAll
** doesn`t....;)
** (Reported by : Jan Hoeydahl)
**
** Revision V1.7
** --------------
** created on Friday, 31.12.93 14:00:28 by Kai Iske. LogMessage :
** - All config variables have been moved to a single one,
** which will be parsed just like a CommandLine
** (Suggested by : Michael 'Mick' Hohmann)
**
** Revision V1.6
** --------------
** created on Thursday, 16.12.93 16:49:51 by Kai Iske. LogMessage :
** - Added MANRMEXT, MANAGEXT and MANNOVIEW options,
** which may be used for extensibility of MAN
** (Somehow suggested by : Michael 'Mick' Hohmann)
**
** Revision V1.5
** --------------
** created on Thursday, 09.12.93 00:58:47 by Kai Iske. LogMessage :
** - Referenced free memory area
**
** Revision V1.4
** --------------
** created on Wednesday, 08.12.93 22:07:47 by Kai Iske. LogMessage :
** -*- created on Wednesday, 08.12.93 22:07:47 by Kai Iske. LogMessage :
** - DOS-Library wasn`t closed
**
** Revision V1.3
** --------------
** created on Wednesday, 08.12.93 19:26:17 by Kai Iske. LogMessage :
** -*- changed on Wednesday, 08.12.93 19:31:23 by Kai Iske. LogMessage :
** - Added CTRL-C checking
** -*- created on Wednesday, 08.12.93 19:26:17 by Kai Iske. LogMessage :
** - Recompiled using SAS 6.50
** - Reduced stack usage
** - Reduced executable size
**
** Revision V1.2
** --------------
** created on Tuesday, 27.07.93 15:20:51 by Kai Iske. LogMessage :
** - Used MAN as a keyword for the template which prevented MAN
** to accept inputs like "man man".
**
** Revision V1.1
** --------------
** created on Monday, 26.07.93 17:42:32 by Kai Iske. LogMessage :
** - Accidentially called Exit() instead of exit(), which
** prevented the program to pass the cleanup code of SAS.
** So a lock to the directory was kept and the shell could
** never been left.............
**
** Revision V1.0
** --------------
** created on Friday, 16.07.93 18:00:23 by Kai Iske. LogMessage :
** -*- changed on Saturday, 17.07.93 16:30:41 by Kai Iske. LogMessage :
** - Man now searches for files that end up with .doc/.man/.guide
** If a .guide file is found, the second Viewer (MANVIEWAG)
** will be used to display the AmigaGuide viewer. Otherwise
** the normal viewer (MANVIEW) will be used
** -*- created on Friday, 16.07.93 18:00:23 by Kai Iske. LogMessage :
** --- Initial release ---
**
*********************************************************************************/
#define REVISION "1.11a"
#define REVDATE "05.03.94"
#define REVTIME "02:30:54"
#define AUTHOR "Kai Iske"
#define VERNUM 1
#define REVNUM 11
#define _USE_SYSBASE
/**********************************************************************/
/* This is, so that the code references our Libraries */
/* stored in our structure */
/**********************************************************************/
#define DOSBase MC->mc_DOSBase
#define UtilityBase MC->mc_UtilityBase
#include <string.h>
#include <stdlib.h>
#include <exec/types.h>
#include <exec/memory.h>
#include <exec/execbase.h>
#include <libraries/asl.h>
#include <dos/dos.h>
#include <dos/exall.h>
#include <dos/dostags.h>
#include <proto/exec.h>
#include <proto/asl.h>
#include <clib/dos_protos.h>
#include <clib/utility_protos.h>
#include <pragmas/dos_pragmas.h>
#include <pragmas/utility_pragmas.h>
/**********************************************************************/
/* This is the private structure for all vars */
/**********************************************************************/
struct ManControl
{
struct DOSLibrary *mc_DOSBase;
struct Library *mc_UtilityBase;
struct ExAllControl *mc_EAC;
char mc_ManOpt[1536],
mc_ManPaths[1024],
mc_ViewCmd[1024],
mc_ViewCmdAG[1024],
mc_ViewCmdDVI[1024],
mc_CheckDir[1024],
mc_SearchName[1536],
mc_FileName[1024],
mc_Pattern[3074],
mc_NormExt[1024],
mc_AGExt[1024],
mc_DVIExt[1024],
mc_NameBuffer[1024],
mc_NonExt[1024];
APTR *mc_EAB;
BPTR mc_OutHandle;
BOOL mc_Found,
mc_Breaked;
};
/**********************************************************************/
/* Prototypes */
/**********************************************************************/
static char *GetDir(char *NewName, char *OldName);
static BOOL DoCheckDir(struct ManControl *MC);
static BOOL IsAssign(struct ManControl *MC);
static void DetermineFileType(struct ManControl *MC);
/**********************************************************************/
/* Version-String */
/**********************************************************************/
static const char *Version = "$VER: Man "REVISION" ("REVDATE")\0";
/**********************************************************************/
/* Template for Command-Line parsing */
/**********************************************************************/
static const char *Template = "MANPAGE";
enum {MAN_ARG, TMP_LAST_ARG};
/**********************************************************************/
/* Template for MANOPT settings */
/**********************************************************************/
static const char *ManTemplate = "MANPATHS/K/A,MANVIEW/K/A,MANVIEWAG/K/A,MANVIEWDVI/K/A,MANNRMEXT/K,MANAGEXT/K,MANDVIEXT/K,MANNOVIEW/K,MANGETFILE/S,MANBASENAME/S";
enum {MANPATHS_ARG, MANVIEW_ARG, MANVIEWAG_ARG, MANVIEWDVI_ARG, MANNRMEXT_ARG, MANAGEXT_ARG, MANDVIEXT_ARG, M