#####################################################
# RULES FILE FOR GC3.KEY by Graham Wheeler
#####################################################

# Lines that begin with # are treated as comments and ignored,
# as are blank lines
#
# Multiple entries can be specified by separating them with `;' (DOS)
# or `:' (UNIX). Entries can be extended over more than one line by
# putting a backslash \ at the end of each line except the last.

#################################################################
#
#	EDITOR, PAGINATOR AND VIEWER CONFIGURATION
#
# The UTILS area tells gc3 what editor, file paginator, and
# file viewer utilities it should use. If you have an EDITOR,
# PAGER or VIEWER environment variable set, it will take
# precedence over these rules.
#
# The paginator is used for viewing the output of commands.
# You must be able to pipe the output of commands to it, as
# in:
#
#	command | pager
#
# The file viewer is for viewing disk files(files with names).
# In this case you must be able to execute it as:
#
#	viewer file
#
# The rules consist of at least one field, which specifies the 
# exact name of the editor, pager or viewer file. gc3 searches 
# the directory path for each of these in turn, and uses the
# first one it finds. If there is more than one field, the 
# others specify the actual command to use (as opposed to the 
# file name - this allows you to pass flags and other arguments to 
# the editor/pager/viewer).
#
# Alternatively a rule can consist of just a gc3 variable
# name. gc3 will use the variable value if it is non-empty, 
# otherwise it will continue trying the next entry in the list.
#
# The rules are tried in turn until one is successful or the
# list is exhausted.

[UNIXUtils]

Editor = \
		vi	\
	:	joe	\
	:	emacs	\
	:	xedit

Pager = \
		less	less -i		\
	:	more	more -w		\
	:	pg

Viewer = \
		$pager				\
	:	view

Mailer = 	\
		elm	\
	:	pine	\
	:	mailx	\
	:	mail

NewsReader = \
		nn		\
	:	trn	\
	:	rn		\
	;

[DOSUtils]

Editor = \
		B.EXE		b	\
	  ;	ME.EXE		me	\
	  ;	VI.EXE		vi	\
	  ;	EDIT.EXE	edit	\
	  ;	NE.EXE		ne

Pager  =	LIST.COM	list /S	\
	  ;	MORE.EXE	more

Viewer =	LIST.COM	list	\
	  ;	$pager

#############################################################
#
#		ENTER KEY HANDLING
#
# The ACTIONS area specifies what happens when we press 
# ENTER on a file.
#
# Note the use of predefined gc3 variables in the commands,
# in particular:
#
#	$pfile - filename at cursor position in active window
#	$basename - $pfile with any extension stripped off
#	$suffix - the extension of $pfile
#	$pager - the file paginator that gc3 is using
#	$editor - the file editor that gc3 is using
#	$viewprog - the file viewer command that gc3 is using
#
# In addition, the DOS rules can use a variable $base which
# is $pfile without the extension.
# If a line ends with a !, then the command-line editor is
# entered allowing editing of the command before execution;
# otherwise the command is executed immediately.
#
# You can also call a script function by specifying the
# name followed by `@' for the command; e.g. (DOS):
#
#	*.ZIP		viewzip@
#
# would cause the script function `viewzip' to be called
# when ENTER was pressed on a zipfile. Note that arguments
# cannot be passed to the script function - this is a very 
# basic hook.

[UNIXActions]

NameActions = \
		[mM]akefile.*	make -f $pfile !

TypeActions = \
		:tar		tar -tvf $pfile | $pager	\
	:	:cpio		cpio -itv < $pfile | $pager

[UDOSActions]

NameActions = \
		MAKEFILE.*	make -f $pfile !

TypeActions = \
		:tar		tar -tvf $pfile | $pager	\
	:	:cpio		cpio -itv < $pfile | $pager

[DOSActions]

NameActions = \
		MAKEFILE	make -f $pFile !	\
	;	FAQ		$viewprog $pFile 	\
	;	READ*.*		$viewprog $pFile 	\
	;	*.AU		plany $pfile		\
	;	*.BAK		del $pFile	       	\
	;	*.BAT		$pFile !		\
	;	*.C 		$editor $pFile		\
	;	*.CMF		playcmf $pfile		\
	;	*.COM		$pFile !		\
	;	*.DL		dl_view $pfile	       	\
	;	*.DVI		v $basename	       	\
	;	*.EXE		$pFile !		\
	;	*.FLI		aaplay $pfile		\
	;	*.GIF		svga $pfile		\
	;	*.GL		grasprt $pfile		\
	;	*.H		$editor $pFile		\
	;	*.IFF		plany $pfile		\
	;	*.LZH		lha x $pfile | $pager	\
	;	*.MID		playmid $pfile		\
	;	*.MOD		mp $pfile		\
	;	*.OBJ		strings $pFile | $pager	\
	;	*.POV		povray +i$pfile		\
	;	*.SND		plany $pfile		\
	;	*.TEX		latex $basename	       	\
	;	*.VOC		plany $pfile		\
	;	*.WAV		plany $pfile		\
	;	*.ZOO		zoo x $basename		\
	;	*.INF		info -d $ppath -f $pfile

TypeActions =

#####################################################
#
#		NON-TEE-ABLE COMMANDS
#
# The EXCEPT area lists the commands which cannot have
# their output redirected (UNIX only).

[UNIXExcept]

CantTee = 	vi	\
	:	elm	\
	:	nn	\
	:	ftp	\
	:	telnet	\
	:	cu	\
	:	sh	\
	:	ksh	\
	:	csh	\
	:	dos	\
	:  less	\
	:  more	\
	:  pg

