/******************************************************************************

	ZHelp()

	This function accepts a help string and displays the corresponding
help text.

	it should be control-C interrupt-able.

*****************************************************************************/

#include "ZPort.h"		/* define portability identifiers */
#include "DefTeco.h"		/* define general identifiers */

EXTERN	BOOLEAN	GotCtC;		/* YES if a control-C was just typed */



#ifdef UNKNOWN
VOID ZHelp(HlpBeg, HlpEnd, SysLib, Prompt)
char *HlpBeg;			/* first char of help request */
char *HlpEnd;			/* last character of help request */
BOOLEAN SysLib;			/* use default HELP library? */
BOOLEAN	Prompt;			/* enter interactive help mode? */
{
	puts("Terminating in function ZHelp.\n");
	exit(1);
}
#endif




#ifdef vax11c
/******************************************************************************
	Help on the VAX is accessed through the help library routines.
******************************************************************************/

#include "DefChars.h"	/* define identifiers for characters */
#include ssdef		/* define system service status return identifiers */
#include descrip	/* define string descriptor structure */

#define	HLP$M_PROMPT	0x00000001	/* interactive help prompting */
#define	HLP$M_PROCESS	0x00000002	/* search process log. name table */
#define HLP$M_GROUP	0x00000004	/* search group log. name name */
#define HLP$M_SYSTEM	0x00000008	/* search system log. name table */
#define HLP$M_LIBLIST	0x00000010	/* list default libraries */
#define HLP$M_HELP	0x00000020	/* put text before topivc list */

int	lib$get_input();
int	lib$put_output();
int	lbr$output_help();	/* xxx */
VOID	lib$stop();		/* terminate image with stack dump */
int	sys$putmsg();		/* VAX/VMS "put message" system service */
VOID	ZDspBf();		/* display a buffer on the terminal */
VOID	ZDspCh();		/* display a character on the terminal */


EXTERN	struct	message_vector msgvec;


VOID ZHelp(HlpBeg, HlpEnd, SysLib, Prompt)
char *HlpBeg;			/* first char of help request */
char *HlpEnd;			/* last character of help request */
BOOLEAN SysLib;			/* use default HELP library? */
BOOLEAN	Prompt;			/* enter interactive help mode? */
{
	struct dsc$descriptor_s line_desc;
	struct dsc$descriptor_s lib_name;
	unsigned int	flags;
	unsigned int	status;

#if DEBUGGING
LOCAL char *DbgPtr;
DbgInd+=2;if(DbgLvl>=2){DbgMsg();DbgDBf("ZHelp: called, text = \"");
for (DbgPtr=HlpBeg; DbgPtr<=HlpEnd; ++DbgPtr) DspChr(*DbgPtr);
DbgDBf("\"\015\012");DbgROf();}
#endif

	lib_name.dsc$b_dtype =
	line_desc.dsc$b_dtype = DSC$K_DTYPE_T;
	lib_name.dsc$b_class =
	line_desc.dsc$b_class = DSC$K_CLASS_S;

	if (SysLib)
		{
		lib_name.dsc$a_pointer = "SYS$HELP:HELPLIB";
		lib_name.dsc$w_length = 16;
		}
	else
		{
		lib_name.dsc$a_pointer = "TEC$HELP";
		lib_name.dsc$w_length = 8;
		}

	line_desc.dsc$a_pointer = HlpBeg;
	line_desc.dsc$w_length = (HlpEnd - HlpBeg) + 1;

	flags = HLP$M_PROCESS | HLP$M_GROUP | HLP$M_SYSTEM | HLP$M_HELP;
	if (Prompt)
		flags |= HLP$M_PROMPT;

	status = lbr$output_help(	lib$put_output,	/* output routine */
					0,		/* output width */
					&line_desc,	/* line-desc */
					&lib_name,	/* library name */
					&flags,		/* flags */
					lib$get_input);	/* input rotuine */
	if (status != SS$_NORMAL)
		{
		msgvec.msgcod = status;
		status = sys$putmsg(	&msgvec,/* message vector */
					0,	/* action routine */
					0);	/* facility name */
		if (status != SS$_NORMAL)
			lib$stop(status);
		ZDspCh(LINEFD);
#if DEBUGGING
if(DbgLvl>=1)
{DbgMsg();DbgDBf("ZHelp: returning.\015\012");DbgROf();}DbgInd-=2;
#endif
		return;
		}

#if DEBUGGING
if(DbgLvl>=2)
{DbgMsg();DbgDBf("ZHelp: returning.\015\012");DbgROf();}DbgInd-=2;
#endif
}
#endif




