Please enable JavaScript to view this site.

A-Shell Development History

The file hook mechanism (this is an early beta release) allows you to establish file "hooks" on specific files and file events. The "hook" is an SBX which is called automatically by A-Shell when the specified event occurs on the file. The SBX may then output auditing information, check for anomalies, enforce rules, export data, essentially whatever it likes.

To establish a hook on a file:

++include ashinc:ashell.def

++include ashinc:hook.def

xcall miamex, MX_FILEHOOK, op, status, file {,fid, handler, events, flags}

Parameters

op  (Num)  [in]

may be one of the following (defined in hook.def):

Symbol

Value

Meaning

HOOKOP_DISABLE

0

disable one (or all) hooks

HOOKUP_ENABLE

1

re-enable one (or all) hooks

HOOKUP_ADD

2

add a new hook

HOOKOP_DEL

3

delete a hook

HOOKOP_APPEVENT

6

call the hook to process an app-defined event

 

status  (Signed Num)  [out]

returns status code:

Value

Meaning

>=0

success

-1

unable to allocate memory for hook table

-2

illegal fspec (must be AMOS-style)

-3

invalid handler syntax

-4

fspec not found (OP 0,1,2,6)

-5

fid not found (OP 0,1,2,6)

-6

opcode not yet implemented

-7

illegal opcode

 

file  (String)  [in]

is the specification of the file whose operations are to be hooked. (Only AMOS-compatible filespecs are currently suported.) Note that with OPs 0, 1 and 3, FILE$ may be "*" to perform the operation on all the hooks in the hook table.

fid  (Num)  [in]

a unique integer identifier for the file, which will be used in any output files to reference the file (more compact than outputting the file spec each time.)

handler  (String)  [in]

depends on the OP. For OP 2 (add), it must specify the handler for the hook, using the following syntax:

SBX:xxxxxx

where xxxxxx is the name of an SBX file, which will be called to process the hook. (see "HOOK SBX SPECIFICATION" below for further details. Note that additional handler types (and corresponding syntax), such as a text file, FIFO, or TCP connection, may be defined later.

For OP 6 (HOOKOP_APPEVENT), the handler parameter may be used to pass an arbitrary string to the hook routine. Typically this may be used to include a message in the hook log file, such as "posting run complete".

events  (B4)  [in]

a bit-field of events to hook, from the following (defined in hook.def):

Symbol

Value

Meaning

HFE_PRE_OPEN

&h00000001

prior to open

HFE_POST_OPEN

&h00000002

after open

HFE_PRE_CLOSE

&h00000004

prior to close

HFE_POST_CLOSE

&h00000008

after close

HFE_PRE_READ

&h00000010

prior to read or get (any)

HFE_POST_READ

&h00000020

after read or get (any)

HFE_PRE_READL

&h00000040

prior to readl or getl

HFE_POST_READL

&h00000080

after readl or getl

HFE_PRE_WRITE

&h00000100

prior to write (or update'record)

HFE_POST_WRITE

&h00000200

after write (or update'record)

HFE_PRE_WRITEL

&h00000400

prior to writel (or create'record)

HFE_POST_WRITEL

&h00000800

after writel (or create'record)

HFE_PRE_ALLOC

&h00002000

prior to allocate

HFE_POST_ALLOC

&h00004000

after allocate

HFE_PRE_KILL

&h00008000

prior to kill

HFE_POST_KILL

&h00010000

after kill

HFE_PRE_SORT

&h00020000

prior to allocate

HFE_POST_SORT

&h00040000

after allocate

HFE_APP_EVENT1

&h10000000

custom application event

 

flags  (B4)  [in]

a bit-field of flags which are passed to the hook routine (as a clue to how the hook should operate, and/or which are used by A-Shell to modify the operation of the hook (from hook.def):

Symbol

Value

Meaning

HFF_PROG

&h00000001

include program name

HFF_SBX

&h00000002

include sbx name

HFF_DATA

&h00000004

include data (for WRITE hook)

HFF_DATA_WAS

&h00000008

include data (prior to write (POST_WRITE only)

HFF_RECNO

&h00000010

include recno

HFF_TIME

&h00000020

include time

HFF_DATE

&h00000040

include date

HFF_USER

&h00000080

include user name

HFF_PID

&h00000100

include process id

HFF_AUTO_DEL

&h00001000

auto delete hook on prog exit