home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
online
/
source
/
c
/
compilers
/
Tickle-4.0.sit.hqx
/
Tickle-4.0
/
src
/
XTCL_callback.p
< prev
next >
Wrap
Text File
|
1993-11-18
|
3KB
|
156 lines
{ This source code was written by Tim Endres }
{ Email: time@ice.com. }
{ USMail: 8840 Main Street, Whitmore Lake, MI 48189 }
{ }
{ Some portions of this application utilize sources }
{ that are copyrighted by ICE Engineering, Inc., and }
{ ICE Engineering retains all rights to those sources. }
{ }
{ Neither ICE Engineering, Inc., nor Tim Endres, }
{ warrants this source code for any reason, and neither }
{ party assumes any responsbility for the use of these }
{ sources, libraries, or applications. The user of these }
{ sources and binaries assumes all responsbilities for }
{ any resulting consequences. }
UNIT XTCLEntry;
INTERFACE
USES Types, Memory, Dialogs;
CONST
TCL_OK = 0;
TCL_ERROR = 1;
TCL_RETURN = 2;
TCL_BREAK = 3;
TCL_CONTINUE = 4;
TYPE
Tcl_Interp = Ptr;
ARGV_Ptr = ARRAY[1..50] OF Ptr;
XTCLParmBlk =
RECORD
version: longint; { Version of the Cmd interface. }
result: longint; { CMD's operation result code. }
resultH: Handle; { CMD's result handle. }
cmdRefNum: integer; { Cmd file reference number. }
cmdHandle: Handle; { CMD's command code handle. }
interp: Tcl_Interp; { Interpreter calling this XTCL. }
eval: ProcPtr; { Callback procedure (C) for tcl script evaluation }
modalproc: ModalFilterProcPtr; { Routine for ModalDialog() to keep background. }
reserved: longint;
END;
PROCEDURE PXTCLEntry(argc: longint ; argv: ARGV_Ptr ; xpb: XTCLParmBlk);
PROCEDURE Cstrcpy(tstr: Ptr ; fstr: Ptr);
FUNCTION Cstrlen(str: Ptr): longint;
IMPLEMENTATION
FUNCTION XTCLCallBack(xpb: XTCLParmBlk ; sH: Handle ; rH: Handle ; oH: Handle): longint;
EXTERNAL;
PROCEDURE PXTCLEntry;
VAR
p: Ptr;
length: longint;
result: longint;
rHandle: Handle;
sHandle: Handle;
script: Ptr;
BEGIN
xpb.result := TCL_OK;
script := argv[2];
length := Cstrlen(script);
sHandle := NewHandle(length+1);
rHandle := NewHandle(0);
IF (sHandle <> NIL) AND (rHandle <> NIL)
THEN
BEGIN
p := sHandle^;
BlockMove(script, sHandle^, length);
result := XTCLCallBack(xpb, sHandle, rHandle, NIL);
length := GetHandleSize(rHandle);
p := Pointer(Ord4(sHandle^) + length);
p^ := 0;
SetHandleSize(xpb.resultH, length + 1);
if (MemError = noErr)
THEN
BEGIN
BlockMove(rHandle^, xpb.resultH^, GetHandleSize(rHandle));
p := Pointer(Ord4(xpb.resultH^) + length);
p^ := 0;
END
ELSE
BEGIN
result := TCL_ERROR;
END;
xpb.result := result;
END;
IF (sHandle <> NIL)
THEN
BEGIN
DisposHandle(sHandle);
END;
IF (rHandle <> NIL)
THEN
BEGIN
DisposHandle(rHandle);
END;
END;
PROCEDURE Cstrcpy;
VAR
fp: Ptr;
tp: Ptr;
i: integer;
BEGIN
i := 0;
REPEAT
fp := Pointer(Ord4(fstr) + i);
tp := Pointer(Ord4(tstr) + i);
tp^ := fp^;
i := i + 1;
UNTIL tp^ = 0;
END;
FUNCTION Cstrlen;
VAR
p: Ptr;
i: integer;
BEGIN
i := 0;
REPEAT
p := Pointer(Ord4(str) + i);
i := i + 1;
UNTIL p^ = 0;
Cstrlen := i - 1;
END;
END.