#ifndef MAINT_H
/******************************************************************************
*******************************************************************************

   Installation:  Western Michigan University Academic Computer Center

   System:	Directory/File System Maintenance (MAINT)
  
   Header name:	maint.h

   Version=01	Level=01	08/12/87	Leonard J. Peirce

   Purpose:  Header file for the MAINT program.  This header file should
	     only be used by MAINT as it would be of no use to any other
	     program.

   Version=01	Level=02	10/06/88	Leonard J. Peirce

   Purpose:  Changes made for Version 1.5.  See MAINT.C for more information.

   Other information:	none

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

#define MAINT_H 1			/* to prevent multiple inclusion      */

/******************************************************************************/
/*                                                                            */
/*                        # I N C L U D E   F I L E S                         */
/*                                                                            */
/******************************************************************************/

#ifdef WMUACC
#include utype
#else
#include "utype.h"
#endif

/******************************************************************************/
/*                                                                            */
/*                             # D E F I N E S                                */
/*                                                                            */
/******************************************************************************/

#define EXTERNAL_HLB			/* our own EXTERNAL help library      */
#define SMG$_EOF 1213442		/* missing SMG definition	      */

#define MAX_NODE_ROW 19			/* max. number of file rows	      */
#define MAX_NODE_COL 8			/* max. number of file columns	      */
#define MAX_FILE 18			/* max. length of displayed filename  */
#define DEV_MAX 255			/* max. length of device name	      */
#define MIN_SLOT_WIDTH 16		/* minimum slot width		      */
#define FLAG_CHAR '*'			/* long filename flag character	      */

#define DIR_INFO_ROWS 2			/* # of rows in page # display	      */
#define MAIN_ROWS 20			/* # of rows in main display	      */
#define WORK_ROWS 22			/* # of rows in work display	      */
#define OPT_INFO_ROWS 2			/* # of rows in options/stats display */

#define DIR_INFO_BASE_ROW 1		/* base row when pasted		      */
#define DIR_INFO_BASE_COL 1		/* base col when pasted		      */
#define MAIN_BASE_ROW 3
#define MAIN_BASE_COL 1
#define WORK_BASE_ROW 3
#define WORK_BASE_COL 1
#define OPT_INFO_BASE_ROW 23
#define OPT_INFO_BASE_COL 1

#define CANT_OPEN -1			/* can't open file to display it      */
#define CANT_DISPLAY -2			/* can't display file on screen	      */
#define EMPTY_FILE -3			/* selected file is empty	      */
#define BAD_FILE -4			/* file format invalid		      */
#define DONT_CREATE -5			/* do not create file		      */
#define NO_FILE -6			/* file does not exist		      */
#define NEW_FILE -7			/* new file had to be created	      */
#define BAD_SCREEN_NO -8		/* bad screen number read in	      */
#define DISPLAY_TEXT 1			/* text descriptors to be displayed   */
#define SLOT_OVF 2			/* text descriptor overflows slot     */

					/**    return codes for proc_dir()   **/
#define RECALL_PROC 1			/* force proc_dir() to be recalled    */
#define EMPTY_DIR 2			/* selected directory is empty	      */

#define PROT_MAX 19			/* max. length of protection string   */
#define DATE_MAX 17			/* max. length of date/time string    */
#define NAME_MAX 19			/* max. length of displayed filename  */
#define SIZE_MAX 6			/* max. length of filesize string     */
#define FULL_MAX 65			/* max. length of full info string    */
#define SCR_MAX 132			/* maximum screen width		      */
#define MESS_MAX 255			/* max. length of broadcast message   */
#define STR_MAX 255			/* max. length of help input line     */
#define FILENAME_MAX 10			/* max. length of displayed filename  */
#define TYPE_MAX 3			/* max. length of displayed filetype  */
#define VERSION_MAX 3			/* max. length of displayed version   */
#define SPEC_MAX 80			/* max. length of filename	      */
#define FULL_SPEC_MAX 255		/* max. length of full file spec      */
#define COMMAND_MAX 3			/* max. number of commands per file   */
#define TEXT_MAX 40			/* max. length of text descriptor     */
#define DIR_TEXT_MAX 60			/* max. length of directory text desc */
#define DATE_TIME_MAX 23		/* max. length of a date/time string  */
#define BUF_MAX 16384			/* buffer size for block mode copying */
#define PAGE_NO_MAX 4			/* max. digits in screen number	      */
#define ACLBUF_MAX 512			/* max. length of ACL binary buffer   */
#define RESP_MAX 74			/* max. length of "Topic ?" response  */
#define PROT_INP_MAX 60			/* max. length of protect str read in */
					/* from the screen		      */

#define IN_REC_SIZE 512			/* size of input record buffer	      */
#define TEXT_REC_MAX 112		/* max. length of text descriptor rec */
#define FUDGE_FACTOR 35			/* multiplied by number of elements   */
					/* needed to get the size of the      */
					/* memory pool to allocate	      */

#define TEXT_FILE "MAINT.TDF"		/* name of text descriptor file	      */

#define DELETE 'd'			/* file command definitions	      */
#define RENAME 'r'
#define COPY 'c'
#define PROTECT 'p'
#define TEXT 't'
					/* /SORT option flag values	      */
#define FILENAME 0			/* sort by filename		      */
#define TYPE 1				/* sort by file type		      */
#define SIZE 2				/* sort by file size		      */
#define DATE 3				/* sort by date			      */

