Browse Source

Documented most of Unix unit

michael 21 years ago
parent
commit
238ac094dc

+ 1 - 2
docs/linuxex/Makefile

@@ -56,8 +56,7 @@ OBJECTS=ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10 ex11 ex12 ex13 ex14 \
         ex28 ex29 ex30 ex31 ex32 ex33 ex34 ex35 ex36 ex37 ex38 ex39 ex40 \
         ex41 ex42 ex43 ex44 ex45 ex46 ex47 ex48 ex49 ex51 ex52 ex53 ex54 ex55 \
         ex56 ex57 ex58 ex59 ex60 ex61 ex62 ex63  ex64 ex65 ex66 \
-        ex67 ex68 ex69 ex70 ex71 ex72
-# ex73 ex74 ex75 ex76 ex77
+        ex67 ex68 ex69 ex70 ex71 ex72 ex73 ex74 ex75 ex76 ex77 ex78
 
 TEXOBJECTS=$(addsuffix .tex, $(OBJECTS))
 

+ 75 - 71
docs/linuxex/README

@@ -2,75 +2,79 @@ These are the example programs that appear in the FPC documentation.
  
 Units guide, Linux unit :
 
-ex1.pp contains an example of the GetEpochTime function.
-ex2.pp contains an example of the GetTimeOfDay function.
-ex3.pp contains an example of the EpochToLocal function.
-ex4.pp contains an example of the LocalToEpoch function.
-ex5.pp contains an example of the GetTime function.
-ex6.pp contains an example of the GetDate function.
-ex7.pp contains an example of the Execve function.
-ex8.pp contains an example of the Execv function.
-ex9.pp contains an example of the Execvp function.
-ex10.pp contains an example of the Execl function.
-ex11.pp contains an example of the Execle function.
-ex11.pp contains an example of the Execlp function.
-ex13.pp contains an example of the Shell function.
-ex14.pp contains an example of the Fork function.
-ex15.pp contains an example of the Nice, Set- and GetPriority functions.
-ex16.pp contains an example of the GetPid and GetPPid functions.
-ex17.pp contains an example of the GetUid and GetEUid functions.
-ex18.pp contains an example of the GetGid and GetEgid functions.
-ex19.pp contains an example of the fdOpen, fdWrite and fdCLose functions.
-ex20.pp contains an example of the fdRead and fdTuncate functions.
-ex21.pp contains an example of the Link and UnLink functions.
-ex22.pp contains an example of the SymLink and UnLink functions.
-ex23.pp contains an example of the Chmod function.
-ex24.pp contains an example of the Chown function.
-ex25.pp contains an example of the UTime function.
-ex26.pp contains an example of the Access function.
-ex27.pp contains an example of the Umask function.
-ex28.pp contains an example of the FStat function.
-ex29.pp contains an example of the LStat function.
-ex30.pp contains an example of the FSStat function.
-ex31.pp contains an example of the Dup function.
-ex32.pp contains an example of the Dup2 function.
-ex33.pp contains an example of the Select function.
-ex34.pp contains an example of the SelectText function.
-ex35.pp contains an example of the OpenDir, ReadDir Telldir and SeekDir functions.
-ex36.pp contains an example of the AssignPipe function.
-ex37.pp contains an example of the POpen and PClose functions.
-ex38.pp contains an example of the AssignStream function.
-ex39.pp contains an example of the GetDomainName function.
-ex40.pp contains an example of the GetHostName function.
-ex41.pp contains an example of the GetEnv function.
-ex42.pp contains an example of the SysInfo function.
-ex43.pp contains an example of the Uname function.
-ex44.pp contains an example of the Octal function.
-ex45.pp contains an example of the FExpand function.
-ex46.pp contains an example of the FSearch function.
-ex47.pp contains an example of the DirName function.
-ex48.pp contains an example of the BaseName function.
-ex49.pp contains an example of the Glob function.
-ex51.pp contains an example of the StringToPPChar function.
-ex52.pp contains an example of the GetFS function.
-ex53.pp contains an example of the S_ISLNK and related functions.
-ex54.pp contains an example of the IOCtl function.
-ex55.pp contains an example of the TCGetAttr,TCSetAttr,CFMakeRaw functions.
-ex56.pp contains an example of the Shell function.
-ex57.pp contains an example of the SigAction function.
-ex58.pp contains an example of the Signal function.
-ex59.pp contains an example of the Alarm function.
-ex60.pp contains an example of the GetDateTime function.
-ex61.pp contains an example of the CreateShellArgV function.
-ex62.pp contains an example of the ReadLink function.
-ex63.pp contains an example of the FRename function.
-ex64.pp contains an example of the SysInfo function.
-ex64.pp contains an example of the SigRaise function.
-ex66.pp contains an example of the MMap function.
-ex67.pp contains an example of the FSplit function.
-ex68.pp contains an example of the Octal function.
-ex69.pp contains an example of the FNMatch function.
-ex70.pp contains an example of the StringToPPchar function.
-ex71.pp contains an example of the clone function.
-ex72.pp contains an example of the NanoSleep function.
+ex1.pp contains an example of the FpGetEpochTime function.
+ex2.pp contains an example of the FpGetTimeOfDay function.
+ex3.pp contains an example of the FpEpochToLocal function.
+ex4.pp contains an example of the FpLocalToEpoch function.
+ex5.pp contains an example of the FpGetTime function.
+ex6.pp contains an example of the FpGetDate function.
+ex7.pp contains an example of the FpExecve function.
+ex8.pp contains an example of the FpExecv function.
+ex9.pp contains an example of the FpExecvp function.
+ex10.pp contains an example of the FpExecl function.
+ex11.pp contains an example of the FpExecle function.
+ex11.pp contains an example of the FpExeclp function.
+ex13.pp contains an example of the FpShell function.
+ex14.pp contains an example of the FpFork function.
+ex15.pp contains an example of the FpNice, FpSet- and FpGetPriority functions.
+ex16.pp contains an example of the FpGetPid and FpGetPPid functions.
+ex17.pp contains an example of the FpGetUid and FpGetEUid functions.
+ex18.pp contains an example of the FpGetGid and FpGetEgid functions.
+ex19.pp contains an example of the FpOpen, FpWrite and FpCLose functions.
+ex20.pp contains an example of the FpRead and FpTuncate functions.
+ex21.pp contains an example of the FpLink and FpUnLink functions.
+ex22.pp contains an example of the FpSymLink and FpUnLink functions.
+ex23.pp contains an example of the FpChmod function.
+ex24.pp contains an example of the FpChown function.
+ex25.pp contains an example of the FpUTime function.
+ex26.pp contains an example of the FpAccess function.
+ex27.pp contains an example of the FpUmask function.
+ex28.pp contains an example of the FpFStat function.
+ex29.pp contains an example of the FpLStat function.
+ex30.pp contains an example of the FpFSStat function.
+ex31.pp contains an example of the FpDup function.
+ex32.pp contains an example of the FpDup2 function.
+ex33.pp contains an example of the FpSelect function.
+ex34.pp contains an example of the FpSelectText function.
+ex35.pp contains an example of the FpOpenDir, FpReadDir FpTelldir and FpSeekDir functions.
+ex36.pp contains an example of the FpAssignPipe function.
+ex37.pp contains an example of the FpPOpen and PClose functions.
+ex38.pp contains an example of the FpAssignStream function.
+ex39.pp contains an example of the FpGetDomainName function.
+ex40.pp contains an example of the FpGetHostName function.
+ex41.pp contains an example of the FpGetEnv function.
+ex42.pp contains an example of the FpSysInfo function.
+ex43.pp contains an example of the FpUname function.
+ex44.pp contains an example of the FpOctal function.
+ex45.pp contains an example of the FpFExpand function.
+ex46.pp contains an example of the FpFSearch function.
+ex47.pp contains an example of the FpDirName function.
+ex48.pp contains an example of the FpBaseName function.
+ex49.pp contains an example of the FpGlob function.
+ex51.pp contains an example of the FpStringToPPChar function.
+ex52.pp contains an example of the FpGetFS function.
+ex53.pp contains an example of the FpS_ISLNK and related functions.
+ex54.pp contains an example of the FpIOCtl function.
+ex55.pp contains an example of the FpTCGetAttr,TCSetAttr,CFMakeRaw functions.
+ex56.pp contains an example of the FpShell function.
+ex57.pp contains an example of the FpSigAction function.
+ex58.pp contains an example of the FpSignal function.
+ex59.pp contains an example of the FpAlarm function.
+ex60.pp contains an example of the FpGetDateTime function.
+ex61.pp contains an example of the FpCreateShellArgV function.
+ex62.pp contains an example of the FpReadLink function.
+ex63.pp contains an example of the FpFRename function.
+ex64.pp contains an example of the FpSysInfo function.
+ex64.pp contains an example of the FpSigRaise function.
+ex66.pp contains an example of the FpMMap function.
+ex67.pp contains an example of the FpFSplit function.
+ex68.pp contains an example of the FpOctal function.
+ex69.pp contains an example of the FpFNMatch function.
+ex70.pp contains an example of the FpStringToPPchar function.
+ex71.pp contains an example of the Fpclone function.
+ex72.pp contains an example of the FpNanoSleep function.
+ex73.pp contains an example of the FpSleep function.
+ex74.pp contains an example of the FpGetGroups function.
+
 serial.pp contains an example of serial port programming in FPC.
