SYN_GLOBALHOOKS_OPEN
WTSupported in traditional Synergy on Windows
|
WNSupported in Synergy .NET on Windows
|
USupported on UNIX
|
|
subroutine syn_globalhooks_open
in channel, n
in modes, OPModes
in filename, a <your implementation>
Arguments
channel
The channel number of the file that was opened.
modes
The open mode of the file that was opened.
filename
The full name of the file that was opened.
Discussion
SYN_GLOBALHOOKS_OPEN enables you to implement global I/O hooks.
Unlike the other system-supplied subroutines, SYN_GLOBALHOOKS_OPEN is not written for you and you don’t call this routine yourself. Instead, you write your own SYN_GLOBALHOOKS_OPEN routine with the specified arguments to do whatever you need it to do. If implemented, SYN_GLOBALHOOKS_OPEN is called automatically on every file open. Based on the parameters received from the OPEN statement, your SYN_GLOBALHOOKS_OPEN implementation determines which file opens will activate I/O hooks.
The SYN_GLOBALHOOKS_OPEN() subroutine that you write must include one of the IOHooks constructors to enable I/O hooks. (However, its existence is not required to use I/O hooks in general—just if you want to use them globally.) See Global I/O hooks for more information.
SYN_GLOBALHOOKS_OPEN is not a member of Synergex.SynergyDE.IOExtensions.IOHooks, so it should not be implemented in the Synergex.SynergyDE.IOExtensions namespace. Instead, it belongs in the global namespace, synglobal. |
The OPModes enumeration follows, for your convenience:
public enum OPModes OPEN_INPUT, ^x(00001) OPEN_OUTPUT, ^x(00002) OPEN_UPDATE, ^x(00004) OPEN_APPEND, ^x(00008) OPEN_SEQUENTIAL, ^x(00010) OPEN_RELATIVE, ^x(00020) OPEN_INDEXED, ^x(00040) OPEN_BLOCK, ^x(00080) OPEN_PRINT, ^x(00100) OPEN_DEFAULT, ^x(00200) OPEN_EXCLRW, ^x(00400) OPEN_EXCLW, ^x(00800) OPEN_NOLOCK, ^x(01000) endenum
Examples
The following is a sample SYN_GLOBALHOOKS_OPEN routine. I/O hooks will be activated upon opening ISAM or relative files open for update, excluding non-record locking files (which includes files open for exclusive access).
subroutine syn_globalhooks_open
in channel, n
in modes, OPModes
in filename, a
global common
global_hooks, i1
global_chan, d3
record
chn, d3
username, a30, "Unknown"
userlen, d5
proc
;
; OPModes.OPEN_NOLOCK is included in the following:
; OPModes.OPEN_EXCLRW
; OPModes.OPEN_EXCLW
;
if ((int)(modes & OPModes.OPEN_UPDATE) &&
& ((int)(modes & OPModes.OPEN_INDEXED) ||
& (int)(modes & OPModes.OPEN_RELATIVE)) &&
& !((int)(modes & OPModes.OPEN_NOLOCK)))
begin
;
; Open/create lock file once (by convention for this example)
;
if (.not.global_hooks)
begin
.ifdef DYNAMIC_INTERACT
chn = %syn_freechn(100, 200)
try
open(chn, u:i, "DBLDIR:hooked_locks")
catch (e, @NoFileFoundException)
begin
xcall isamc("DBLDIR:hooked_locks", 118, 2, "s=1,l=54,dups", "s=55,l=8,type=t")
chn = %syn_freechn(100, 200)
open(chn, u:i, "DBLDIR:hooked_locks")
end
endtry
.else
chn = %syn_freechn(100, 200)
open(chn, a, "hooked_locks.log")
.endc
global_hooks = 1
global_chan = chn
end
xcall getlog("SYNUSER", username, userlen)
;
; Establish I/O hooks on this channel
; (my I/O hooks constructor follows)
; (void)new global_hooks(channel, global_chan, filename, username)
end
xreturn
end