#define SYSTEM_READ 0x1			/* protection field bit masks	      */
#define SYSTEM_WRITE 0x2
#define SYSTEM_EXECUTE 0x4
#define SYSTEM_DELETE 0x8

#define OWNER_READ 0x10
#define OWNER_WRITE 0x20
#define OWNER_EXECUTE 0x40
#define OWNER_DELETE 0x80

#define GROUP_READ 0x100
#define GROUP_WRITE 0x200
#define GROUP_EXECUTE 0x400
#define GROUP_DELETE 0x800

#define WORLD_READ 0x1000
#define WORLD_WRITE 0x2000
#define WORLD_EXECUTE 0x4000
#define WORLD_DELETE 0x8000

#define TPU$_NORMAL 0x3F2B091		/* can't find it anywhere.....	      */

/******************************************************************************/
/*                                                                            */
/*          S T R U C T U R E S ,   U N I O N S ,   T Y P E D E F S           */
/*                                                                            */
/******************************************************************************/

typedef	 struct	  DATE_TYPE {		/* for overlaying date values	      */
	 ULONG	  left,			/* left 32-bits of date/time value    */
		  right;		/* right 32-bits		      */
} DATE_DEF;

typedef	 struct	  NODE_TYP {		/* screen position node		      */
	 short	  left_row,	   	/* row-coordinate for node array      */
		  left_col,		/* column-coordinate for node array   */
		  right_row,		/* row-coordinate for node array      */
		  right_col,		/* column-coordinate for node array   */
		  down_row,		/* row-coordinate for node array      */
		  down_col,		/* column-coordinate for node array   */
		  up_row,		/* row-coordinate for node array      */
		  up_col,		/* column-coordinate for node array   */
		  row,			/* cursor row coordinate for node     */
		  column;		/* cursor column coordinate for node  */
} NODE_DEF;

typedef	 struct	  ARG_TYP {		/* run-time argument flags	      */
	 short	  sort,			/* wants files sorted		      */
		  size,			/* wants size field included	      */
		  prot,			/* wants protection field included    */
		  date,			/* wants date field included	      */
		  def,			/* wants just default info	      */
		  full,			/* wants all (size,date,prot)	      */
		  wide,			/* wants 132-column mode	      */
		  confirm,		/* wants to be asked before Xecuting  */
		  text_startup,		/* set if /TEXT on command line	      */
		  text;			/* wants text descriptors included    */
} ARG_DEF;

typedef	 struct	  COM_TYP {		/* file command definition type	      */
	 char	  *copy_name,		/* new filename for copying	      */
		  *ren_name,		/* new filename for renaming	      */
		  *text;		/* text descriptor string	      */
	 USHORT	  prot;			/* protection value		      */
	 short	  copy_len,		/* max. length of copy filename str.  */
		  ren_len,		/* max. length of rename filename str */
		  text_len;		/* max. length of text string	      */
	 char	  comm_text,		/* text descriptor for file	      */
		  comm_del,		/* file is to be deleted	      */
		  comm_prot,		/* new protection for file	      */
		  comm_copy,		/* file is to be copied		      */
		  comm_ren;		/* file is to be renamed	      */
	 char	  dummy[3];		/* pad-out; might not be necessary    */
} COM_DEF;

typedef	 struct	  ENT_TYP {		/* file entry definition type	      */
	 COM_DEF  *command;		/* commands for file		      */
  	 char	  *filename,		/* real filename		      */
		  *prot_str,		/* file protection string	      */
		  *date_str,		/* date/time string		      */
		  *text;		/* text descriptor		      */
	 ULONG 	  size,			/* in blocks			      */
		  time[2];		/* quadword time value		      */
	 USHORT	  prot;			/* integer value of protection	      */
	 char	  scr_name[NAME_MAX+1],	/* filename displayed on screen	      */
		  curdir;		/* set if file in current directory   */
	 char	  dummy[1];		/* make length of structure a multi-  */
					/* ple of 4 to make things easier     */
} ENT_DEF;

typedef	 struct	  POOL_TYP {		/* memory pool node structure	      */
	 char	  *ptr,			/* pointer to next byte in pool	      */
		  *first;		/* pointer to beginning of pool	      */
struct	 POOL_TYP *next_pool;		/* pointer to next memory pool	      */
	 long	  remaining,		/* # of remaining bytes in pool	      */
		  length;		/* original length of pool	      */
} POOL_DEF;

typedef	 struct	  OPT_TYPE {		/* displayed options definition	      */
	 char	  *keystr,		/* keystroke for command	      */
	  	  *remaining,		/* rest of chars in command	      */
		  key_len,		/* length of keystroke for command    */
		  rem_len,		/* length of rest of chars in command */
		  spaces;		/* number of spaces after command def */
} OPT_DEF;

typedef	 struct	  UIC_TYPE {		/* for overlaying xab$l_uic	      */
	 USHORT	  member,		/* member part of UIC		      */
		  group;		/* group part of UIC		      */
} UIC_DEF;

typedef	 struct	  {			/* summary info of directory entries  */
	 ENT_DEF  *ptr;			/* pointer to directory info	      */
	 short	  num_file;		/* number of files in directory	      */
} DIR_SUMM;

/******************************************************************************/
/*                                                                            */
/*   E X T E R N A L   D E F I N I T I O N S   &   D E C L A R A T I O N S    */
/*                                                                            */
/******************************************************************************/


/******************************************************************************/
/*                                                                            */
/*     S T A T I C   D E F I N I T I O N S   &   D E C L A R A T I O N S      */
/*                                                                            */
/******************************************************************************/

#endif
