mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 23:06:07 +02:00
* update std handles after initing c
This commit is contained in:
parent
bd64ad0539
commit
65513e55d1
@ -1,3 +1,6 @@
|
|||||||
|
{
|
||||||
|
$Id$
|
||||||
|
}
|
||||||
unit initc;
|
unit initc;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
@ -9,6 +12,7 @@ interface
|
|||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
{$LINKLIB cygwin}
|
{$LINKLIB cygwin}
|
||||||
|
{$linklib kernel32}
|
||||||
|
|
||||||
{ this unit is just ment to run
|
{ this unit is just ment to run
|
||||||
startup code to get C code to work correctly PM }
|
startup code to get C code to work correctly PM }
|
||||||
@ -16,6 +20,9 @@ interface
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
{$i textrec.inc}
|
||||||
|
|
||||||
|
|
||||||
procedure cygwin_crt0(p : pointer);cdecl;external;
|
procedure cygwin_crt0(p : pointer);cdecl;external;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -35,8 +42,30 @@ end;
|
|||||||
|
|
||||||
procedure C_exit(status : longint);popstack;external name '_exit';
|
procedure C_exit(status : longint);popstack;external name '_exit';
|
||||||
|
|
||||||
|
const
|
||||||
|
STD_INPUT_HANDLE = $fffffff6;
|
||||||
|
STD_OUTPUT_HANDLE = $fffffff5;
|
||||||
|
STD_ERROR_HANDLE = $fffffff4;
|
||||||
|
|
||||||
|
function GetStdHandle(nStdHandle:DWORD):longint;external 'kernel32' name 'GetStdHandle';
|
||||||
|
|
||||||
|
procedure UpdateStdHandle(var t:TextRec;var stdHandle:longint;newHandle:longint);
|
||||||
|
{ Check if the stdHandle is the same as the one in the TextRec, then
|
||||||
|
also update the TextRec }
|
||||||
|
begin
|
||||||
|
if t.Handle=stdHandle then
|
||||||
|
t.Handle:=newHandle;
|
||||||
|
stdHandle:=newHandle;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
cygwin_crt0(nil);
|
cygwin_crt0(nil);
|
||||||
|
{ Reinitialize std handles that can be changed }
|
||||||
|
UpdateStdHandle(TextRec(Input),StdInputHandle,GetStdHandle(STD_INPUT_HANDLE));
|
||||||
|
UpdateStdHandle(TextRec(Output),StdOutputHandle,GetStdHandle(STD_OUTPUT_HANDLE));
|
||||||
|
TextRec(StdOut).Handle:=StdOutputHandle;
|
||||||
|
UpdateStdHandle(TextRec(Stderr),StdErrorHandle,GetStdHandle(STD_ERROR_HANDLE));
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
{ should we pass exit code ?
|
{ should we pass exit code ?
|
||||||
@ -44,8 +73,11 @@ finalization
|
|||||||
C_exit(0);
|
C_exit(0);
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.2 2000-07-13 11:33:57 michael
|
Revision 1.3 2000-12-30 17:48:36 peter
|
||||||
+ removed logs
|
* update std handles after initing c
|
||||||
|
|
||||||
|
Revision 1.2 2000/07/13 11:33:57 michael
|
||||||
|
+ removed logs
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user