########################################################################
#
#		INTERNAL CONTAINER RULES
#
# Unlike all of the rules above which mean nothing to gc3 
# itself (they are used purely by the code in gc3.key), the
# rules in this section are handled by gc3 itself. These rules
# specify how gc3 can handle container files such as tar, shar,
# cpio, zip, arc, etc files. The rules tell gc3 how to extract,
# update and delete individual components of the different types
# of containers (add, extract and delete fields), how to recognise
# type of file (name and type fields), and how to get the name,
# size, date and time info (other fields). Each rule consists of
# a number of items, namely:
#
#	name - a pattern matched against the name
#	type - a pattern matched against the output of `file f'
#			where f is the container file
#
# Both tests are applied and both must pass for the container
# to be associated with a rule; however, either or both of the
# tests may be empty which implies success.
#
#	list - the command to run to get a list of the contents
#			of the container
#
# In the commands, @x is short for the container file path, and @f
# for the file to be added/deleted/extracted. @b represents the name
# of @f with any path prefix removed; this is useful when the container
# itself contains subdirectories.
#
#	fields - the total number of whitespace separated fields in the
#		contents listing produced by the list command above
#
#	item - the field containing the component file name
#
# Note that fields are numbered from 1.
#
#	size - the field containing the component file size
#
# The date and time are parsed using the information given in
# six items; each of these specifies a field number and an offset
# within the field, separated by a comma. Each field should be
# numeric except the month which may be numeric or a recognisable
# 3-or-more letter code. The items are:
#
#	year	- the field and offset giving the year
#	month	- the field and offset giving the month
#	day	- the field and offset giving the day
#	hour	- the field and offset giving the hour
#	min	- the field and offset giving the minutes
#	sec	- the field and offset giving the seconds
#
# This is best illustrated by example. Here is a sample line
# that results from running `pkunzip -v ' under DOS on a zip file:
#
#   9264  Implode   4324  54%  12-13-93  14:56  e170a621 ---  README
#
# Clearly, there are 9 fields, the size is given by the first and
# the name by the last. The date is given by the 5th field, with
# the month starting at offset 1, the day at offset 4, and the
# year at offset 7. Similarly, the time is given by the 6th field,
# with the hour at offset 1 and the minutes at offset 4. See DOSRule_1
# below for the actual rule.
#
# Fields that don't exist should have zero entries, or the item
# should be left out completely of the rule. Each rule must have
# at least either a name or a type item. The rules must be numbered
# sequentially from 1, with the prefix DOSRule_ or UNIXRule_. gc3
# reads these in order from 1 until a failure, so if you have rule 1
# and rule 3 it will fail on rule 2 and never get to 3.


[DOSRule_1]

# Zip files under DOS, using PKWare pkzip/pkunzip.

name	= *.ZIP
#type	=
list	= pkunzip -v @x
fields	= 9
item	= 9
size	= 1
year	= 5,7
month	= 5,1
day	= 5,4
hour	= 6,1
min	= 6,4
#sec	= 0,0
add	= pkzip -a @x @f
extract = pkunzip -do @x @b
delete	= pkzip -d @x @f

[DOSRule_2]

# ARC files under DOS, using PKWare pkarc/pkxarc

name	= *.ARC
#type	=
list	= pkxarc -v @x
fields	= 8
item	= 1
size	= 2
year	= 6,7
month	= 6,1
day	= 6,4
hour	= 7,1
min	= 7,4
#sec	= 7,7
add	= 
extract = pkxarc -x @x @f
delete	= 

[UNIXRule_1]

# zip file handler using portable zip 1.1

name	= zip$
type	=
list	= unzip -v @x
fields	= 8
item	= 8
size	= 1
year	= 5,7
month	= 5,1
day	= 5,4
hour	= 6,1
min	= 6,4
sec	= 0,0
add	= zip -u @x @f
extract = unzip -x @x @f
delete	= zip -d @x @f

[UNIXRule_2]

# System V tar file handler

name	= 
type	= tar
list	= tar tvf @x
fields	= 7
item	= 7
size	= 2
year	= 6,1
month	= 3,1
day	= 4,1
hour	= 5,1
min	= 5,4
sec	= 0,0
add	= tar uf @x @f
extract = tar xf @x @f
delete	= tar df @x @f

[UNIXRule_3]

# System V ASCII cpio file handler

name	= 
type	= expanded ASCII cpio
list	= cpio -ictv < @x
fields	= 10
item	= 10
size	= 5
year	= 9,1
month	= 6,1
day	= 7,1
hour	= 8,1
min	= 8,4
sec	= 0,0
add	= basename @f | cpio -ocA -O @x
extract = cpio -ic @f < @x
delete =

[UNIXRule_4]

# System V normal cpio file handler

name	= 
type	= cpio
list	= cpio -itv < @x
fields	= 10
item	= 10
size	= 5
year	= 9,1
month	= 6,1
day	= 7,1
hour	= 8,1
min	= 8,4
sec	= 0,0
add	= basename @f | cpio -oA -O @x
extract = cpio -i @f < @x
delete =

#[UNIXRule_5]

# Remote connect with rsh - experimental - does not work
# with subdirectories. To use this you need to create a
# local file with the machine name followed by a colon. For
# example, to access my home directory on gramix I could use
# `touch "gramix:"'. Then by pressing ENTER on this file I
# `connect' to my remote home directory.

#name	= :$
#type	=
#list	= rsh @x ls -l /home/gram
#list	= rsh gramix ls -l /home/gram
#fields= 9
#item	= 9
#size	= 5
#year	= 0,0
#month	= 0,0
#day	= 0,0
#hour	= 0,0
#min	= 0,0
#sec	= 0,0
#add	= rcp @f @x
#extract = rcp @x@f .
#delete = rsh @x rm @f
#delete = rsh gramix rm @f

########################## FINIS #################################
