home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume26
/
maint
/
part02
/
maint.h.dist
< prev
next >
Wrap
Text File
|
1992-05-13
|
16KB
|
386 lines
#ifndef MAINT_H
/******************************************************************************
*******************************************************************************
Installation: Western Michigan University Academic Computer Center
System: Directory/File System Maintenance
Program: maint
Header name: maint.h
Version=01 Level=00 01/24/92 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.
Other information: (C) Copyright 1992, Leonard J. Peirce
********************************************************************************
*******************************************************************************/
#define MAINT_H 1 /* to prevent multiple inclusion */
/******************************************************************************/
/* */
/* # I N C L U D E F I L E S */
/* */
/******************************************************************************/
#include <sys/types.h>
#include <dirent.h>
/******************************************************************************/
/* */
/* # D E F I N E S */
/* */
/******************************************************************************/
/* HELPFILE contains on-line help for maint and should be defined in the
* Makefile so that maints knows where it's supposed to be and so that it
* it gets installed in the right spot; if you don't want to define it in
* the Makefile you'll need to make sure that the path to the help file is
* correct in both spots
*/
#ifndef HELPFILE
#define HELPFILE "/usr/local/lib/maint.help"
#endif
#define MAX_SCREEN_ROWS 65 /* max. # of rows for screens */
#define MAX_SCREEN_COLS 132 /* max. # of columns for screens */
#define DEFAULT_PAGER "less" /* less is better than cat.....:-) */
#define DEFAULT_EDITOR "vi" /* sigh..... */
#define DEFAULT_SHELL "csh"
/* the following stuff you probably won't want to touch */
#define TRUE (1)
#define FALSE (0)
#define NULLPTR (char *) 0
#define LEFT 0
#define RIGHT 1
#define SPEC_WINDOW_ROWS 2 /* # of rows in directory spec window */
#define SPEC_WINDOW_START_ROW 0 /* starting row # of dir spec window */
#define STAT_WINDOW_ROWS 2 /* # of rows in statistics window */
#define STAT_WINDOW_START_ROW 0
#define SUCCESS 1
#define FAILURE 0
#define NO_REBUILD 0 /* return values from config() */
#define REBUILD_WITH_FILEMARKS 1
#define REBUILD_SCREEN 2
#define REBUILD_DIRECTORY 4
#define REBUILD_WITH_SORT 8
#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 CANT_ALLOCATE -9 /* can't allocate necessary memory */
#define CANT_OPEN_DEST -10 /* can't open destination file */
#define CANT_STAT -11 /* can't stat a file */
#define CANT_WRITE -12 /* can't write to a file */
#define CANT_CHMOD -13 /* chmod() failed on a file */
#define BAD_GROUP -14 /* invalid group specified */
#define BAD_OWNER -15 /* invalid owner specified */
#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 NORMAL 1
#define HIGHLITE 2
#define PROT_MAX 10 /* max. length of protection string */
#define DATE_MAX 12 /* max. length of date/time string */
#define DNAME_MAX 14 /* max. length of displayed filename */
#define FILEMARK_MAX 1 /* max. length of filetype mark */
#define DISP_MAX DNAME_MAX+FILEMARK_MAX /* max. length of filename & mark */
#define SIZE_MAX 8 /* max. length of filesize string */
#define OWNER_MAX 8 /* max. length of owner string */
#define GROUP_MAX 8 /* max. length of group string */
#define FIELD_GAP 2 /* space between fields in a slot */
#define SLOT_GAP 3 /* space between slots on a screen */
#define FULL_MAX PROT_MAX + DATE_MAX + DISP_MAX + OWNER_MAX + \
SIZE_MAX + GROUP_MAX + (FIELD_GAP * 5)
#define MESS_MAX 255 /* max. length of broadcast message */
#define STR_MAX 255 /* max. length of help input line */
#define TYPE_MAX 3 /* max. length of displayed filetype */
#define SPEC_MAX 255 /* max. length of filename */
#define FULL_SPEC_MAX 255 /* max. length of full file spec */
#define RESP_MAX 80 /* max. length of response from tty */
#define COMMAND_MAX 4 /* max. number of commands per file */
#define TEXT_MAX 40 /* max. length of text descriptor */
#define DIR_TEXT_MAX 70 /* 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 DIR_NAME_MAX MAXNAMLEN /* this is system-dependent */
#define PROMPT_MAX 80 /* max.length of a prompt string */
#define ID_STR_MAX 16 /* max. length of uid/gid string */
#define TIME_STR_MAX 24 /* time string from ctime(3) */
#define PROT_INP_MAX 9 /* max. length of protect str read in */
/* from the screen */
/* maximum number of file rows; this is used to allocate the static array
* for holding file scree nodes
*/
#define MAX_NODE_ROW (MAX_SCREEN_ROWS - (SPEC_WINDOW_ROWS + \
STAT_WINDOW_ROWS + 1))
#define MAX_NODE_COL ((MAX_SCREEN_COLS + (DISP_MAX + \
SLOT_GAP - 1))/(DISP_MAX + SLOT_GAP))
#define MIN_SLOT_WIDTH 16 /* minimum slot width */
#define MIN_DISP_LEN 5 /* display >= 5 chars for inputting */
#define FLAG_CHAR '+' /* long filename flag character */
#define TAG_CHAR '>' /* tag for making marks on files */
#define OPT_STRING_MAX 40 /* option id string */
#define GROUP_SAVE 150 /* number of gids to save */
#define OWNER_SAVE 150 /* number of uids to save */
#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 */
/* these must coincide with the fields in the arg_strings structure that
* is defined in main.c
*/
#define SIZE_OPT 0
#define PROT_OPT 1
#define DATE_OPT 2
#define GROUP_OPT 3
#define OWNER_OPT 4
#define CONFIRM_OPT 5
#define AUTO_FEED_OPT 6
#define TEXT_OPT 7
#define DOT_FILES_OPT 8
#define FILEMARKS_OPT 9
#define SORT_OPT 10
#define NUM_OPT_STRINGS 11
#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'
#define GROUP 'g'
#define OWNER 'o'
/* -S option flag values */
#define FILENAME 1 /* sort by filename */
#define TYPE 2 /* sort by file type */
#define SIZE 3 /* sort by file size */
#define DATE 4 /* sort by date */
#define NUM_SORT_OPT 4 /* number of highest sort option */
#define REGULAR '-'
#define DIRECTORY 'd'
#define CHARACTER 'c'
#define BLOCK 'b'
#define FIFO 'p'
#define SOCKET 's'
#define LINK 'l'
#define CONTROL_B 0x2
#define CONTROL_D 0x4
#define CONTROL_F 0x6
#define CONTROL_G 0x7
#define CONTROL_H 0x8
#define CONTROL_I 0x9
#define CONTROL_K 0xB
#define CONTROL_L 0xC
#define CONTROL_P 0x10
#define CONTROL_R 0x12
#define CONTROL_W 0x17
#define CONTROL_Z 0x1a
#define LINEFEED 0xA
#define CARRIAGE_RETURN 0xD
#define BACKSPACE 0x8
#define ESCAPE 0x1b
#define kbytes(size) (((size) + 1023) / 1024)
#define info_mess(message) write_mess(message,A_BOLD,0)
#define xmess(message,prefix_len) write_mess(message,A_REVERSE,prefix_len)
#if defined(SYSV) && !defined(sun)
/* stuff that needs to be defined for System V */
#define vfork fork /* no vfork() */
#define dbtob(db) ((unsigned)(db) << BSHIFT)
#define R_OK 04 /* for access() */
#endif
/******************************************************************************/
/* */
/* S T R U C T U R E S , U N I O N S , T Y P E D E F S */
/* */
/******************************************************************************/
#if defined(SYSV) && !defined(sun)
typedef unsigned long int u_long; /* I like underscores.... */
typedef unsigned int u_int;
typedef unsigned short int u_short;
typedef unsigned char u_char;
typedef int gid_t,uid_t;
#endif
#ifdef SUNOS3
/* weird...SunOS 3.X doesn't have typedefs for uid_t and gid_t in sys/types.h;
* however, SunOS 4.0 does and it doesn't match the pw_uid and pw_gid fields
* in the passwd struct in pwd.h -- they are ints and the typedefs for uid_t
* and gid_t in sys/types.h are u_short.....sigh.....
*/
typedef int uid_t, gid_t;
#endif
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 */
group, /* wants group field */
owner, /* wants owner field */
wide, /* wants 132-column mode */
confirm, /* wants to be asked before Xecuting */
auto_feed, /* wants autofeed on Delete/Unmark */
text_startup, /* set if -t on command line */
text, /* wants text descriptors included */
dot_files, /* wants files starting with . */
filemarks; /* / for dirs, * for executables, etc */
} ARG_DEF;
typedef struct ARG_STR_TYP { /* strings for configuring on the fly */
char string[OPT_STRING_MAX+1];
short *ptr; /* pointer into arg structure */
} ARG_STR;
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 */
gid_t group; /* new group value */
uid_t owner; /* new owner for file */
u_short 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 */
comm_grp, /* change group of file */
comm_own; /* change owner of file */
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 */
*text; /* text descriptor */
size_t size; /* in blocks */
time_t time; /* whatever type of time desired..... */
uid_t uid; /* owner id of file */
gid_t gid; /* group id of file */
u_short prot, /* integer protection value */
name_len, /* length of scr_name minus padding */
disp_len; /* displayed length of full filename */
u_char type, /* file type */
mark_flag; /* set if file is Marked */
char scr_name[DISP_MAX+1]; /* displayed filename and filemark */
} 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 */
size_t 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 { /* saved uid/gid entry */
uid_t id; /* uid/gid saved */
char str[ID_STR_MAX+1]; /* associated string */
} ID_ENT;
typedef struct { /* summary info of directory entries */
ENT_DEF *ptr; /* pointer to directory info */
short num_file; /* number of files in directory */
} DIR_SUMM;
typedef struct DIR_TYPE { /* directory info link structure */
ENT_DEF *dirptr; /* pointer to directory information */
char *dir_name; /* name of directory */
struct DIR_TYPE *prev, /* pointer to previous directory node */
*next; /* pointer to next directory node */
POOL_DEF *first_pool, /* first memory pool for directory */
*curr_pool; /* current memory pool for directory */
size_t pool_length; /* length for allocating new pools */
time_t stat_time; /* when directory was last modified */
u_short count; /* number of times directory entered */
short num_file; /* number of files in directory */
} DIR_PTR;
/******************************************************************************/
/* */
/* 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