v20i001: scan - A directory menu program, Part01/03

Patrick J. Wolfe pat at kai.com
Tue May 21 15:42:37 AEST 1991


Submitted-by: Patrick J. Wolfe <pat at kai.com>
Posting-number: Volume 20, Issue 1
Archive-name: scan/part01

Scan is a directory menu program.  It uses curses to present a full screen menu
with output similar to that of "ls -l".  You can scroll through the listing and
perform common operations (such as view, edit, remove) on individual files.  You
can also "tag" multiple files using the "m" key, and perform operations on all
the tagged files at once.

Scan has an online setup facility (press capital "S" while scan is running) for
redefining keys and setting options, so that, unlike many other programs, you
don't have to go through the tedious cycle of reading the manpage, editing the
rc file, and running the program over and over to get things the way you like.

Scan is known to work on various flavors of BSD and System V Unix, including:
	Esix (AT&T Unix) System V Release 3.2 rev D
	Sequent Dynix V3
	SGI Irix V3
	SunOS 4.1.1  [moderator tested.. -Kent+]
With little or no work, it should work on any other flavor.

Patrick J. Wolfe   (pat at kai.com, uunet!uiucuxc!kailand!pat)
-------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix at uunet.uu.net if you want that tool.
# Contents:  README config.h defkeys.h fileops.c
# Wrapped by kent at sparky on Tue May 21 00:34:20 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo If this archive is complete, you will see the following message:
echo '          "shar: End of archive 1 (of 3)."'
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
  echo shar: Extracting \"'README'\" \(2442 characters\)
  sed "s/^X//" >'README' <<'END_OF_FILE'
XTo compile the "scan" program, edit "config.h" and "Makefile" to plug in your
Xfavorite choices and enter "make".
X
XScan is a directory menu program.  It uses curses to present a full screen menu
Xwith output similar to that of "ls -l".  You can scroll through the listing and
Xperform common operations (such as view, edit, remove) on individual files.  You
Xcan also "tag" multiple files using the "m" key, and perform operations on all
Xthe tagged files at once.
X
XScan has an online setup facility (press capital "S" while scan is running) for
Xredefining keys and setting options, so that, unlike many other programs, you
Xdon't have to go through the tedious cycle of reading the manpage, editing the
Xrc file, and running the program over and over to get things the way you like.
X
XScan is known to work on various flavors of BSD and System V Unix, including:
X	Esix (AT&T Unix) System V Release 3.2 rev D
X	Sequent Dynix V3
X	SGI Irix V3
XWith little or no work, it should work on any other flavor.
X
XThe original version of "scan" was written by me in the OBS Wylbur "exec"
Xlanguage for users of the US MEPCOM Joint Computer Center at Great Lakes
XNaval Base, Great Lakes IL, where it is still being used today.
X
X-------------------------------------------------------------------------------
X
XThis software is Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
X
XPermission is hereby granted to copy, distribute or otherwise 
Xuse any part of this package as long as you do not try to make 
Xmoney from it or pretend that you wrote it.  This copyright 
Xnotice must be maintained in any copy made.
X
XUse of this software constitutes acceptance for use in an AS IS 
Xcondition. There are NO warranties with regard to this software.  
XIn no event shall the author be liable for any damages whatsoever 
Xarising out of or in connection with the use or performance of this 
Xsoftware.  Any use of this software is at the user's own risk.
X
XIf you make modifications to this software that you feel 
Xincreases it usefulness for the rest of the community, please 
Xemail the changes, enhancements, bug fixes as well as any and 
Xall ideas to me. This software is going to be maintained and 
Xenhanced as deemed necessary by the community.
X             
X        Patrick J. Wolfe   (pat at kai.com, uunet!uiucuxc!kailand!pat)
X	System Programmer/Operations Manager
X	Kuck and Associates, 1906 Fox Drive, Champaign, IL USA 61820-7334
X	voice: 217-356-2288  fax: 217-356-5199
X
END_OF_FILE
  if test 2442 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
  fi
  # end of 'README'
fi
if test -f 'config.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'config.h'\"
else
  echo shar: Extracting \"'config.h'\" \(7314 characters\)
  sed "s/^X//" >'config.h' <<'END_OF_FILE'
