mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-28 21:20:29 +02:00
* 1.9.x fixes
This commit is contained in:
parent
3e7ae43113
commit
5f8f040fdc
@ -2,22 +2,22 @@ Program Example33;
|
|||||||
|
|
||||||
{ Program to demonstrate the Select function. }
|
{ Program to demonstrate the Select function. }
|
||||||
|
|
||||||
Uses linux;
|
Uses BaseUnix;
|
||||||
|
|
||||||
Var FDS : FDSet;
|
Var FDS : sigset_t;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FD_Zero (FDS);
|
fpsigemptyset (FDS);
|
||||||
FD_Set (0,FDS);
|
fpsigaddset (FDS,0);
|
||||||
Writeln ('Press the <ENTER> to continue the program.');
|
Writeln ('Press the <ENTER> to continue the program.');
|
||||||
{ Wait until File descriptor 0 (=Input) changes }
|
{ Wait until File descriptor 0 (=Input) changes }
|
||||||
Select (1,@FDS,nil,nil,nil);
|
fpSelect (1,@FDS,nil,nil,nil);
|
||||||
{ Get rid of <ENTER> in buffer }
|
{ Get rid of <ENTER> in buffer }
|
||||||
readln;
|
readln;
|
||||||
Writeln ('Press <ENTER> key in less than 2 seconds...');
|
Writeln ('Press <ENTER> key in less than 2 seconds...');
|
||||||
FD_Zero (FDS);
|
fpsigemptyset (FDS);
|
||||||
FD_Set (0,FDS);
|
fpsigaddset (FDS,0);
|
||||||
if Select (1,@FDS,nil,nil,2000)>0 then
|
if fpSelect (1,@FDS,nil,nil,2000)>0 then
|
||||||
Writeln ('Thank you !')
|
Writeln ('Thank you !')
|
||||||
{ FD_ISSET(0,FDS) would be true here. }
|
{ FD_ISSET(0,FDS) would be true here. }
|
||||||
else
|
else
|
||||||
|
@ -2,7 +2,7 @@ Program Example33;
|
|||||||
|
|
||||||
{ Program to demonstrate the SelectText function. }
|
{ Program to demonstrate the SelectText function. }
|
||||||
|
|
||||||
Uses linux;
|
Uses Unix;
|
||||||
|
|
||||||
Var tv : TimeVal;
|
Var tv : TimeVal;
|
||||||
|
|
||||||
@ -13,8 +13,8 @@ begin
|
|||||||
{ Get rid of <ENTER> in buffer }
|
{ Get rid of <ENTER> in buffer }
|
||||||
readln;
|
readln;
|
||||||
Writeln ('Press <ENTER> key in less than 2 seconds...');
|
Writeln ('Press <ENTER> key in less than 2 seconds...');
|
||||||
tv.sec:=2;
|
tv.tv_sec:=2;
|
||||||
tv.usec:=0;
|
tv.tv_sec:=0;
|
||||||
if SelectText (Input,@tv)>0 then
|
if SelectText (Input,@tv)>0 then
|
||||||
Writeln ('Thank you !')
|
Writeln ('Thank you !')
|
||||||
else
|
else
|
||||||
|
@ -3,25 +3,25 @@ Program Example35;
|
|||||||
{ Program to demonstrate the
|
{ Program to demonstrate the
|
||||||
OpenDir,ReadDir, SeekDir and TellDir functions. }
|
OpenDir,ReadDir, SeekDir and TellDir functions. }
|
||||||
|
|
||||||
Uses linux;
|
Uses BaseUnix;
|
||||||
|
|
||||||
Var TheDir : PDir;
|
Var TheDir : PDir;
|
||||||
ADirent : PDirent;
|
ADirent : PDirent;
|
||||||
Entry : Longint;
|
Entry : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
TheDir:=OpenDir('./.');
|
TheDir:=fpOpenDir('./.');
|
||||||
Repeat
|
Repeat
|
||||||
Entry:=TellDir(TheDir);
|
// Entry:=fpTellDir(TheDir);
|
||||||
ADirent:=ReadDir (TheDir);
|
ADirent:=fpReadDir (TheDir^);
|
||||||
If ADirent<>Nil then
|
If ADirent<>Nil then
|
||||||
With ADirent^ do
|
With ADirent^ do
|
||||||
begin
|
begin
|
||||||
Writeln ('Entry No : ',Entry);
|
Writeln ('Entry No : ',Entry);
|
||||||
Writeln ('Inode : ',ino);
|
Writeln ('Inode : ',d_fileno);
|
||||||
Writeln ('Offset : ',off);
|
// Writeln ('Offset : ',d_off);
|
||||||
Writeln ('Reclen : ',reclen);
|
Writeln ('Reclen : ',d_reclen);
|
||||||
Writeln ('Name : ',pchar(@name[0]));
|
Writeln ('Name : ',pchar(@d_name[0]));
|
||||||
end;
|
end;
|
||||||
Until ADirent=Nil;
|
Until ADirent=Nil;
|
||||||
Repeat
|
Repeat
|
||||||
@ -29,18 +29,18 @@ begin
|
|||||||
ReadLn (Entry);
|
ReadLn (Entry);
|
||||||
If Entry<>-1 then
|
If Entry<>-1 then
|
||||||
begin
|
begin
|
||||||
SeekDir (TheDir,Entry);
|
// fpSeekDir (TheDir,Entry); // not implemented for various platforms
|
||||||
ADirent:=ReadDir (TheDir);
|
ADirent:=fpReadDir (TheDir^);
|
||||||
If ADirent<>Nil then
|
If ADirent<>Nil then
|
||||||
With ADirent^ do
|
With ADirent^ do
|
||||||
begin
|
begin
|
||||||
Writeln ('Entry No : ',Entry);
|
Writeln ('Entry No : ',Entry);
|
||||||
Writeln ('Inode : ',ino);
|
Writeln ('Inode : ',d_fileno);
|
||||||
Writeln ('Offset : ',off);
|
// Writeln ('Offset : ',off);
|
||||||
Writeln ('Reclen : ',reclen);
|
Writeln ('Reclen : ',d_reclen);
|
||||||
Writeln ('Name : ',pchar(@name[0]));
|
Writeln ('Name : ',pchar(@d_name[0]));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Until Entry=-1;
|
Until Entry=-1;
|
||||||
CloseDir (TheDir);
|
fpCloseDir (TheDir^);
|
||||||
end.
|
end.
|
||||||
|
@ -2,15 +2,15 @@ Program Example36;
|
|||||||
|
|
||||||
{ Program to demonstrate the AssignPipe function. }
|
{ Program to demonstrate the AssignPipe function. }
|
||||||
|
|
||||||
Uses linux;
|
Uses BaseUnix,Unix;
|
||||||
|
|
||||||
Var pipi,pipo : Text;
|
Var pipi,pipo : Text;
|
||||||
s : String;
|
s : String;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Writeln ('Assigning Pipes.');
|
Writeln ('Assigning Pipes.');
|
||||||
If Not assignpipe(pipi,pipo) then
|
If assignpipe(pipi,pipo)<>0 then
|
||||||
Writeln('Error assigning pipes !',LinuxError);
|
Writeln('Error assigning pipes !',fpgeterrno);
|
||||||
Writeln ('Writing to pipe, and flushing.');
|
Writeln ('Writing to pipe, and flushing.');
|
||||||
Writeln (pipo,'This is a textstring');close(pipo);
|
Writeln (pipo,'This is a textstring');close(pipo);
|
||||||
Writeln ('Reading from pipe.');
|
Writeln ('Reading from pipe.');
|
||||||
|
@ -2,7 +2,7 @@ Program Example37;
|
|||||||
|
|
||||||
{ Program to demonstrate the Popen function. }
|
{ Program to demonstrate the Popen function. }
|
||||||
|
|
||||||
uses linux;
|
uses BaseUnix,Unix;
|
||||||
|
|
||||||
var f : text;
|
var f : text;
|
||||||
i : longint;
|
i : longint;
|
||||||
@ -19,10 +19,10 @@ begin
|
|||||||
writeln (f,'exit 2');
|
writeln (f,'exit 2');
|
||||||
writeln (f);
|
writeln (f);
|
||||||
close (f);
|
close (f);
|
||||||
chmod ('test21a',octal (755));
|
fpchmod ('test21a',&755);
|
||||||
popen (f,'./test21a arg1 arg2','W');
|
popen (f,'./test21a arg1 arg2','W');
|
||||||
if linuxerror<>0 then
|
if fpgeterrno<>0 then
|
||||||
writeln ('error from POpen : Linuxerror : ', Linuxerror);
|
writeln ('error from POpen : errno : ', fpgeterrno);
|
||||||
for i:=1 to 10 do
|
for i:=1 to 10 do
|
||||||
writeln (f,'This is written to the pipe, and should appear on stdout.');
|
writeln (f,'This is written to the pipe, and should appear on stdout.');
|
||||||
Flush(f);
|
Flush(f);
|
||||||
|
@ -2,7 +2,7 @@ Program Example38;
|
|||||||
|
|
||||||
{ Program to demonstrate the AssignStream function. }
|
{ Program to demonstrate the AssignStream function. }
|
||||||
|
|
||||||
Uses linux;
|
Uses BaseUnix,Unix;
|
||||||
|
|
||||||
Var Si,So : Text;
|
Var Si,So : Text;
|
||||||
S : String;
|
S : String;
|
||||||
@ -13,7 +13,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
Writeln ('Calling son');
|
Writeln ('Calling son');
|
||||||
Assignstream (Si,So,'./ex38 -son');
|
Assignstream (Si,So,'./ex38 -son');
|
||||||
if linuxerror<>0 then
|
if fpgeterrno<>0 then
|
||||||
begin
|
begin
|
||||||
writeln ('AssignStream failed !');
|
writeln ('AssignStream failed !');
|
||||||
halt(1);
|
halt(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user