+ex75.pp contains an example of the setsid function.

+ 2 - 6
docs/linuxex/ex30.pp

@@ -2,7 +2,7 @@ program Example30;
 
 { Program to demonstrate the FSStat function. }
 
-uses BaseUnix,Unix;
+uses BaseUnix,Unix,UnixType;
     
 var s : string; 
     info : tstatfs;
@@ -19,18 +19,14 @@ begin
        end;
     writeln;
     writeln ('Result of fsstat on file ''',s,'''.');
-    writeln ('fstype  : ',info.ftype);
+    writeln ('fstype  : ',info.fstype);
     writeln ('bsize   : ',info.bsize);
     writeln ('bfree   : ',info.bfree);
     writeln ('bavail  : ',info.bavail);
     writeln ('files   : ',info.files);
     writeln ('ffree   : ',info.ffree);
-    {$ifdef FreeBSD}
     writeln ('fsid    : ',info.fsid[0]);
-    {$else}
-    writeln ('fsid    : ',info.fsid);
     writeln ('Namelen : ',info.namelen);
-    {$endif}
     write ('Type name of file to do fsstat. (q quits) :');
     readln (s)
     end;

+ 5 - 5
docs/linuxex/ex33.pp

@@ -4,19 +4,19 @@ Program Example33;
 
 Uses BaseUnix;
 
-Var FDS : sigset_t;
+Var FDS : Tfdset;
 
 begin
-  fpsigemptyset (FDS);
-  fpsigaddset (FDS,0);
+  fpfd_zero(FDS);
+  fpfd_set(0,FDS);
   Writeln ('Press the <ENTER> to continue the program.');
   { Wait until File descriptor 0 (=Input) changes }
   fpSelect (1,@FDS,nil,nil,nil);
   { Get rid of <ENTER> in buffer }
   readln;
   Writeln ('Press <ENTER> key in less than 2 seconds...');
-  fpsigemptyset (FDS);
-  fpsigaddset (FDS,0);
+  Fpfd_zero(FDS);
+  FpFd_set (0,FDS);
   if fpSelect (1,@FDS,nil,nil,2000)>0 then 
     Writeln ('Thank you !')
     { FD_ISSET(0,FDS) would be true here. }

+ 17 - 0
docs/linuxex/ex73.pp

@@ -0,0 +1,17 @@
+program example73;
+
+{ Program to demonstrate the FpSleep function. } 
+
+uses BaseUnix;
+
+Var
+  Res : Longint;
+  
+begin
+  Write('Sleep returned : ');
+  Flush(Output);
+  Res:=(fpSleep(10));
+  Writeln(res);
+  If (res<>0) then
+    Writeln('Remaining seconds     : ',res);
+end.

+ 19 - 0
docs/linuxex/ex74.pp

@@ -0,0 +1,19 @@
+program example74;
+
+uses baseunix;
+
+Var
+  P : PGrpArr;
+  C,R,I : Cint;
+  
+begin
+  C:=5;
+  GetMem(P,Sizeof(tgid)*C);
+  FillChar(P^,Sizeof(tgid)*C,0);
+  R:=fpGetGroups(C,P^);
+  If (R>0) then
+    begin
+    For I:=0 to R-1 do
+       Writeln('Group id :',P^[I]);
+    end;
+end.

+ 21 - 0
docs/linuxex/ex79.pp

@@ -0,0 +1,21 @@
+Program Example79;
+
+{ Program to demonstrate the FpExecVP function. }
+
+Uses Unix, strings;
+
+Const Arg0 : PChar = 'ls';
+      Arg1 : Pchar = '-l';
+      
+Var PP : PPchar;
+
+
+begin
+  GetMem (PP,3*SizeOf(Pchar));
+  PP[0]:=Arg0;
+  PP[1]:=Arg1;
+  PP[2]:=Nil;
+  { Execute 'ls -l', with current environment. }
+  { 'ls' is looked for in PATH environment variable.}
+  fpExecvp ('ls',pp);
+end.

+ 13 - 0
docs/linuxex/ex80.pp

@@ -0,0 +1,13 @@
+program example56;
+
+uses Unix;
+
+{ Program to demonstrate the Shell function }
+
+Var S : Longint;
+
+begin
+  Writeln ('Output of ls -l *.pp');
+  S:=fpSystem('ls -l *.pp');
+  Writeln ('Command exited wwith status : ',S);
+end.

+ 1 - 1
docs/linuxex/ex9.pp

@@ -14,7 +14,7 @@ begin
   GetMem (PP,3*SizeOf(Pchar));
   PP[0]:=Arg0;
   PP[1]:=Arg1;
-  PP[3]:=Nil;
+  PP[2]:=Nil;
   { Execute 'ls -l', with current environment. }
   { 'ls' is looked for in PATH environment variable.}
   { Envp is defined in the system unit. }

+ 44 - 0
docs/linuxex/ex91.pp

@@ -0,0 +1,44 @@
+program Example30;
+
+{ Program to demonstrate the FSStat function. }
+
+uses BaseUnix,Unix,UnixType;
+    
+var s : string; 
+    fd : cint;
+    info : tstatfs;
+      
+begin
+  writeln ('Info about current partition : ');
+  s:='.';
+  while s<>'q' do 
+    begin
+    Fd:=fpOpen(S,O_RDOnly);
+    if (fd>=0) then
+      begin
+      if fstatfs (fd,info)<>0 then
+        begin
+        writeln('Fstat failed. Errno : ',fpgeterrno);
+        halt (1);
+        end;
+      FpClose(fd);  
+      writeln;
+      writeln ('Result of fsstat on file ''',s,'''.');
+      writeln ('fstype  : ',info.fstype);
+      writeln ('bsize   : ',info.bsize);
+      writeln ('bfree   : ',info.bfree);
+      writeln ('bavail  : ',info.bavail);
+      writeln ('files   : ',info.files);
+      writeln ('ffree   : ',info.ffree);
+      {$ifdef FreeBSD}
+      writeln ('fsid    : ',info.fsid[0]);
+      {$else}
+      writeln ('fsid    : ',info.fsid[0]);
+      writeln ('Namelen : ',info.namelen);
+      {$endif}
+      write ('Type name of file to do fsstat. (q quits) :');
+      readln (s)
+      
+      end;
+    end;
+end.