X/*
X *	configuration file for scan program
X */
X
X
X/* maximum number of users we can cache */
X#define MAXLID		128
X
X/* maximum number of groups we can cache */
X#define MAXGID		64
X
X/*	if RM_BREAKPOINT is defined, it is the maximum number of files that
X *	may be deleted at one time before the rm_verify is forced "on".
X */
X#define RM_BREAKPOINT	10
X
X/* defaults editor and file viewer */
X#define DEFAULT_EDITOR	"vi"
X#define DEFAULT_PAGER	"less"
X
X/*
X * SYSTEM_RCFILE will be processed before the user's .scanrc,
X * allowing site wide defaults
X */
X#define SYSTEM_RCFILE "/usr/local/lib/scan.rc"
X
X/*
X *	Define "SIGTYPE" to the type of the value returned by the "signal"
X *	system call.  On BSD 4.2 systems, it's "void".  On BSD 4.3 and SVR3
X *	systems, it's "int".
X *
X *	Define "VOIDPTR" if your C compiler can handle void pointers.  The
X *	portable C compiler that comes with many systems cannot.  Most modern
X *	C compilers can.
X *
X *	Define "NEED_TSTP" if your curses library uses "_tstp()" instead of
X *	"tstp()".  If you need this, you'll find the link fails with an
X *	unresolved reference to _tstp.
X *
X *	Defining "System5" is the same as defining ALL of the following:
X *
X *		Define "SYSVmemcpy" to use memcpy instead of bcopy.
X *		Define "SYSVcurses" if your system has System V curses.
X *		Define "SYSVdirent" if your system uses the "dirent" directory
X *			access (get Doug Gwyn's library if your System V
X *			system doesn't support this).
X *		Define "SYSVgetcwd" to use getcwd instead of getwd.
X *
X *	If you have one of the ever more popular mixture operating systems,
X *	just pick the features you need out of the above list.
X *
X *	Here's some known values:
X */
X
X/* HP/UX V7 and later */
X#ifdef hpux
X#define SIGTYPE	void
X#define System5
X#define VOIDPTR
X#define NEED_TSTP
X#else
X
X/* SGI Irix 3.3 */
X#ifdef sgi
X#define SYSVcurses
X#define SYSVdirent
X#define SYSVmemcpy
X#define SIGTYPE	void
X/*
X#define VOIDPTR
X*/
X#define NEED_TSTP
X#else
X
X/* Sequent Dynix V3 */
X#ifdef sequent
X#define SIGTYPE int
X#ifndef LINT
X#define VOIDPTR
X#endif
X#else
X
X/* Esix (AT&T Unix) System V Release 3.2 Rev D */
X#ifdef i386
X#define System5
X#define SIGTYPE	void
X#define NEEDTIMEH
X#define VOIDPTR
X#else
X
X/*
X * Concurrent RTU 5.0
X */
X#ifdef mc700
X#define SIGTYPE	void
X#define NEED_TSTP
X#define System5
X#ifdef _UCB
XDANGER Will Robinson
X	scan will not link in the ucb universe on RTU V5
X	because the curses include file is broken!
X	The _rawmode routine does not exist!
X	compile in the ATT universe instead!
X#endif
X#else
X
X/* Alliant Concentrix V5.5 */
X#ifdef alliant
X#define SIGTYPE void
X#else
X
X/* HP/Apollo Domain/OS SR 10.3 */
X#ifdef apollo
X#define SIGTYPE int
X#define VOIDPTR
X
X#endif /* apollo */
X#endif /* alliant */
X#endif /* rtu */
X#endif /* i386 */
X#endif /* sequent */
X#endif /* sgi */
X#endif /* hpux */
X
X#ifdef System5
X#define SYSVcurses
X#define SYSVmemcpy
X#define SYSVdirent
X#define SYSVgetcwd
X#endif /* System5 */
X
X#ifdef VOIDPTR
Xtypedef void *voidptr;
X#else
Xtypedef int *voidptr;
X#endif
X
X#ifndef SIGTYPE
X#define SIGTYPE	void
X#endif
X
X#include <curses.h>
X#include <sys/types.h>
X#include <sys/wait.h>
X#include <sys/stat.h>
X#ifdef NEEDTIMEH
X#include <time.h>
X#endif
X#include <sys/time.h>
X#include <pwd.h>
X#include <grp.h>
X#include <signal.h>
X#include <ctype.h>
X#include <errno.h>
X
X#ifdef SYSVdirent
X#include "dirent.h"
X#define NAMELEN(x) strlen(x->d_name)
X#define direct dirent
X#else
X#include <sys/dir.h>
X#define NAMELEN(x) x->d_namlen
X#endif /* SYSVdirent */
X
X#ifdef sequent
X#include <sys/universe.h>
X#endif /* sequent */
X
X#include "getch.h"
X
X#ifdef SYSVmemcpy
X#define BCOPY(source,dest,len) memcpy(dest,source,len)
X#else
X#define BCOPY(source,dest,len) bcopy(source,dest,len)
X#endif
X
X#define beep()  fprintf (stderr, "\007");
X
X#define PGM_VERSION	"Scan V4.0"	/* for informational purposes */
Xextern int PAGESIZE;
X
X/* maximum length any filename can be */
X#define MAXPATHLEN	1024
X/* maximum number of command line arguments we will handle */
X#define MAXARGS		512
X
X/* how much memory to allocate in each name buffer block */
X#define BUFSIZE	256 * 1024
X
Xstruct	namelist {	/* used to cache login id and group information */
X	int	number;
X	char	name[9];
X	};
X
X/* largest number of files we will handle */
X#define MAXDIRSIZE	512
Xstruct	dblock	{		/* used to store file information */
X	int	size,		/* filesize in bytes */
X		owner,		/* index into lidlist */
X		group,		/* index into gidlist */
X		selected,	/* flag to indicate selected status */
X		type;		/* file type */
X	time_t	ctime;		/* time of last modification */
X	char	perms[13];	/* file permissions */
X	char	modtime[13];	/* last modification time */
X	char	*name;		/* file name */
X	char	*link;		/* name pointed to, for symbolic links */
X	};
X
X#ifndef TRUE
X#define TRUE 1
X#endif
X#ifndef FALSE
X#define FALSE 0
X#endif
X#define ONERROR 2
X
Xstruct option_entry {
X	char	*name;
X	int	*variable;
X	char	**value_table;
X	short	default_value;
X	};
X
X/* shorthand names for option values */
X#define DOT_FIRST 0
X#define DOT_LAST 1
X#define DOT_HIDE 2
X
X#define DIR_FIRST 0
X#define DIR_LAST 1
X#define DIR_SORT 2
X
X#define WITH_DOT 0
X#define WITH_DIR 1
X
X#define OPT_FALSE 0
X#define OPT_TRUE 1
X
Xtypedef int Function ();
X
X#define NILL (Function *)0x0
X#define SIZEKEYTAB 512
X
X#define KEY_UNDEF 0
X#define KEY_FUNC 1
X#define KEY_CMD 2
X
X#define OPT_TAGALL	00010000
X#define OPT_TAGCUR	00001000
X#define OPT_VERIFY	00000100
X#define OPT_WAITERR	00000010
X#define OPT_WAIT	00000001
X#define OPT_NONE   	00000000
X
Xstruct funcname_entry {
X	char *name;
X	int (*kfunc) ();
X	};
X
Xstruct key_entry {
X	short	type;	/* KEY_UNDEF = undefined, KEY_FUNC = built in function, KEY_CMD = command string */
X	short	options;
X	voidptr	pntr;
X	};
X
Xstruct keydef_entry {
X	char *name;
X	int value;
X	};
X
Xextern int bottom_line(), cd_back(), cd_dot(), cd_dotdot(), cd_file(),
X	cd_home(), cd_or_edit(), cd_or_view(), cd_prompt(), cd_root(),
X	command_file(), command_tagged(), edit_file(), edit_tagged(),
X	execute_file(), exec_file(), exit_pgm(), first_page(), fork_shell(),
X	help_screen(), last_page(), middle_line(), next_halfpage(),
X	next_line(), next_page(), prev_halfpage(), prev_line(), prev_page(),
X	redraw_menu(), rm_file(), rm_tagged(), setup_menu(), tag_all(),
X	toggle_tag(), top_line(), untag_all(), view_file(), view_tagged();
X
X/*
X * This software is Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
X *
X * Permission is hereby granted to copy, distribute or otherwise 
X * use any part of this package as long as you do not try to make 
X * money from it or pretend that you wrote it.  This copyright 
X * notice must be maintained in any copy made.
X *
X * Use of this software constitutes acceptance for use in an AS IS 
X * condition. There are NO warranties with regard to this software.  
X * In no event shall the author be liable for any damages whatsoever 
X * arising out of or in connection with the use or performance of this 
X * software.  Any use of this software is at the user's own risk.
X *
X * If you make modifications to this software that you feel 
X * increases it usefulness for the rest of the community, please 
X * email the changes, enhancements, bug fixes as well as any and 
X * all ideas to me. This software is going to be maintained and 
X * enhanced as deemed necessary by the community.
X *              
X *              Patrick J. Wolfe
X *              uunet!uiucuxc!kailand!pwolfe
X *              pwolfe at kailand.kai.com
X */
END_OF_FILE
  if test 7314 -ne `wc -c <'config.h'`; then
    echo shar: \"'config.h'\" unpacked with wrong size!
  fi
  # end of 'config.h'