#ifdef XENIX
VOID ZHelp(HlpBeg, HlpEnd, SysLib, Prompt)
char *HlpBeg;			/* first char of help request */
char *HlpEnd;			/* last character of help request */
BOOLEAN SysLib;			/* use default HELP library? */
BOOLEAN	Prompt;			/* enter interactive help mode? */
{
#if NO
	LOCAL WORD TmpWrd;

	static char *ParaTx[] = {
/*  0*/ "Three arguments are given (a,b,c or H,c).",

/*  1*/ "There is a close angle bracket not matched by an open",
/*  2*/ "angle bracket somewhere to its left. (Note: an",
/*  3*/ "iteration in a macro stored in a Q-register must be",
/*  4*/ "complete within the Q-register.)",

/*  5*/ "Conditionals, parenthesized arguments and iterations",
/*  6*/ "must be properly nested. The user probably used some",
/*  7*/ "construct like: n\"E...(...' where an iteration or",
/*  8*/ "parenthesized argument is begun in a conditional but not",
/*  9*/ "terminated in the same conditional.",

/* 10*/ "A file specification string in an E command contains an",
/* 11*/ "unknown device name.",

/* 12*/ "An nD command has been attempted which is not contained",
/* 13*/ "within the current page.",

/* 14*/ "The requested input file could not be located. If this",
/* 15*/ "occurred within a macro, the colon modified ER or EB",
/* 16*/ "command may be necessary.",

/* 17*/ "The page of text currently in the text buffer will not",
/* 18*/ "fit in the open output file. Until enough free space",
/* 19*/ "can be obtained on the output device the file may have",
/* 20*/ "to be split. An EF command to close the current output",
/* 21*/ "file, followed by a new EW command to a temporary file",
/* 22*/ "may be used. The files should be concatenated when the",
/* 23*/ "space problem is alleviated.",

/* 24*/ "A search argument contains a ^E command that is either",
/* 25*/ "not defined or incomplete. The only valid ^E commands",
/* 26*/ "in search arguments are: ^EA, ^ED, ^EV, ^EW, ^EL, ^ES,",
/* 27*/ "^E<nnn> and ^E[a,b,c...]",

/* 28*/ "An invalid E command has been executed. The E character",
/* 29*/ "must be followed by an alphabetic to form a legal E",
/* 30*/ "command (i.e. ER or EX).",

/* 31*/ "An illegal F command has been executed.",

/* 32*/ "The filespec as an argument to one of the E commands is",
/* 33*/ "unacceptable to the system. The file specification must",
/* 34*/ "be appropriate to the system in use.",

/* 35*/ "A command of the form \"nItext$\" was attempted. This",
/* 36*/ "combination of character and text insertion is illegal.",

/* 37*/ "An attempt has been made to execute an invalid TECO",
/* 38*/ "command.",

/* 39*/ "An 8 or 9 has been entered when the radix of TECO is set",
/* 40*/ "to octal.",

/* 41*/ "The argument preceding a P or PW command is negative or",
/* 42*/ "0.",

/* 43*/ "One of the valid \" commands did not follow the \". Refer",
/* 44*/ "to Section 5.14 (conditional execution commands) for",
/* 45*/ "the legal set of commands.",

/* 46*/ "An illegal Q-register name was specified in one of the",
/* 47*/ "Q-register commands.",

/* 48*/ "The argument to a ^R radix command must be 8, 10 or 16.",

/* 49*/ "The argument preceding a search command is 0. This",
/* 50*/ "argument must not be 0.",

/* 51*/ "One of the search string special characters (^Q, ^V, ^W,",
/* 52*/ "etc.) would have modified the search string delimiter",
/* 53*/ "(usually ESCAPE).",

/* 54*/ "The character following a ^ must have an ASCII value",
/* 55*/ "between 100 and 137 inclusive or between 141 and 172",
/* 56*/ "inclusive.",

/* 57*/ "Every conditional (opened with the \" command) must be",
/* 58*/ "closed with the ' command.",

/* 59*/ "Insufficient memory available to complete the current",
/* 60*/ "command. Make sure the Q-register area does not contain",
/* 61*/ "much unnecessary text. Breaking up the text area into",
/* 62*/ "multiple pages might be useful.",

/* 63*/ "There is a right angle bracket that has no matching left",
/* 64*/ "angle bracket. An iteration must be complete within the",
/* 65*/ "macro or command.",

/* 66*/ "There is a right parenthesis that is not matched by a",
/* 67*/ "corresponding left parenthesis.",

/* 68*/ "There is a left angle bracket that has no matching right",
/* 69*/ "angle bracket. An iteration must be complete within the",
/* 70*/ "macro or command.",

/* 71*/ "There is a right parenthesis that is not matched by a",
/* 72*/ "corresponding left parenthesis.",

/* 73*/ "A ' command (end of conditional) was encountered. Every",
/* 74*/ "' command must be matched by a preceding \" (start of",
/* 75*/ "conditional) command.",

/* 76*/ "The ^_ command must be preceded by either a specific",
/* 77*/ "numeric argument or a command that returns a numeric",
/* 78*/ "value.",

/* 79*/ "A command has been executed in which a , is not preceded",
/* 80*/ "by a numeric argument.",

/* 81*/ "The =, ==, or === command must be preceded by either a",
/* 82*/ "specific numeric argument or a command that returns a",
/* 83*/ "numeric value.",

/* 84*/ "A ) parenthesis has been encountered and is not properly",
/* 85*/ "preceded by a specific numeric argument or a command",
/* 86*/ "that returns a numeric value.",

/* 87*/ "The \" commands must be preceded by a single numeric",
/* 88*/ "argument on which the decision to execute the following",
/* 89*/ "commands or skip to the matching ' is based.",

/* 90*/ "The ; command must be preceded by a single numeric",
/* 91*/ "argument on which the decision to execute the following",
/* 92*/ "commands or skip to the matching > is based.",

/* 93*/ "The U comand must be preceded by either a specific",
/* 94*/ "numeric argument or a command that returns a numeric",
/* 95*/ "value.",

/* 96*/ "A comma was preceded by a negative number.",

/* 97*/ "The Y command must not be preceded by either a numeric",
/* 98*/ "argument or a command that returns a numeric value.",

/* 99*/ "Before issuing an input command, such as Y, it is",
/*100*/ "necessary to open an input file by use of a command such",
/*101*/ "as ER or EB.",

/*102*/ "Before issuing an output command, such as N or P,",
/*103*/ "it is necessary to open an output file by use of a",
/*104*/ "command such as EW or EB.",

/*105*/ "A P command was preceded by a negative or 0 argument.",

/*106*/ "A command was issued that is not yet implemented in this",
/*107*/ "version of TECO.",

/*108*/ "A command has been executed which tried to create an",
/*109*/ "output file, but an output file currently is open. It",
/*110*/ "is typically appropriate to use the EC or EK command as",
/*111*/ "the situation calls for to close the output file.",

/*112*/ "A ] sommand (pop off q-register stack into a q-register)",
/*113*/ "was encountered when there was nothing on the q-register",
/*114*/ "stack.",

/*115*/ "The command string has become too complex. Simplify it.",

/*116*/ "A J, C or R command has been executed which attempted to",
/*117*/ "move the pointer off the page. The result of executing",
/*118*/ "one of these commands must leave the pointer between 0",
/*119*/ "and Z, inclusive. The characters referenced by a D or",
/*120*/ "nA command must also be within the buffer boundary.",

/*121*/ "A ; command has been executed outside of an open",
/*122*/ "iteration bracket. This command may only be executed",
/*123*/ "within iteration brackets.",

/*124*/ "A search command not preceded by a colon modifier and",
/*125*/ "not within an iteration has failed to find the specified",
/*126*/ "\"text\". After an S search fails the pointer is left at",
/*127*/ "the beginning of the buffer. After an N or _ search",
/*128*/ "fails the last page of the input file has been input",
/*129*/ "and, in the case of N, output, and the buffer is",
/*130*/ "cleared. In the case of an N search it is usually",
/*131*/ "necessary to close the output file and reopen it for",
/*132*/ "continued editing.",

/*133*/ "A search or file name string is too long. This is most",
/*134*/ "likely the result of a missing ESCAPE after the string.",

/*135*/ "The tag !tag! specified by an O command cannot be",
/*136*/ "found. This tag must be in the same macro level as the",
/*137*/ "O command referencing it.",

/*138*/ "This is a general error which is usually caused by an",
/*139*/ "unterminated insert, search, or filespec argument, an",
/*140*/ "unterminated ^A message, an unterminated tag or comment",
/*141*/ "(i.e., unterminated ! construct), or a missing '",
/*142*/ "character which closes a conditional execution command.",

/*143*/ "This error is that same as the ?UTC error except that the",
/*144*/ "unterminated command was executing from a Q-register",
/*145*/ "(i.e., it was a macro). (Note: An entire command",
/*146*/ "sequence stored in a q-register must be complete within",
/*147*/ "the Q-register.)",

/*148*/ "Execution of TECO was aborted. This is usually due to",
/*149*/ "the typing of <CTRL/C>.",

/*150*/ "An attempt has been made to execute a Y or _ search",
/*151*/ "command with an output file open, that would cause text",
/*152*/ "in the text buffer to be erased without outputting it to",
/*153*/ "the output file. The ED command controls this check.",

/*154*/ "The output device is too full to accept the requested",
/*155*/ "output file."
	};

	static int StartP[] = {
/*  0*/    0,    /*  1*/    1,    /*  2*/    5,    /*  3*/   10,
/*  4*/   12,    /*  5*/   14,    /*  6*/   17,    /*  7*/   24,
/*  8*/   28,    /*  9*/   31,    /* 10*/   32,    /* 11*/   35,
/* 12*/   37,    /* 13*/   39,    /* 14*/   41,    /* 15*/   43,
/* 16*/   46,    /* 17*/   48,    /* 18*/   49,    /* 19*/   51,
/* 20*/   54,    /* 21*/   57,    /* 22*/   59,    /* 23*/   63,
/* 24*/   66,    /* 25*/   68,    /* 26*/   71,    /* 27*/   73,
/* 28*/   76,    /* 29*/   79,    /* 30*/   81,    /* 31*/   84,
/* 32*/   87,    /* 33*/   90,    /* 34*/   93,    /* 35*/   96,
/* 36*/   97,    /* 37*/   99,    /* 38*/  102,    /* 39*/  105,
/* 40*/  106,    /* 41*/  108,    /* 42*/  112,    /* 43*/  115,
/* 44*/  116,    /* 45*/  121,    /* 46*/  124,    /* 47*/  133,
/* 48*/  135,    /* 49*/  138,    /* 50*/  143,    /* 51*/  148,
/* 52*/  150,    /* 53*/  154
	};

	static int EndP[] = {
/*  0*/    0,    /*  1*/    4,    /*  2*/    9,    /*  3*/   11,
/*  4*/   13,    /*  5*/   16,    /*  6*/   23,    /*  7*/   27,
/*  8*/   30,    /*  9*/   31,    /* 10*/   34,    /* 11*/   36,
/* 12*/   38,    /* 13*/   40,    /* 14*/   42,    /* 15*/   45,
/* 16*/   47,    /* 17*/   48,    /* 18*/   50,    /* 19*/   53,
/* 20*/   56,    /* 21*/   58,    /* 22*/   62,    /* 23*/   65,
/* 24*/   67,    /* 25*/   70,    /* 26*/   72,    /* 27*/   75,
/* 28*/   78,    /* 29*/   80,    /* 30*/   83,    /* 31*/   86,
/* 32*/   89,    /* 33*/   92,    /* 34*/   95,    /* 35*/   96,
/* 36*/   98,    /* 37*/  101,    /* 38*/  104,    /* 39*/  105,
/* 40*/  107,    /* 41*/  111,    /* 42*/  114,    /* 43*/  115,
/* 44*/  120,    /* 45*/  123,    /* 46*/  132,    /* 47*/  134,
/* 48*/  137,    /* 49*/  142,    /* 50*/  147,    /* 51*/  149,
/* 52*/  153,    /* 53*/  156
	};

	DbgDBf("\015\012");
/* ??? */	/* get ErrNum */
/*	for (TmpWrd=StartP[ErrNum]; TmpWrd<=EndP[ErrNum]; ++TmpWrd)
		{
		DbgDBf(ParaTx[TmpWrd]);
		DbgDBf("\015\012");
		}
*/
#endif
	return(ExeNYI());
}
#endif