fi
if test -f 'defkeys.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'defkeys.h'\"
else
  echo shar: Extracting \"'defkeys.h'\" \(26960 characters\)
  sed "s/^X//" >'defkeys.h' <<'END_OF_FILE'
X/*
X *	default key assignment table
X *
X * This software is Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
X *
X * Permission is hereby granted to copy, distribute or otherwise 
X * use any part of this package as long as you do not try to make 
X * money from it or pretend that you wrote it.  This copyright 
X * notice must be maintained in any copy made.
X *
X * Use of this software constitutes acceptance for use in an AS IS 
X * condition. There are NO warranties with regard to this software.  
X * In no event shall the author be liable for any damages whatsoever 
X * arising out of or in connection with the use or performance of this 
X * software.  Any use of this software is at the user's own risk.
X *
X * If you make modifications to this software that you feel 
X * increases it usefulness for the rest of the community, please 
X * email the changes, enhancements, bug fixes as well as any and 
X * all ideas to me. This software is going to be maintained and 
X * enhanced as deemed necessary by the community.
X *              
X *              Patrick J. Wolfe
X *              uunet!uiucuxc!kailand!pwolfe
X *              pwolfe at kailand.kai.com
X */
X
X
Xstruct key_entry default_keytab[] = {
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^@ - NULL */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^A */
X	{ KEY_FUNC,	0,	(voidptr) prev_page },		/* ^B */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^C */
X	{ KEY_FUNC,	0,	(voidptr) next_halfpage },	/* ^D */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^E */
X	{ KEY_FUNC,	0,	(voidptr) next_page },		/* ^F */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^G */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^H */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^I - Tab */
X	{ KEY_FUNC,	0,	(voidptr) toggle_tag },		/* ^J - LineFeed */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^K */
X	{ KEY_FUNC,	0,	(voidptr) redraw_menu },	/* ^L */
X	{ KEY_FUNC,	0,	(voidptr) cd_or_edit },		/* ^M - Return */
X	{ KEY_FUNC,	0,	(voidptr) next_line },		/* ^N */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^O */
X	{ KEY_FUNC,	0,	(voidptr) prev_line },		/* ^P */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^Q - Xon */
X	{ KEY_FUNC,	0,	(voidptr) redraw_menu },	/* ^R */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^S - Xoff */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^T */
X	{ KEY_FUNC,	0,	(voidptr) prev_halfpage },	/* ^U */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^V */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^W */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^X */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^Y */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^Z */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* Escape */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \034 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \035 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \036 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \037 */
X
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* space */
X	{ KEY_FUNC,	0,	(voidptr) fork_shell },		/* ! */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* " */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* # */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* $ */
X	{ KEY_FUNC,	0,	(voidptr) fork_shell },		/* % */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* & */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ' */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ( */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* * */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* + */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* , */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* - */
X	{ KEY_FUNC,	0,	(voidptr) cd_dot },		/* . */
X	{ KEY_FUNC,	0,	(voidptr) cd_root },		/* / */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* 0 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* 1 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* 2 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* 3 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* 4 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* 5 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* 6 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* 7 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* 8 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* 9 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* : */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ; */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* < */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* = */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* > */
X	{ KEY_FUNC,	0,	(voidptr) help_screen },	/* ? */
X
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* @ */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* A */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* B */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* C */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* D */
X	{ KEY_FUNC,	0,	(voidptr) edit_tagged },	/* E */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* F */
X	{ KEY_FUNC,	0,	(voidptr) last_page },		/* G */
X	{ KEY_FUNC,	0,	(voidptr) top_line },		/* H */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* I */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* J */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* K */
X	{ KEY_FUNC,	0,	(voidptr) bottom_line },	/* L */
X	{ KEY_FUNC,	0,	(voidptr) middle_line },	/* M */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* N */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* O */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* P */
X	{ KEY_FUNC,	0,	(voidptr) exit_pgm },		/* Q */
X	{ KEY_FUNC,	0,	(voidptr) rm_tagged },		/* R */
X	{ KEY_FUNC,	0,	(voidptr) setup_menu },		/* S */
X	{ KEY_FUNC,	0,	(voidptr) tag_all },		/* T */
X	{ KEY_FUNC,	0,	(voidptr) untag_all },		/* U */
X	{ KEY_FUNC,	0,	(voidptr) view_tagged },	/* V */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* W */
X	{ KEY_FUNC,	0,	(voidptr) command_tagged },	/* X */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* Y */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* Z */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* [ */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \ */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ] */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ^ */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* _ */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* ` */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* a */
X	{ KEY_FUNC,	0,	(voidptr) cd_back },		/* b */
X	{ KEY_FUNC,	0,	(voidptr) cd_prompt },		/* c */
X	{ KEY_FUNC,	0,	(voidptr) cd_file },		/* d */
X	{ KEY_FUNC,	0,	(voidptr) edit_file },		/* e */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* f */
X	{ KEY_UNDEF,	0,	(voidptr) first_page },		/* g */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* h */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* i */
X	{ KEY_FUNC,	0,	(voidptr) next_line },		/* j */
X	{ KEY_FUNC,	0,	(voidptr) prev_line },		/* k */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* l */
X	{ KEY_FUNC,	0,	(voidptr) toggle_tag },		/* m */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* n */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* o */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* p */
X	{ KEY_FUNC,	0,	(voidptr) exit_pgm },		/* q */
X	{ KEY_FUNC,	0,	(voidptr) rm_file },		/* r */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* s */
X	{ KEY_FUNC,	0,	(voidptr) first_page },		/* t */
X	{ KEY_FUNC,	0,	(voidptr) cd_dotdot },		/* u */
X	{ KEY_FUNC,	0,	(voidptr) view_file },		/* v */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* w */
X	{ KEY_FUNC,	0,	(voidptr) command_file },	/* x */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* y */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* z */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* { */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* | */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* } */
X	{ KEY_FUNC,	0,	(voidptr) cd_home },		/* ~ */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* Delete */
X
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0200 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0201 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0202 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0203 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0204 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0205 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0206 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0207 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0210 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0211 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0212 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0213 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0214 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0215 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0216 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0217 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0220 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0221 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0222 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0223 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0224 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0225 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0226 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0227 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0230 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0231 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0232 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0233 - CSI */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0234 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0235 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0236 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0237 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0240 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0241 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0242 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0243 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0244 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0245 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0246 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0247 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0250 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0251 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0252 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0253 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0254 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0255 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0256 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0257 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0260 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0261 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0262 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0263 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0264 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0265 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0266 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0267 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0270 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0271 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0272 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0273 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0274 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0275 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0276 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0277 */
X
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0300 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0301 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0302 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0303 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0304 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0305 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0306 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0307 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0310 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0311 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0312 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0313 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0314 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0315 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0316 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0317 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0320 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0321 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0322 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0323 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0324 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0325 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0326 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0327 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0330 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0331 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0332 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0333 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0334 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0335 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0336 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0337 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0340 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0341 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0342 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0343 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0344 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0345 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0346 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0347 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0350 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0351 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0352 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0353 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0354 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0355 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0356 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0357 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0360 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0361 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0362 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0363 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0364 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0365 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0366 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0367 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0370 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0371 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0372 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0373 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0374 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0375 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0376 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0377 */
X
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0400 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0401 - KEY_BREAK */
X	{ KEY_FUNC,	0,	(voidptr) next_line },		/* \0402 - KEY_DOWN */
X	{ KEY_FUNC,	0,	(voidptr) prev_line },		/* \0403 - KEY_UP */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0404 - KEY_LEFT */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0405 - KEY_RIGHT */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0406 - KEY_HOME */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0407 - KEY_BACKSPACE */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0410 - KEY_F0 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0411 - KEY_F1 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0412 - KEY_F2 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0413 - KEY_F3 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0414 - KEY_F4 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0415 - KEY_F5 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0416 - KEY_F6 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0417 - KEY_F7 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0420 - KEY_F8 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0421 - KEY_F9 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0422 - KEY_F10 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0423 - KEY_F11 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0424 - KEY_F12 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0425 - KEY_F13 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0426 - KEY_F14 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0427 - KEY_F15 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0430 - KEY_F16 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0431 - KEY_F17 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0432 - KEY_F18 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0433 - KEY_F19 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0434 - KEY_F20 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0435 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0436 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0437 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0440 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0441 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0442 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0443 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0444 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0445 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0446 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0447 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0450 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0451 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0452 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0453 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0454 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0455 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0456 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0457 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0460 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0461 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0462 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0463 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0464 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0465 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0466 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0467 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0470 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0471 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0472 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0473 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0474 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0475 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0476 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0477 */
X
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0500 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0501 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0502 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0503 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0504 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0505 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0506 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0507 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0510 - KEY_DL (delete line) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0511 - KEY_IL (insert line) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0512 - KEY_DC (delete char) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0513 - KEY_IC (insert char or enter insert mode) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0514 - KEY_EI (exit insert mode) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0515 - KEY_CLEAR (clear screen) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0516 - KEY_EOS (clear to end of screen) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0517 - KEY_EOL (clear to end of line) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0520 - KEY_SF (scroll forward) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0521 - KEY_SR (scroll reverse) */
X	{ KEY_FUNC,	0,	(voidptr) next_page },		/* \0522 - KEY_NPAGE (next page) */
X	{ KEY_FUNC,	0,	(voidptr) prev_page },		/* \0523 - KEY_PPAGE (previous page) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0524 - KEY_STAB (set tab) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0525 - KEY_CTAB (clear tab) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0526 - KEY_CATAB (clear all tabs) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0527 - KEY_ENTER (enter or send) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0530 - KEY_SRESET (soft reset) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0531 - KEY_RESET (hard reset) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0532 - KEY_PRINT (print screen) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0533 - KEY_LL (move to last line column 0) */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0534 - KEY_PF1 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0535 - KEY_PF2 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0536 - KEY_PF3 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0537 - KEY_PF4 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0540 - KEY_Pad0 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0541 - KEY_Pad1 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0542 - KEY_Pad2 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0543 - KEY_Pad3 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0544 - KEY_Pad4 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0545 - KEY_Pad5 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0546 - KEY_Pad6 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0547 - KEY_Pad7 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0550 - KEY_Pad8 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0551 - KEY_Pad9 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0552 - KEY_PadEnter */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0553 - KEY_PadMinus */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0554 - KEY_PadPeriod */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0555 - KEY_PadComma */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0556 - KEY_Pad00 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0557 - KEY_BackTab */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0560 - KEY_Find */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0561 - KEY_InsertHere */
X	{ KEY_FUNC,	0,	(voidptr) rm_file },		/* \0562 - KEY_Remove */
X	{ KEY_FUNC,	0,	(voidptr) toggle_tag },		/* \0563 - KEY_Select */
X	{ KEY_FUNC,	0,	(voidptr) prev_page },		/* \0564 - KEY_PrevScreen */
X	{ KEY_FUNC,	0,	(voidptr) next_page },		/* \0565 - KEY_NextScreen */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0566 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0567 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0570 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0571 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0572 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0573 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0574 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0575 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0576 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0577 */
X
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0600 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0601 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0602 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0603 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0604 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0605 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0606 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0607 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0610 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0611 - KEY_SF1 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0612 - KEY_SF2 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0613 - KEY_SF3 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0614 - KEY_SF4 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0615 - KEY_SF5 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0616 - KEY_SF6 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0617 - KEY_SF7 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0620 - KEY_SF8 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0621 - KEY_SF9 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0622 - KEY_SF10 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0623 - KEY_SF11 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0624 - KEY_SF12 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0625 - KEY_SF13 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0626 - KEY_SF14 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0627 - KEY_SF15 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0630 - KEY_SF16 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0631 - KEY_SF17 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0632 - KEY_SF18 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0633 - KEY_SF19 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0634 - KEY_SF20 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0635 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0636 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0637 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0640 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0641 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0642 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0643 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0644 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0645 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0646 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0647 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0650 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0651 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0652 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0653 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0654 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0655 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0656 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0657 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0660 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0661 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0662 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0663 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0664 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0665 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0666 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0667 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0670 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0671 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0672 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0673 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0674 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0675 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0676 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0677 */
X
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0700 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0701 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0702 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0703 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0704 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0705 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0706 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0707 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0710 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0711 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0712 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0713 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0714 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0715 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0716 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0717 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0720 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0721 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0722 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0723 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0724 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0725 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0726 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0727 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0730 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0731 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0732 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0733 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0734 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0735 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0736 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0737 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0740 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0741 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0742 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0743 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0744 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0745 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0746 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0747 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0750 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0751 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0752 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0753 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0754 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0755 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0756 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0757 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0760 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0761 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0762 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0763 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0764 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0765 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0766 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0767 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0770 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0771 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0772 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0773 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0774 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0775 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0776 */
X	{ KEY_UNDEF,	0,	(voidptr) NULL },		/* \0777 */
X	};
END_OF_FILE
  if test 26960 -ne `wc -c <'defkeys.h'`; then
    echo shar: \"'defkeys.h'\" unpacked with wrong size!
  fi
  # end of 'defkeys.h'
fi
if test -f 'fileops.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fileops.c'\"
else
  echo shar: Extracting \"'fileops.c'\" \(13765 characters\)
  sed "s/^X//" >'fileops.c' <<'END_OF_FILE'
X/*
X *	fileops.c - display directory menu
X *
X * This software is Copyright (c) 1989, 1990, 1991 by Patrick J. Wolfe.
X *
X * Permission is hereby granted to copy, distribute or otherwise 
X * use any part of this package as long as you do not try to make 
X * money from it or pretend that you wrote it.  This copyright 
X * notice must be maintained in any copy made.
X *
X * Use of this software constitutes acceptance for use in an AS IS 
X * condition. There are NO warranties with regard to this software.  
X * In no event shall the author be liable for any damages whatsoever 
X * arising out of or in connection with the use or performance of this 
X * software.  Any use of this software is at the user's own risk.
X *
X * If you make modifications to this software that you feel 
X * increases it usefulness for the rest of the community, please 
X * email the changes, enhancements, bug fixes as well as any and 
X * all ideas to me. This software is going to be maintained and 
X * enhanced as deemed necessary by the community.
X *              
X *              Patrick J. Wolfe
X *              uunet!uiucuxc!kailand!pwolfe
X *              pwolfe at kailand.kai.com
X */
X
X#include "config.h"
X
Xextern long sixmonthsago;
Xextern int opt_dot_order, opt_dotdir_order, opt_dir_order, opt_hide_dotdot,
X	opt_show_filetype, opt_show_symlinks;
Xextern int topptr, curptr, lastptr, COLS, namebufleft;
Xextern char *sys_errlist[], errormsg[], *namebuf, *monthtable[];
X
Xextern WINDOW *headwin, *datawin, *helpwin;
X
Xstruct stat sb;
Xstruct dblock cwd[MAXDIRSIZE];
Xstruct namelist lidlist[MAXLID];
Xstruct namelist gidlist[MAXGID];
Xint lidend = -1, gidend = -1, hidden_ctr;
Xchar currdir[MAXPATHLEN], prevdir[MAXPATHLEN];
Xchar *emptystring = "", *nbptr;
X
X
Xvoid
Xstatfile (ctr)
Xint	ctr;
X{
Xstruct passwd *pb;
Xstruct group *gb;
Xstruct tm *tb;
Xstruct stat sb2;
Xint ctr2, permend = 0;
X#ifdef sequent
Xint ctr3;
X#endif
X#ifdef S_IFLNK
Xchar ucblink[MAXPATHLEN];
X#ifdef sequent
Xchar attlink[MAXPATHLEN];
X#endif
X#endif
Xchar *ptr2;
X
X
X#ifdef S_IFLNK
Xif (opt_show_symlinks)
X	ctr2 = lstat (cwd[ctr].name, &sb);	/* if showing links, then use "lstat()" to get status of the link */
Xelse
X#endif
X	ctr2 = stat (cwd[ctr].name, &sb);
X
Xif (ctr2 != 0) {
X	cwd[ctr].size = -1;
X	cwd[ctr].selected = 0;	/* unselect it */
X	if (errno == ENOENT) {	/* store error message for display */
X		for (cwd[ctr].link = nbptr, ptr2 = "deleted";
X			(namebufleft > 0) && ((*nbptr = *ptr2) != '\0');
X			namebufleft--, nbptr++, ptr2++);
X		/* move to the next character in the file name buffer */
X		namebufleft--;
X		nbptr++;
X		}
X	else	{
X		for (cwd[lastptr].link = nbptr, ptr2 = sys_errlist[errno];
X			(namebufleft > 0) && ((*nbptr = *ptr2) != '\0');
X			namebufleft--, nbptr++, ptr2++);
X
X		/* move to the next character in the file name buffer */
X		namebufleft--;
X		nbptr++;
X		}
X	if (namebufleft <= 0) {
X		fprintf (stderr, "file name buffer is too small - raise and recompile scan\n");
X		die ();
X		}
X	return;
X	}
X
X/* if this hasn't changed - don't waste any more time */
Xif ((cwd[ctr].size != -1) && (cwd[ctr].ctime == sb.st_ctime)) {
X	return;	
X	}
X
X/* make link point to an empty string, so we don't have to check for NULL */
Xcwd[ctr].link = emptystring;
X
X/*
X * determine filetype - we want to do this first, because if it's a symbolic
X * link, we would prefer info about the file being pointed to
X */
Xcwd[ctr].type = sb.st_mode & S_IFMT;
X
Xif (cwd[ctr].type == S_IFREG) {
X	cwd[ctr].perms[0] = '-';
X	}
Xelse if (cwd[ctr].type == S_IFDIR) {
X	cwd[ctr].perms[0] = 'd';
X	}
Xelse if (cwd[ctr].type == S_IFBLK) {
X	cwd[ctr].perms[0] = 'b';
X	}
Xelse if (cwd[ctr].type == S_IFCHR) {
X	cwd[ctr].perms[0] = 'c';
X	}
X
X#ifdef S_IFSOCK
Xelse if (cwd[ctr].type == S_IFSOCK) {
X	cwd[ctr].perms[0] = 's';
X	}
X#endif /* S_IFSOCK */
X
X#ifdef S_IFIFO
Xelse if (cwd[ctr].type == S_IFIFO) {
X	cwd[ctr].perms[0] = 'f';
X	}
X#endif /* S_IFIFO */
X
X#ifdef S_IFLNK
X
X#ifdef sequent
X/* check for conditional symbolic link before regular symbolic link */
Xelse if ((cwd[ctr].type == S_IFLNK) && (sb.st_spare4[0] == 1)) {
X	if (stat (cwd[ctr].name, &sb2) == 0) {
X		BCOPY ((char *) &sb2, (char *)&sb, sizeof (struct stat));	/* use stats of the pointed at thing */
X		cwd[ctr].type = sb.st_mode & S_IFMT;	/* get the actual file type */
X		}
X	cwd[ctr].perms[0] = 'l';
X	if (((ctr2 = readclink (cwd[ctr].name, ucblink, MAXPATHLEN, U_UCB)) == -1) 
X	 || ((ctr3 = readclink (cwd[ctr].name, attlink, MAXPATHLEN, U_ATT)) == -1)) {
X		for (cwd[lastptr].link = nbptr, ptr2 = sys_errlist[errno];
X			(namebufleft > 0) && ((*nbptr = *ptr2) != '\0');
X			namebufleft--, nbptr++, ptr2++);
X
X		/* move to the next character in the file name buffer */
X		namebufleft--;
X		nbptr++;
X		}
X	else	{
X		ucblink[ctr2] = '\0';	/* readclink does not null terminate it's filename */
X		attlink[ctr3] = '\0';	/* readclink does not null terminate it's filename */
X		for (cwd[lastptr].link = nbptr, ptr2 = " -> ucb=";
X			(namebufleft > 0) && ((*nbptr = *ptr2) != '\0');
X			namebufleft--, nbptr++, ptr2++);
X		for (ptr2 = ucblink;
X			(namebufleft > 0) && ((*nbptr = *ptr2) != '\0');
X			namebufleft--, nbptr++, ptr2++);
X		for (ptr2 = " att=";
X			(namebufleft > 0) && ((*nbptr = *ptr2) != '\0');
X			namebufleft--, nbptr++, ptr2++);
X		for (ptr2 = attlink;
X			(namebufleft > 0) && ((*nbptr = *ptr2) != '\0');
X			namebufleft--, nbptr++, ptr2++);
X		namebufleft--;
X		nbptr++;
X		}
X	if (namebufleft <= 0) {
X		fprintf (stderr, "file name buffer is too small - raise and recompile scan\n");
X		die ();
X		}
X	}
X#endif /* sequent */
X
Xelse if (cwd[ctr].type == S_IFLNK) {
X	if (stat (cwd[ctr].name, &sb2) == 0) {
X		BCOPY ((char *) &sb2, (char *)&sb, sizeof (struct stat));	/* use stats of the pointed at thing */
X		cwd[ctr].type = sb.st_mode & S_IFMT;	/* get the actual file type */
X		}
X	cwd[ctr].perms[0] = 'l';
X	if ((ctr2 = readlink (cwd[ctr].name, ucblink, MAXPATHLEN)) == -1) {
X		for (cwd[lastptr].link = nbptr, ptr2 = sys_errlist[errno];
X			(namebufleft > 0) && ((*nbptr = *ptr2) != '\0');
X			namebufleft--, nbptr++, ptr2++);
X
X		/* move to the next character in the file name buffer */
X		namebufleft--;
X		nbptr++;
X		}
X	else	{
X		ucblink[ctr2] = '\0';	/* readlink does not null terminate it's filename */
X		for (cwd[lastptr].link = nbptr, ptr2 = " -> ";
X			(namebufleft > 0) && ((*nbptr = *ptr2) != '\0');
X			namebufleft--, nbptr++, ptr2++);
X		for (ptr2 = ucblink;
X			(namebufleft > 0) && ((*nbptr = *ptr2) != '\0');
X			namebufleft--, nbptr++, ptr2++);
X		namebufleft--;
X		nbptr++;
X		}
X	if (namebufleft <= 0) {
X		fprintf (stderr, "file name buffer is too small - raise and recompile scan\n");
X		die ();
X		}
X	}
X#endif /* S_IFLNK */
X
Xelse	{
X	cwd[ctr].perms[0] = '?';	/* unknown */
X	}
X
Xcwd[ctr].perms[++permend] = (sb.st_mode & 0400 ? 'r' : '-');		/* owners permissions */
Xcwd[ctr].perms[++permend] = (sb.st_mode & 0200 ? 'w' : '-');
Xcwd[ctr].perms[++permend] = ((sb.st_mode & 04000) && (sb.st_mode & 0100) ? 's' :
X			sb.st_mode & 04000 ? 'S' : sb.st_mode & 0100 ? 'x' : '-');
Xcwd[ctr].perms[++permend] = (sb.st_mode & 040 ? 'r' : '-');			/* group permissions */
Xcwd[ctr].perms[++permend] = (sb.st_mode & 020 ? 'w' : '-');
Xcwd[ctr].perms[++permend] = ((sb.st_mode & 02000) && (sb.st_mode & 010) ? 's' :
X			sb.st_mode & 02000 ? 'S' : sb.st_mode & 010 ? 'x' : '-');
Xcwd[ctr].perms[++permend] = (sb.st_mode & 04 ? 'r' : '-');			/* others permissions */
Xcwd[ctr].perms[++permend] = (sb.st_mode & 02 ? 'w' : '-');
Xcwd[ctr].perms[++permend] = ((sb.st_mode & 01000) && (sb.st_mode & 01) ? 't' :
X			sb.st_mode & 01000 ? 'T' : sb.st_mode & 01 ? 'x' : '-');
Xcwd[ctr].perms[++permend] = '\0';
X
Xif (opt_show_filetype && (cwd[ctr].link[0] == '\0')) {
X	if (cwd[ctr].perms[0] == 'd') {
X		cwd[ctr].link = "/";
X		}
X	else if ((cwd[ctr].perms[0] == '-') && ((sb.st_mode & 0111) != 0)) {
X		cwd[ctr].link = "*";
X		}
X	}
X
Xif ((cwd[ctr].owner == -1) || (lidlist[cwd[ctr].owner].number != sb.st_uid)) {
X	for (ctr2 = 0; (cwd[ctr].owner == -1) && (ctr2 <= lidend); ctr2++) {
X		if (lidlist[ctr2].number == sb.st_uid) {
X			cwd[ctr].owner = ctr2;
X			}
X		}
X	if (cwd[ctr].owner == -1) {				/* didn't already have user name */
X		if (lidend >= MAXLID) {				/* store for future files */
X			fprintf (stderr, "MAXLID is too low - reset and recompile\n");
X			die ();
X			}
X		lidend++;
X		cwd[ctr].owner = lidend;
X		lidlist[lidend].number = sb.st_uid;
X		if ((pb = getpwuid(sb.st_uid)) == NULL) {
X			sprintf (lidlist[lidend].name, "%d", sb.st_uid);
X			}
X		else	{
X			strcpy (lidlist[lidend].name, pb->pw_name);
X			}
X		}
X	}
X
Xif ((cwd[ctr].group == -1) || (gidlist[cwd[ctr].group].number != sb.st_gid)) {
X	for (ctr2 = 0; (cwd[ctr].group == -1) && (ctr2 <= gidend); ctr2++) {
X		if (gidlist[ctr2].number == sb.st_gid) {
X			cwd[ctr].group = ctr2;
X			}
X		}
X	if (cwd[ctr].group == -1) {				/* didn't already have group name */
X		if (gidend >= MAXGID) {				/* store for future files */
X			fprintf (stderr, "MAXGID is too low - reset and recompile\n");
X			die ();
X			}
X		gidend++;
X		cwd[ctr].group = gidend;
X		gidlist[gidend].number = sb.st_gid;
X		if ((gb = (struct group *) getgrgid(sb.st_gid)) == (struct group *) NULL) {
X			sprintf (gidlist[gidend].name, "%d", sb.st_gid);
X			}
X		else	{
X			strcpy (gidlist[gidend].name, gb->gr_name);
X			}
X		}
X	}
X
X/* like ls, if it's over six months old, display the year instead of the time */
Xtb = localtime (&sb.st_mtime);
Xif (sb.st_mtime < sixmonthsago)
X	sprintf (cwd[ctr].modtime, "%3s %02d %04d ", monthtable[tb->tm_mon], tb->tm_mday, 1900 + tb->tm_year);
Xelse
X	sprintf (cwd[ctr].modtime, "%3s %02d %02d:%02d", monthtable[tb->tm_mon], tb->tm_mday, tb->tm_hour, tb->tm_min); 
X
Xcwd[ctr].size = sb.st_size;
Xcwd[ctr].ctime = sb.st_ctime;
X}
X
X
Xint
Xsortdirfirst (a, b)
Xstruct	dblock	*a, *b;
X{
Xint aisdir, bisdir;
X
Xif (opt_dir_order != DIR_SORT) {	/* if not mixing dirs and files, sort between dirs and files */
X	if (a->size != -1)
X		aisdir = (a->type == S_IFDIR);
X	else if (stat (a->name, &sb) == 0) 
X		aisdir = ((sb.st_mode & S_IFMT) == S_IFDIR);
X	else
X		aisdir = 0;
X	if (b->size != -1)
X		bisdir = (b->type == S_IFDIR);
X	else if (stat (b->name, &sb) == 0) 
X		bisdir = ((sb.st_mode & S_IFMT) == S_IFDIR);
X	else
X		bisdir = 0;
X	if (aisdir && ! bisdir) {
X		return (opt_dir_order == DIR_LAST ? 1 : -1);
X		}
X	if (! aisdir && bisdir) {
X		return (opt_dir_order == DIR_LAST ? -1 : 1);
X		}
X	}
X
Xif (opt_dot_order != DOT_HIDE) {	/* if not hiding dot files, sort between dot and non-dot files now */
X	if ((a->name[0] == '.') && (b->name[0] != '.')) {
X		return (opt_dot_order == DOT_LAST ? 1 : -1);
X		}
X	else if ((a->name[0] != '.') && (b->name[0] == '.')) {
X		return (opt_dot_order == DOT_LAST ? -1 : 1);
X		}
X	}
X
Xreturn (strncmp (a->name, b->name, 16));	/* sort alphabetically by name */
X}
X
X
Xint
Xsortdotfirst (a, b)
Xstruct	dblock	*a, *b;
X{
Xint aisdir, bisdir;
X
Xif (opt_dot_order != DOT_HIDE) {	/* if not hiding dot files, sort between dot and non-dot files now */
X	if ((a->name[0] == '.') && (b->name[0] != '.')) {
X		return (opt_dot_order == DOT_LAST ? 1 : -1);
X		}
X	else if ((a->name[0] != '.') && (b->name[0] == '.')) {
X		return (opt_dot_order == DOT_LAST ? -1 : 1);
X		}
X	}
X
Xif (opt_dir_order != DIR_SORT) {	/* if not mixing dirs and files, sort between dirs and files */
X	if (a->size != -1)
X		aisdir = (a->type == S_IFDIR);
X	else if (stat (a->name, &sb) == 0) 
X		aisdir = ((sb.st_mode & S_IFMT) == S_IFDIR);
X	else
X		aisdir = 0;
X	if (b->size != -1)
X		bisdir = (b->type == S_IFDIR);
X	else if (stat (b->name, &sb) == 0) 
X		bisdir = ((sb.st_mode & S_IFMT) == S_IFDIR);
X	else
X		bisdir = 0;
X	if (aisdir && ! bisdir) {
X		return (opt_dir_order == DIR_LAST ? 1 : -1);
X		}
X	if (! aisdir && bisdir) {
X		return (opt_dir_order == DIR_LAST ? -1 : 1);
X		}
X	}
X
Xreturn (strncmp (a->name, b->name, 16));	/* sort alphabetically by name */
X}
X
X
Xvoid
Xdo_chdir (dirname)
Xchar	*dirname;
X{
XDIR	*dirp;
Xstruct timeval tp;
Xstruct	direct	*dp;
XFunction *sortroutine;
Xchar *ptr2;
X
Xgettimeofday (&tp, 0);
Xsixmonthsago = tp.tv_sec - (60 * 60 * 24 * 180);		/* time 180 days (6 months) ago */
X
Xhidden_ctr = 0;
X
Xif ((chdir (dirname) == -1) || ((dirp = opendir(".")) == NULL)) {
X	strcpy (errormsg, "could not cd to \"");
X	strcat (errormsg, dirname);
X	strcat (errormsg, "\": ");
X	strcat (errormsg, sys_errlist[errno]);
X	msgupdate ();
X	if (chdir (currdir) != -1) {
X		return;
X		}
X	if (chdir ("/") == -1) {
X		fprintf (stderr, "\r\nscan: fatal error - couldn't cd to %s, %s or /\n",
X			dirname, currdir);
X		die ();
X		}
X	}
X
X/* save previous directory name, get current directory name */
Xstrcpy (prevdir, currdir);
X#ifdef SYSVgetcwd
Xgetcwd (currdir, MAXPATHLEN);
X#else
Xgetwd (currdir);
X#endif /* SYSVgetcwd */
X
X/* start over at beginning of the name buffer */
Xnamebufleft = BUFSIZE;
Xnbptr = namebuf;
X
Xfor (lastptr = 0, dp = readdir(dirp); (lastptr < MAXDIRSIZE) && (dp != NULL); dp = readdir(dirp)) {
X	if (opt_hide_dotdot && (((NAMELEN(dp) == 1) && (dp->d_name[0] == '.'))	/* check if hiding just "." and ".." */
X	  || ((NAMELEN(dp) == 2) && (dp->d_name[0] == '.') && (dp->d_name[1] == '.')) )) {
X		continue;
X		}
X	if ((opt_dot_order == DOT_HIDE) && (dp->d_name[0] == '.')) {	/* check if hiding dot files */
X		hidden_ctr++;
X		continue;
X		}
X
X	/* add filename to file name buffer */
X	for (cwd[lastptr].name = nbptr, ptr2 = dp->d_name;
X		(namebufleft > 0) && ((*nbptr = *ptr2) != '\0');
X		namebufleft--, nbptr++, ptr2++);
X
X	/* move to the next character in the file name buffer */
X	namebufleft--;
X	nbptr++;
X	if (namebufleft <= 0) {
X		fprintf (stderr, "file name buffer is too small - raise and recompile scan\n");
X		die ();
X		}
X
X	/* get status of file now */
X	cwd[lastptr].size = cwd[lastptr].owner = cwd[lastptr].group = -1;
X	statfile (lastptr);
X
X	cwd[lastptr].selected = 0;
X	lastptr++;
X	}
X
Xclosedir (dirp);
X
Xif (opt_dotdir_order == WITH_DIR)
X	sortroutine = sortdirfirst;
Xelse
X	sortroutine = sortdotfirst;
X
Xqsort ((char *) cwd, lastptr, sizeof (struct dblock), sortroutine);
Xlastptr--;
X
Xtopptr = curptr = 0;
Xredraw_menu ();
X}
END_OF_FILE
  if test 13765 -ne `wc -c <'fileops.c'`; then
    echo shar: \"'fileops.c'\" unpacked with wrong size!
  fi
  # end of 'fileops.c'
fi
echo shar: End of archive 1 \(of 3\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 archives.
    rm -f ark[1-9]isdone
else
    echo You still must unpack the following archives:
    echo "        " ${MISSING}
fi
exit 0
exit 0 # Just in case...
-- 
Kent Landfield                   INTERNET: kent at sparky.IMD.Sterling.COM
Sterling Software, IMD           UUCP:     uunet!sparky!kent
Phone:    (402) 291-8300         FAX:      (402) 291-4362
Please send comp.sources.misc-related mail to kent at uunet.uu.net.



More information about the Comp.sources.misc mailing list