diff options
| -rw-r--r-- | UChecksum.pas | 18 | ||||
| -rw-r--r-- | UChecksumDruid.pas | 18 | ||||
| -rw-r--r-- | UChmod.pas | 2 | ||||
| -rw-r--r-- | UChown.pas | 12 | ||||
| -rw-r--r-- | UConfig.pas | 20 | ||||
| -rw-r--r-- | UCore.pas | 100 | ||||
| -rw-r--r-- | UCoreClasses.pas | 32 | ||||
| -rw-r--r-- | UCoreUtils.pas | 72 | ||||
| -rw-r--r-- | UEngines.pas | 352 | ||||
| -rw-r--r-- | UGlibC_compat.pas | 267 | ||||
| -rw-r--r-- | UGnome.pas | 4 | ||||
| -rw-r--r-- | ULibc.pas | 945 | ||||
| -rw-r--r-- | UMain.pas | 34 | ||||
| -rw-r--r-- | UPreferences.pas | 4 | ||||
| -rw-r--r-- | USearch.pas | 16 | ||||
| -rw-r--r-- | UViewer.pas | 2 | ||||
| -rw-r--r-- | tuxcmd.dpr | 2 | ||||
| -rw-r--r-- | vfs/UVFSCore.pas | 90 |
18 files changed, 1323 insertions, 667 deletions
diff --git a/UChecksum.pas b/UChecksum.pas index 5f0e4db..c6099a6 100644 --- a/UChecksum.pas +++ b/UChecksum.pas @@ -63,7 +63,7 @@ var implementation -uses ULocale, UCoreUtils, Libc, UCore, DateUtils; +uses ULocale, UCoreUtils, ULibc, UCore, DateUtils; type TFileListItem = class CRC: LongWord; @@ -217,8 +217,8 @@ begin else if SFVPresent then FileList.Columns[1].Caption := 'CRC-32'; try - Buffer := Libc.malloc(ChksumBlockSize); - Libc.memset(Buffer, 0, ChksumBlockSize); + Buffer := malloc(ChksumBlockSize); + memset(Buffer, 0, ChksumBlockSize); except Application.MessageBox(LANGAnErrorOccuredWhileInitializingMemoryBlock, [mbOK], mbError, mbNone, mbOK); Exit; @@ -227,7 +227,7 @@ begin FD := Engine.OpenFile(FileName, omRead, Error); if Error <> 0 then begin Application.MessageBox(Format(LANGAnErrorOccuredWhileOpeningFileSS, [StrToUTF8(ExtractFileName(FileName)), GetErrorString(Error)]), [mbOK], mbError, mbNone, mbOK); - Libc.free(Buffer); + libc_free(Buffer); Exit; end; s := ''; @@ -237,7 +237,7 @@ begin if Error <> 0 then begin Application.MessageBox(Format(LANGAnErrorOccuredWhileReadingFileSS, [StrToUTF8(ExtractFileName(FileName)), GetErrorString(Error)]), [mbOK], mbError, mbNone, mbOK); Engine.CloseFile(FD); - Libc.free(Buffer); + libc_free(Buffer); Exit; end; // processing begins @@ -258,7 +258,7 @@ begin CommentOpen := False; Engine.CloseFile(FD); - Libc.free(Buffer); + libc_free(Buffer); Result := True; end; @@ -393,8 +393,8 @@ begin ProgressBar.Value := 0; Application.ProcessMessages; try - Buffer := Libc.malloc(ChksumBlockSize); - Libc.memset(Buffer, 0, ChksumBlockSize); + Buffer := malloc(ChksumBlockSize); + memset(Buffer, 0, ChksumBlockSize); except Application.MessageBox(LANGAnErrorOccuredWhileInitializingMemoryBlock, [mbOK], mbError, mbNone, mbOK); Exit; @@ -445,7 +445,7 @@ begin DebugMsg([Format('Checksum processing: %d:%3d = %.3f MB/s', [SecondOf(Time2 - Time1), MillisecondOf(Time2 - Time1), (MaxSize / (SecondOf(Time2 - Time1) + MillisecondOf(Time2 - Time1) / 1000)) / (1024 * 1024)])]); FileList.Items[List.Count - 1].RedrawRow; - Libc.free(Buffer); + libc_free(Buffer); ProgressBar.Fraction := 1; CheckButton.Caption := LANGCheckButtonCaptionCheck; if Stop then StatLabel.Caption := LANGChecksumInterrupted else begin diff --git a/UChecksumDruid.pas b/UChecksumDruid.pas index 188bac0..18e4243 100644 --- a/UChecksumDruid.pas +++ b/UChecksumDruid.pas @@ -76,7 +76,7 @@ var implementation -uses ULocale, UCoreUtils, Libc, UCore, DateUtils, UConfig, StrUtils; +uses ULocale, UCoreUtils, ULibc, UCore, DateUtils, UConfig, StrUtils; procedure TFChecksumDruid.FormCreate(Sender: TObject); @@ -488,8 +488,8 @@ begin HashString := ''; Result := False; try - Buffer := Libc.malloc(ChksumBlockSize); - Libc.memset(Buffer, 0, ChksumBlockSize); + Buffer := malloc(ChksumBlockSize); + memset(Buffer, 0, ChksumBlockSize); except ErrorLabel.Caption := ErrorLabel.Caption + LANGAnErrorOccuredWhileInitializingMemoryBlock + #10; Exit; @@ -518,7 +518,7 @@ begin CheckStop; until (Count < ChksumBlockSize) or Stop; Engine.CloseFile(FD); - Libc.free(Buffer); + libc_free(Buffer); if IsItSFV then HashString := IntToHex(not CRC, 8) else begin @@ -542,8 +542,8 @@ begin Exit; end; try - Buffer := Libc.malloc(ChksumBlockSize); - Libc.memset(Buffer, 0, ChksumBlockSize); + Buffer := malloc(ChksumBlockSize); + memset(Buffer, 0, ChksumBlockSize); except ErrorLabel.Caption := ErrorLabel.Caption + LANGAnErrorOccuredWhileInitializingMemoryBlock + #10; Exit; @@ -576,7 +576,7 @@ begin end; BufferPos := -1; Engine.CloseFile(FileDes); - Libc.free(Buffer); + libc_free(Buffer); end; end; @@ -591,8 +591,8 @@ begin Exit; end; try - Buffer := Libc.malloc(ChksumBlockSize); - Libc.memset(Buffer, 0, ChksumBlockSize); + Buffer := malloc(ChksumBlockSize); + memset(Buffer, 0, ChksumBlockSize); except ErrorLabel.Caption := ErrorLabel.Caption + LANGAnErrorOccuredWhileInitializingMemoryBlock + #10; Exit; @@ -52,7 +52,7 @@ var implementation -uses Libc, ULocale, UCoreUtils; +uses ULibc, ULocale, UCoreUtils; procedure TFChmod.FormCreate(Sender: TObject); @@ -22,7 +22,7 @@ unit UChown; interface uses - SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKMenus, GTKView; + SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView; type TFChown = class(TGTKDialog) @@ -49,7 +49,7 @@ var implementation -uses Libc, ULocale, UCoreUtils, UCoreClasses; +uses ULibc, ULocale, UCoreUtils, UCoreClasses; procedure TFChown.FormCreate(Sender: TObject); @@ -170,14 +170,14 @@ begin if UsrManager.UserList.Count > 0 then for i := 0 to UsrManager.UserList.Count - 1 do begin Item := OwnerListView.Items.Add; - Item.SetValue(0, TUser(UsrManager.UserList[i]).UserName); - Item.SetValue(1, TUser(UsrManager.UserList[i]).UID); + Item.SetValue(0, TSystemUser(UsrManager.UserList[i]).UserName); + Item.SetValue(1, TSystemUser(UsrManager.UserList[i]).UID); end; if UsrManager.GroupList.Count > 0 then for i := 0 to UsrManager.GroupList.Count - 1 do begin Item := GroupListView.Items.Add; - Item.SetValue(0, TGroup(UsrManager.GroupList[i]).GroupName); - Item.SetValue(1, TGroup(UsrManager.GroupList[i]).GID); + Item.SetValue(0, TSystemGroup(UsrManager.GroupList[i]).GroupName); + Item.SetValue(1, TSystemGroup(UsrManager.GroupList[i]).GID); end; finally UsrManager.Free; diff --git a/UConfig.pas b/UConfig.pas index e295e2d..4dd13aa 100644 --- a/UConfig.pas +++ b/UConfig.pas @@ -130,14 +130,14 @@ function CheckConfFilesMod(var ChangedMainGUI, ChangedAssoc, ChangedBookmarks, C implementation -uses Libc, SysUtils, IniFiles, UCoreUtils, UCore, UFileAssoc, UCoreClasses, UGnome, UVFSCore; +uses ULibc, SysUtils, UCoreUtils, UCore, UFileAssoc, UCoreClasses, UGnome, UVFSCore; var InternalQuickExit, InternalDeleteHistory: boolean; InternalMainGUIConfmtime, InternalBookmarksConfmtime, InternalFAssocConfmtime, InternalMounterConfmtime, InternalConnMgrConfmtime: Longint; -function GetFileTime(FileName: string): Longint; forward; +function GetFileTime(FileName: string): time_t; forward; (********************************************************************************************************************************) (********************************************************************************************************************************) @@ -652,7 +652,7 @@ begin Exit; end; s := IncludeTrailingPathDelimiter(s) + 'filetypes'; - if Libc.access(PChar(s), R_OK) = 0 then Libc.remove(PChar(s)); + if access(PChar(s), R_OK) = 0 then libc_remove(PChar(s)); IniFile := TMyIniFile.Create(s, False); try try @@ -786,7 +786,7 @@ begin Exit; end; s := IncludeTrailingPathDelimiter(s) + 'mounter'; - if Libc.access(PChar(s), R_OK) = 0 then Libc.remove(PChar(s)); + if access(PChar(s), R_OK) = 0 then libc_remove(PChar(s)); IniFile := TMyIniFile.Create(s, False); try try @@ -959,7 +959,7 @@ begin Exit; end; s := IncludeTrailingPathDelimiter(s) + 'connmgr'; - if Libc.access(PChar(s), R_OK) = 0 then Libc.remove(PChar(s)); + if access(PChar(s), R_OK) = 0 then libc_remove(PChar(s)); IniFile := TMyIniFile.Create(s, False); try try @@ -1016,12 +1016,14 @@ end; (********************************************************************************************************************************) (********************************************************************************************************************************) -function GetFileTime(FileName: string): Longint; -var StatBuf : TStatBuf64; +function GetFileTime(FileName: string): time_t; +var StatBuf: Pstat64; begin Result := -1; - if __lxstat64(_STAT_VER, PChar(FileName), StatBuf) <> 0 then Exit; - Result := StatBuf.st_mtime; + StatBuf := malloc(sizeof(Tstat64)); + memset(StatBuf, 0, sizeof(Tstat64)); + if lstat64(PChar(FileName), StatBuf) = 0 then Result := StatBuf^.st_mtim.tv_sec; + libc_free(StatBuf); end; function CheckConfFilesMod(var ChangedMainGUI, ChangedAssoc, ChangedBookmarks, ChangedMounter, ChangedConnections: boolean): boolean; @@ -20,7 +20,7 @@ unit UCore; interface -uses glib2, SyncObjs, Classes, GTKForms, GTKView, Libc, UGlibC_compat, UEngines, UCoreUtils, UProgress, UVFSCore; +uses glib2, SyncObjs, Classes, GTKForms, GTKView, ULibc, UEngines, UCoreUtils, UProgress, UVFSCore; function FillPanel(List: TList; ListView: TGTKListView; Engine: TPanelEngine; LeftPanel: boolean): boolean; @@ -234,8 +234,8 @@ begin if ListView.Items.Count = 0 then ListItem := ListView.Items.Add else ListItem := ListView.Items[0]; - Data := Libc.malloc(SizeOf(TDataItem)); - Libc.memset(Data, 0, SizeOf(TDataItem)); + Data := malloc(SizeOf(TDataItem)); + memset(Data, 0, SizeOf(TDataItem)); with Data^ do begin UpDir := True; IsDotFile := False; @@ -684,13 +684,13 @@ var DefResponse: integer; // Global variables for this function Res := True; BSize := DestEngine.GetBlockSize; - Buffer := Libc.malloc(BSize); + Buffer := malloc(BSize); if Buffer = nil then begin CopyFilesWorker_ErrorFunc(SenderThread, 1, errno, SourceFile); // Memory allocation failed - Libc.free(Buffer); + libc_free(Buffer); Exit; end; - Libc.memset(Buffer, 0, BSize); + memset(Buffer, 0, BSize); BytesWritten := 0; repeat @@ -708,7 +708,7 @@ var DefResponse: integer; // Global variables for this function Break; end; until (BytesRead = 0) or (BytesWritten < BytesRead); - Libc.free(Buffer); + libc_free(Buffer); if DestEngine.CloseFile(fdst) <> 0 then begin CopyFilesWorker_ErrorFunc(SenderThread, 4, errno, DestFile); // Cannot close target file @@ -1285,8 +1285,8 @@ begin if Pos('.', FileName) > 1 then FileName := ChangeFileExt(FileName, '.crc') else FileName := FileName + '.crc'; try - Buffer := Libc.malloc(CRCBlockSize); - Libc.memset(Buffer, 0, CRCBlockSize); + Buffer := malloc(CRCBlockSize); + memset(Buffer, 0, CRCBlockSize); except Application.MessageBox(LANGAnErrorOccuredWhileInitializingMemoryBlock, [mbOK], mbError, mbNone, mbOK); Exit; @@ -1298,7 +1298,7 @@ begin repeat Count := Engine.ReadFile(FD, Buffer, CRCBlockSize, Error); if Error <> 0 then begin - Libc.free(Buffer); + libc_free(Buffer); Engine.CloseFile(FD); Exit; end; @@ -1319,7 +1319,7 @@ begin if Length(s) > 0 then ProcessLine(s); Engine.CloseFile(FD); - Libc.free(Buffer); + libc_free(Buffer); Result := True; end; @@ -1411,8 +1411,8 @@ begin if Assigned(Stat) then MergeBlockSize := ComputeBlockSize(Stat^.Size) else MergeBlockSize := 65536*4; try - Buffer := Libc.malloc(MergeBlockSize); - Libc.memset(Buffer, 0, MergeBlockSize); + Buffer := malloc(MergeBlockSize); + memset(Buffer, 0, MergeBlockSize); except FCancelMessage := LANGAnErrorOccuredWhileInitializingMemoryBlock; FShowCancelMessage := True; @@ -1422,7 +1422,7 @@ begin if Error <> 0 then begin FCancelMessage := Format(LANGAnErrorOccuredWhileOpeningFileSS, [StrToUTF8(TargetName), GetErrorString(Error)]); FShowCancelMessage := True; - Libc.free(Buffer); + libc_free(Buffer); Exit; end; @@ -1470,7 +1470,7 @@ begin end else ShowMessageBox(Format(LANGMergeOfSSucceeded_NoCRCFileAvailable, [StrToUTF8(ExtractFileName(TargetFinalName))]), [mbOK], mbInfo, mbNone, mbOK); Engine.CloseFile(FD); end; - Libc.free(Buffer); + libc_free(Buffer); SenderThread.FDoneThread := True; end; @@ -1611,8 +1611,8 @@ begin List := TList.Create; try - Buffer := Libc.malloc(SplitBlockSize); - Libc.memset(Buffer, 0, SplitBlockSize); + Buffer := malloc(SplitBlockSize); + memset(Buffer, 0, SplitBlockSize); except FCancelMessage := LANGAnErrorOccuredWhileInitializingMemoryBlock; FShowCancelMessage := True; @@ -1621,7 +1621,7 @@ begin FD := Engine.OpenFile(ParamString1, omRead, Error); if Error <> 0 then begin FCancelMessage := Format(LANGAnErrorOccuredWhileOpeningFileSS, [StrToUTF8(ParamString1), GetErrorString(Error)]); - Libc.free(Buffer); + libc_free(Buffer); Exit; end; FilePath := IncludeTrailingPathDelimiter(ProcessPattern(Engine, ParamString2, Engine.Path, '', True)); @@ -2363,8 +2363,8 @@ end; (********************************************************************************************************************************) (********************************************************************************************************************************) procedure FillDefaultFstabMounterItems; -var fd: PGlibc_IOFile; - mntent: PGlibc_mntent; +var fd: PFILE; + mntent: Pmntent; MounterItem: TMounterItem; begin while MounterList.Count > 0 do begin @@ -2373,10 +2373,10 @@ begin end; MounterList.Clear; - fd := glibc_setmntent(_PATH_MNTTAB, 'r'); + fd := setmntent(_PATH_MNTTAB, 'r'); if fd = nil then Exit; // Get mount name - mntent := glibc_getmntent(fd); + mntent := getmntent(fd); while mntent <> nil do begin if (mntent^.mnt_dir <> '/') and (mntent^.mnt_dir <> '/boot') and (Pos('/proc', mntent^.mnt_dir) <> 1) and (Pos('/dev', mntent^.mnt_dir) <> 1) and (mntent^.mnt_dir <> 'swap') and (mntent^.mnt_dir <> '') then @@ -2396,53 +2396,53 @@ begin MounterItem.DeviceType := 0; MounterList.Add(MounterItem); end; - mntent := glibc_getmntent(fd); + mntent := getmntent(fd); end; - glibc_endmntent(fd); + endmntent(fd); end; function TMounterItem.Mounted: boolean; -var fd: PGlibc_IOFile; - mntent: PGlibc_mntent; +var fd: PFILE; + mntent: Pmntent; begin Result := False; - fd := glibc_setmntent(_PATH_MOUNTED, 'r'); + fd := setmntent(_PATH_MOUNTED, 'r'); if fd = nil then Exit; // Get mount name - mntent := glibc_getmntent(fd); + mntent := getmntent(fd); while mntent <> nil do begin // DebugMsg(['mntent^.mnt_dir = ', Int64(mntent^.mnt_dir)]); // DebugMsg(['mntent^.mnt_dir = ', mntent^.mnt_dir]); // DebugMsg(['sizeof(mntent^.mnt_dir) = ', sizeof(mntent^.mnt_dir)]); -// DebugMsg(['sizeof(TGlibc_mntent) = ', sizeof(TGlibc_mntent)]); +// DebugMsg(['sizeof(Tmntent) = ', sizeof(Tmntent)]); // DebugMsg(['string(mntent^.mnt_dir) = ', string(mntent^.mnt_dir)]); // DebugMsg(['MountPath = ', MountPath]); if mntent^.mnt_dir = MountPath then begin Result := True; Break; end; - mntent := glibc_getmntent(fd); + mntent := getmntent(fd); end; - glibc_endmntent(fd); + endmntent(fd); end; function TMounterItem.IsInFSTab: boolean; -var fd: PGlibc_IOFile; - mntent: PGlibc_mntent; +var fd: PFILE; + mntent: Pmntent; begin Result := False; - fd := glibc_setmntent(_PATH_MNTTAB, 'r'); + fd := setmntent(_PATH_MNTTAB, 'r'); if fd = nil then Exit; // Get mount name - mntent := glibc_getmntent(fd); + mntent := getmntent(fd); while mntent <> nil do begin if (mntent^.mnt_dir = MountPath) and (mntent^.mnt_fsname = Device) then begin Result := True; Break; end; - mntent := glibc_getmntent(fd); + mntent := getmntent(fd); end; - glibc_endmntent(fd); + endmntent(fd); end; function TMounterItem.Mount: boolean; @@ -2531,7 +2531,7 @@ begin end; procedure GetDirSize(AListView: TGTKListView; Engine: TPanelEngine; DataList: TList; AllItems: boolean); -var t: __time_t; +var t: time_t; b: boolean; FRemoteWait: TFRemoteWait; @@ -2581,9 +2581,9 @@ var t: __time_t; if (ASize < 0) or FMainEscPressed or (Assigned(FRemoteWait) and FRemoteWait.Cancelled) then Exit; Data^.Size := ASize; s := FormatSize(ASize, 0); - Libc.free(Data^.ColumnData[3]); -// Data^.ColumnData[3] := Libc.malloc(Length(s) + 1); -// Libc.memset(Data^.ColumnData[3], 0, Length(s) + 1); + libc_free(Data^.ColumnData[3]); +// Data^.ColumnData[3] := malloc(Length(s) + 1); +// memset(Data^.ColumnData[3], 0, Length(s) + 1); Data^.ColumnData[3] := strdup(PChar(s)); except end; end; @@ -2688,15 +2688,15 @@ end; } (********************************************************************************************************************************) (********************************************************************************************************************************) function PurgeDirectory(APath: string): boolean; -var Handle : PDirectoryStream; +var Handle : PDIR; DirEnt : PDirent64; - StatBuf : PGlibc_stat64; + StatBuf : Pstat64; Buf : PChar; begin try Result := True; APath := IncludeTrailingPathDelimiter(APath); - Handle := Libc.opendir(PChar(APath)); + Handle := opendir(PChar(APath)); if not Assigned(Handle) then begin Result := False; Exit; @@ -2706,22 +2706,22 @@ begin if Assigned(DirEnt) and Assigned(PChar(@DirEnt^.d_name[0])) then begin Buf := Pchar(@DirEnt^.d_name[0]); if (Buf <> '.') and (Buf <> '..') and (DirEnt^.d_name[0] <> #0) then begin - StatBuf := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(StatBuf, 0, sizeof(TGlibc_stat64)); - if glibc_lstat64(PChar(APath + string(Buf)), StatBuf) = 0 then + StatBuf := malloc(sizeof(Tstat64)); + memset(StatBuf, 0, sizeof(Tstat64)); + if lstat64(PChar(APath + string(Buf)), StatBuf) = 0 then if __S_ISTYPE(StatBuf.st_mode, __S_IFDIR) then PurgeDirectory(APath + string(Buf)) else begin // DebugMsg(['Removing ', APath + string(Buf)]); - Result := Result and (Libc.remove(PChar(APath + string(Buf))) = 0); + Result := Result and (libc_remove(PChar(APath + string(Buf))) = 0); end; - Libc.free(StatBuf); + libc_free(StatBuf); end; end; until DirEnt = nil; closedir(Handle); // DebugMsg(['Removing ', ExcludeTrailingPathDelimiter(APath)]); - Result := Result and (Libc.remove(PChar(ExcludeTrailingPathDelimiter(APath))) = 0); + Result := Result and (libc_remove(PChar(ExcludeTrailingPathDelimiter(APath))) = 0); except on E: Exception do DebugMsg(['*** Exception raised in UCore.PurgeDirectory(APath = ', APath, '): ', E.ClassName, ': ', E.Message]); end; diff --git a/UCoreClasses.pas b/UCoreClasses.pas index 0267843..0c2a605 100644 --- a/UCoreClasses.pas +++ b/UCoreClasses.pas @@ -21,16 +21,16 @@ unit UCoreClasses; interface -uses gdk2pixbuf, gtk2, gdk2, glib2, SysUtils, Classes, Libc, IniFiles, GTKClasses, GTKStdCtrls, GTKDialogs, GTKPixbuf, UGnome, +uses gdk2pixbuf, gtk2, gdk2, glib2, SysUtils, Classes, ULibc, IniFiles, GTKClasses, GTKStdCtrls, GTKDialogs, GTKPixbuf, UGnome, UEngines; -type TUser = class +type TSystemUser = class public UserName, FullName, HomeDir, LoginShell: string; UID, GID: Cardinal; end; - TGroup = class + TSystemGroup = class public GroupName: string; GID: Cardinal; @@ -103,10 +103,10 @@ uses GTKForms, GTKUtils, ULocale, UConfig, UCore, UCoreUtils; (********************************************************************************************************************************) (********************************************************************************************************************************) constructor TUserManager.Create; -var pwd: PPasswordRecord; - User: TUser; +var pwd: PPasswd; + User: TSystemUser; grp: PGroup; - Group: TGroup; + Group: TSystemGroup; i: integer; begin inherited Create; @@ -117,7 +117,7 @@ begin setpwent; pwd := getpwent; while pwd <> nil do begin - User := TUser.Create; + User := TSystemUser.Create; User.UserName := String(StrToUTF8(pwd^.pw_name)); User.FullName := String(StrToUTF8(pwd^.pw_gecos)); User.HomeDir := String(StrToUTF8(pwd^.pw_dir)); @@ -134,7 +134,7 @@ begin setgrent; grp := getgrent; while grp <> nil do begin - Group := TGroup.Create; + Group := TSystemGroup.Create; Group.GroupName := String(StrToUTF8(grp^.gr_name)); Group.GID := grp^.gr_gid; Group.Users := TStringList.Create; @@ -159,16 +159,16 @@ var i: integer; begin if UserList.Count > 0 then for i := UserList.Count - 1 downto 0 do begin - TUser(UserList[i]).Free; + TSystemUser(UserList[i]).Free; UserList.Delete(i); end; UserList.Clear; UserList.Free; if GroupList.Count > 0 then for i := GroupList.Count - 1 downto 0 do begin - TGroup(GroupList[i]).Users.Clear; - TGroup(GroupList[i]).Users.Free; - TGroup(GroupList[i]).Free; + TSystemGroup(GroupList[i]).Users.Clear; + TSystemGroup(GroupList[i]).Users.Free; + TSystemGroup(GroupList[i]).Free; GroupList.Delete(i); end; GroupList.Clear; @@ -183,8 +183,8 @@ begin else Result := IntToStr(UID); if UserList.Count > 0 then for i := 0 to UserList.Count - 1 do - if TUser(UserList[i]).UID = UID then begin - Result := TUser(UserList[i]).UserName; + if TSystemUser(UserList[i]).UID = UID then begin + Result := TSystemUser(UserList[i]).UserName; Break; end; end; @@ -196,8 +196,8 @@ begin else Result := IntToStr(GID); if GroupList.Count > 0 then for i := 0 to GroupList.Count - 1 do - if TGroup(GroupList[i]).GID = GID then begin - Result := TGroup(GroupList[i]).GroupName; + if TSystemGroup(GroupList[i]).GID = GID then begin + Result := TSystemGroup(GroupList[i]).GroupName; Break; end; end; diff --git a/UCoreUtils.pas b/UCoreUtils.pas index 3dc91f0..ed43589 100644 --- a/UCoreUtils.pas +++ b/UCoreUtils.pas @@ -24,7 +24,7 @@ unit UCoreUtils; interface -uses gdk2pixbuf, gtk2, gdk2, glib2, SysUtils, Classes, Libc, UGlibC_compat, GTKControls, GTKStdCtrls, GTKClasses, UEngines; +uses gtk2, gdk2, glib2, SysUtils, Classes, ULibc, GTKClasses, UEngines; type PIntArray = ^TIntArray; @@ -57,8 +57,8 @@ function GetErrorString(ErrorNo: integer): string; function GetSignalString(SignalNo: integer): string; function FormatSize(Value: Int64; Base: integer; OverrideSizeFormat: integer = -1): string; -function FormatDate(Value: TTimeT; const FormatTime, FormatDate: boolean; OverrideTimeFormat: integer = -1; OverrideDateFormat: integer = -1; OverrideDateTimeFormat: integer = -1; OverrideCustomDateFormat: string = ''; OverrideCustomTimeFormat: string = ''): string; -function StripDate(Value: TTimeT): TTimeT; +function FormatDate(Value: time_t; const FormatTime, FormatDate: boolean; OverrideTimeFormat: integer = -1; OverrideDateFormat: integer = -1; OverrideDateTimeFormat: integer = -1; OverrideCustomDateFormat: string = ''; OverrideCustomTimeFormat: string = ''): string; +function StripDate(Value: time_t): time_t; function AttrToStr(const Mode: Cardinal; IncludeFileType: boolean = True): string; function AttrToOctal(const Mode: Cardinal): integer; @@ -204,7 +204,7 @@ begin DebugMsg(['FormatSize(0): sprintf() failed, using old format function.']); Result := FormatFloat('###,###,##0', Value div Base); end else Result := StrToUTF8(p); - Libc.free(p); + free(p); end; 1 : begin // 123456 Result := IntToStr(Value div Base); @@ -260,7 +260,7 @@ begin end; (********************************************************************************************************************************) -function FormatDate(Value: TTimeT; const FormatTime, FormatDate: boolean; OverrideTimeFormat: integer = -1; OverrideDateFormat: integer = -1; OverrideDateTimeFormat: integer = -1; OverrideCustomDateFormat: string = ''; OverrideCustomTimeFormat: string = ''): string; +function FormatDate(Value: time_t; const FormatTime, FormatDate: boolean; OverrideTimeFormat: integer = -1; OverrideDateFormat: integer = -1; OverrideDateTimeFormat: integer = -1; OverrideCustomDateFormat: string = ''; OverrideCustomTimeFormat: string = ''): string; var DateString, TimeString: string; DateFormat, TimeFormat: string; CustDateFormat, CustTimeFormat: string; @@ -311,7 +311,7 @@ begin placed := strftime(Buf, 254, PChar(DateFormat), time_tm); if placed <= 0 then DebugMsg(['FormatDate: error converting date. The result will be unpredictable.']); DateString := String(StrToUTF8(Buf)); - Libc.free(Buf); + free(Buf); end; if FormatTime then begin @@ -335,7 +335,7 @@ begin placed := strftime(Buf, 254, PChar(TimeFormat), time_tm); if placed <= 0 then DebugMsg(['FormatDate: error converting time. The result will be unpredictable.']); TimeString := String(StrToUTF8(Buf)); - Libc.free(Buf); + free(Buf); end; if FormatDate and FormatTime then begin @@ -348,7 +348,7 @@ begin if FormatDate then Result := DateString; end; -function StripDate(Value: TTimeT): TTimeT; +function StripDate(Value: time_t): time_t; var time_tm: Ptm; begin time_tm := localtime(@Value); @@ -438,11 +438,11 @@ end; function GetHostName: string; var s: PChar; begin - s := Libc.malloc(65536); - Libc.memset(s, 0, 65536); - Libc.gethostname(s, 65536); + s := malloc(65536); + memset(s, 0, 65536); + ULibc.gethostname(s, 65536); Result := PgcharToString(strdup(s)); - Libc.free(s); + libc_free(s); end; (********************************************************************************************************************************) @@ -1073,14 +1073,14 @@ begin // Make the args_list array args_list := nil; if Length(Parameters) > 0 then begin - args_list := Libc.malloc((Length(Parameters) + 1) * SizeOf(PChar)); - Libc.memset(args_list, 0, (Length(Parameters) + 1) * SizeOf(PChar)); + args_list := malloc((Length(Parameters) + 1) * SizeOf(PChar)); + memset(args_list, 0, (Length(Parameters) + 1) * SizeOf(PChar)); for I := 0 to Length(Parameters) - 1 do begin Temp := Parameters[i]; {$R-} -// PCharArray(args_list^)[I] := Libc.malloc(Length(Temp)+1); -// Libc.memset(PCharArray(args_list^)[I], 0, Length(Temp)+1); +// PCharArray(args_list^)[I] := malloc(Length(Temp)+1); +// memset(PCharArray(args_list^)[I], 0, Length(Temp)+1); // StrCopy(PCharArray(args_list^)[I], PChar(Temp)); PCharArray(args_list^)[I] := strdup(PChar(Temp)); {$R+} @@ -1190,10 +1190,10 @@ begin if ConfUseLibcSystem then begin s := s + ' &'; DebugMsg([s]); - DebugMsg(['**** Running libc.system']); - x := Libc.system(PChar(s)); + DebugMsg(['**** Running system']); + x := libc_system(PChar(s)); Result := x <> -1; // -1 means fork failed - DebugMsg(['**** Running libc.system = ', x, ' --- done']); + DebugMsg(['**** Running system = ', x, ' --- done']); end else begin if Length(Args) = 0 then Exit; for x := 0 to Length(Args) - 1 do Args[x] := RemoveQuotation(Args[x]); @@ -1213,7 +1213,7 @@ end; function IsItX11App(const Application: string): boolean; const BSize = 32768; What = 'libX11.so'; -var stream: PIOFile; +var stream: PFILE; Buffer: Pointer; i: integer; str: string; @@ -1227,14 +1227,14 @@ begin // stream := popen(PChar(Application), 'r'); DebugMsg(['***** IsItX11App: popen OK']); if Assigned(stream) then begin - Buffer := Libc.malloc(BSize); + Buffer := malloc(BSize); if buffer = nil then Writeln('buffer nil: ', integer(errno)); if stream = nil then Writeln('stream nil'); - Libc.memset(Buffer, 0, BSize); + memset(Buffer, 0, BSize); DebugMsg(['***** IsItX11App: malloc() OK']); while feof(stream) = 0 do begin - i := Libc.fread(Buffer, 1, BSize, stream); + i := fread(Buffer, 1, BSize, stream); if i > 0 then begin SetLength(str, i); memcpy(@str[1], Buffer, i); @@ -1253,7 +1253,7 @@ end; function HandleSystemCommand(const Command, ErrorText: string): boolean; const BSize = 32768; -var stream: PIOFile; +var stream: PFILE; Buffer: Pointer; i, NumRead: integer; child_pid: __pid_t; @@ -1274,11 +1274,11 @@ begin // Main application if child_pid <> 0 then begin - __close(fds[1]); + libc_close(fds[1]); stream := fdopen(fds[0], 'r'); - Buffer := Libc.malloc(BSize); + Buffer := malloc(BSize); DebugMsg(['x0']); - Libc.memset(Buffer, 0, BSize); + memset(Buffer, 0, BSize); DebugMsg(['x1']); if buffer = nil then Writeln('buffer nil: ', integer(errno)); if stream = nil then Writeln('stream nil'); @@ -1292,12 +1292,12 @@ begin memcpy(@s[Length(s) - NumRead + 1], Buffer, NumRead); end; end; - __close(fds[0]); + libc_close(fds[0]); DebugMsg(['x2']); TrimCRLFESC(s); DebugMsg(['x3']); - Libc.free(Buffer); + free(Buffer); DebugMsg(['x4']); end @@ -1308,14 +1308,14 @@ begin // Fill the args_list array args_list := nil; if Length(Parameters) > 0 then begin - args_list := Libc.malloc((Length(Parameters) + 1) * SizeOf(PChar)); - Libc.memset(args_list, 0, (Length(Parameters) + 1) * SizeOf(PChar)); + args_list := malloc((Length(Parameters) + 1) * SizeOf(PChar)); + memset(args_list, 0, (Length(Parameters) + 1) * SizeOf(PChar)); for I := 0 to Length(Parameters) - 1 do begin Temp := Parameters[i]; {$R-} -// PCharArray(args_list^)[I] := Libc.malloc(Length(Temp)+1); -// Libc.memset(PCharArray(args_list^)[I], 0, Length(Temp)+1); +// PCharArray(args_list^)[I] := malloc(Length(Temp)+1); +// memset(PCharArray(args_list^)[I], 0, Length(Temp)+1); // StrCopy(PCharArray(args_list^)[I], PChar(Temp)); PCharArray(args_list^)[I] := strdup(PChar(Temp)); {$R+} @@ -1328,7 +1328,7 @@ begin on E: Exception do DebugMsg(['*** forked ** function HandleSystemCommand(''', Command, '''):Exception: ', E.Message]); end; - __close(fds[0]); // Close copy of reader file descriptor + libc_close(fds[0]); // Close copy of reader file descriptor dup2(fds[1], STDERR_FILENO); execvp(PChar(Parameters[0]), args_list); DebugMsg(['***** HandleSystemCommand: failed execvp: something went wrong...']); @@ -1862,9 +1862,9 @@ begin end; procedure SetupSignals; -var sigchld_action: __sigaction; +var sigchld_action: _sigaction; begin - Libc.memset(@sigchld_action, 0, SizeOf(__sigaction)); + memset(@sigchld_action, 0, SizeOf(__sigaction)); sigchld_action.__sigaction_handler := @signal_proc; sigaction(SIGUSR1, @sigchld_action, nil); sigaction(SIGCHLD, @sigchld_action, nil); diff --git a/UEngines.pas b/UEngines.pas index e490cca..6cb8d7a 100644 --- a/UEngines.pas +++ b/UEngines.pas @@ -21,7 +21,7 @@ unit UEngines; interface -uses glib2, gdk2, Classes, Libc, UGlibC_compat; +uses glib2, gdk2, Classes, ULibc; const ERRException = -1; @@ -49,7 +49,7 @@ type UpDir: boolean; Mode, UID, GID: Cardinal; IsDir, IsLnk, IsBlk, IsChr, IsFIFO, IsSock, Selected, IsDotFile: boolean; - ModifyTime: TTimeT; + ModifyTime: time_t; Icon: Pointer; ItemColor: PGdkColor; end; @@ -64,7 +64,7 @@ type Size: Int64; Mode, UID, GID: Cardinal; IsDir, IsLnk, ForceMove, IsOnRO, IsExecutable: boolean; - ModifyTime: TTimeT; + ModifyTime: time_t; Level: word; atime, mtime: Int64; end; @@ -189,7 +189,7 @@ procedure FreeDataItem(DataItem: PDataItem); overload; implementation -uses SysUtils, UCoreUtils, UConfig; +uses SysUtils, UCoreUtils; (********************************************************************************************************************************) constructor TPanelEngine.Create; @@ -244,23 +244,23 @@ end; function TLocalTreeEngine.GetListing(var List: TList; const AddDotFiles: boolean; APath: string): integer; var Item : PDataItem; - Handle : PDirectoryStream; + Handle : PDIR; DirEnt : PDirent64; Buf : PChar; // StatBuf : TStatBuf64; - StatBuf : PGlibc_stat64; + StatBuf : Pstat64; i: integer; LnkBuf : array[0..1000] of char; begin Result := 0; try APath := IncludeTrailingPathDelimiter(APath); - if Libc.__chdir(PChar(APath)) <> 0 then begin + if libc_chdir(PChar(APath)) <> 0 then begin Result := errno; DebugMsg(['*** TLocalTreeEngine.GetListing(APath=', APath, '): chdir error: ', strerror(Result)]); Exit; end; - Handle := Libc.opendir(PChar(APath)); + Handle := opendir(PChar(APath)); if not Assigned(Handle) then begin DebugMsg(['*** TLocalTreeEngine.GetListing(APath=', APath, '): opendir() handle == NULL: ', strerror(errno)]); Result := ERRNoAccess; @@ -279,9 +279,9 @@ begin begin Item := nil; // DebugMsg(['x5']); - Item := Libc.malloc(SizeOf(TDataItem)); + Item := malloc(SizeOf(TDataItem)); // DebugMsg(['x6']); - Libc.memset(Item, 0, SizeOf(TDataItem)); + memset(Item, 0, SizeOf(TDataItem)); // DebugMsg(['x7']); with Item^ do begin // DebugMsg(['x8']); @@ -293,10 +293,10 @@ begin FDisplayName := StrToUTF8(Buf); // FDisplayName := strdup(Buf); // DebugMsg(['x']); - StatBuf := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(StatBuf, 0, sizeof(TGlibc_stat64)); + StatBuf := malloc(sizeof(Tstat64)); + memset(StatBuf, 0, sizeof(Tstat64)); // DebugMsg(['(II) TLocalTreeEngine.GetListing(APath=', APath, '): lstat(Buf = ', Buf, ')']); - if glibc_lstat64(Buf, StatBuf) <> 0 then begin + if lstat64(Buf, StatBuf) <> 0 then begin DebugMsg(['*** TLocalTreeEngine.GetListing(APath=', APath, '): Error reading file via lstat64: ', strerror(errno)]); Continue; end; @@ -308,11 +308,7 @@ begin IsChr := __S_ISTYPE(StatBuf^.st_mode, __S_IFCHR); IsFIFO := __S_ISTYPE(StatBuf^.st_mode, __S_IFIFO); IsSock := __S_ISTYPE(StatBuf^.st_mode, __S_IFSOCK); -{$IFDEF KYLIX} - ModifyTime := StatBuf^.st_mtime; -{$ELSE} ModifyTime := StatBuf^.st_mtim.tv_sec; -{$ENDIF} if StatBuf^.st_uid = 4294967295 then UID := getuid else UID := StatBuf^.st_uid; if StatBuf^.st_gid = 4294967295 then GID := getgid @@ -320,26 +316,26 @@ begin UpDir := False; Selected := False; // DebugMsg(['(II) TLocalTreeEngine.GetListing(APath=', APath, '): freeing StatBuf...']); - Libc.free(StatBuf); + libc_free(StatBuf); // DebugMsg([' done.']); if IsLnk then begin // DebugMsg(['aaaax']); i := readlink(PChar(APath + String(Buf)), LnkBuf, SizeOf(LnkBuf)); if i > 0 then begin LnkBuf[i] := #0; - LnkPointTo := Libc.malloc(i + 1); - Libc.memset(LnkPointTo, 0, i + 1); - LnkPointTo := Libc.strncpy(LnkPointTo, @LnkBuf[0], i); + LnkPointTo := malloc(i + 1); + memset(LnkPointTo, 0, i + 1); + LnkPointTo := strncpy(LnkPointTo, @LnkBuf[0], i); end; - StatBuf := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(StatBuf, 0, sizeof(TGlibc_stat64)); - if glibc_stat64(Buf, StatBuf) = 0 then begin + StatBuf := malloc(sizeof(Tstat64)); + memset(StatBuf, 0, sizeof(Tstat64)); + if stat64(Buf, StatBuf) = 0 then begin IsDir := __S_ISTYPE(StatBuf^.st_mode, __S_IFDIR); Mode := StatBuf^.st_mode; end; // DebugMsg(['(II) TLocalTreeEngine.GetListing(APath=', APath, '): freeing StatBuf...']); - Libc.free(StatBuf); + libc_free(StatBuf); // DebugMsg([' done.']); end; // DebugMsg(['xdffffffff']); @@ -369,11 +365,11 @@ end; function TLocalTreeEngine.ChangeDir(const NewPath: string; const ShowProgress: boolean = True): integer; var APath: string; - Handle : PDirectoryStream; + Handle : PDIR; begin try APath := IncludeTrailingPathDelimiter(NewPath); - if __chdir(PChar(APath)) <> 0 then begin + if libc_chdir(PChar(APath)) <> 0 then begin Result := errno; Exit; end; @@ -403,21 +399,21 @@ end; (********************************************************************************************************************************) function TLocalTreeEngine.ExplicitChDir(const NewPath: string): integer; begin - Result := __chdir(PChar(NewPath)); + Result := libc_chdir(PChar(NewPath)); if Result <> 0 then Result := errno; end; (********************************************************************************************************************************) function TLocalTreeEngine.GetFileSystemSize(const APath: string): Int64; -var Stat: PGlibc_statfs64; +var Stat: Pstatfs64; begin Result := 0; try - Stat := Libc.malloc(sizeof(TGlibc_statfs64)); - Libc.memset(Stat, 0, sizeof(TGlibc_statfs64)); - if glibc_statfs64(PChar(APath), Stat) <> 0 then Exit; + Stat := malloc(sizeof(Tstatfs64)); + memset(Stat, 0, sizeof(Tstatfs64)); + if statfs64(PChar(APath), Stat) <> 0 then Exit; Result := Stat^.f_bsize * Stat^.f_blocks; - Libc.free(Stat); + libc_free(Stat); except on E: Exception do DebugMsg(['*** TLocalTreeEngine.GetFileSystemSize(APath=', APath, ') -Exception: ', E.Message]); end; @@ -430,15 +426,15 @@ end; (********************************************************************************************************************************) function TLocalTreeEngine.GetFileSystemFree(const APath: string): Int64; -var Stat: PGlibc_statfs64; +var Stat: Pstatfs64; begin Result := 0; try - Stat := Libc.malloc(sizeof(TGlibc_statfs64)); - Libc.memset(Stat, 0, sizeof(TGlibc_statfs64)); - if glibc_statfs64(PChar(APath), Stat) <> 0 then Exit; + Stat := malloc(sizeof(Tstatfs64)); + memset(Stat, 0, sizeof(Tstatfs64)); + if statfs64(PChar(APath), Stat) <> 0 then Exit; Result := Stat^.f_bsize * Stat^.f_bavail; - Libc.free(Stat); + libc_free(Stat); except on E: Exception do DebugMsg(['*** TLocalTreeEngine.GetFileSystemFree(APath=', APath, ') -Exception: ', E.Message]); end; @@ -452,9 +448,9 @@ end; (********************************************************************************************************************************) function TLocalTreeEngine.MakeDir(const NewDir: string): integer; begin - DebugMsg(['(II) TLocalTreeEngine.MakeDir: begin']); +// DebugMsg(['(II) TLocalTreeEngine.MakeDir: begin']); Result := __mkdir(PChar(NewDir), OctalToAttr(ConfDefaultDirCreationMask)); - DebugMsg(['(II) TLocalTreeEngine.MakeDir: Result = ', Result]); +// DebugMsg(['(II) TLocalTreeEngine.MakeDir: Result = ', Result]); if Result <> 0 then Result := errno; (* if Result <> 0 then try @@ -464,7 +460,7 @@ begin DebugMsg(['(II) TLocalTreeEngine.MakeDir: Exception']); end; *) - DebugMsg(['(II) TLocalTreeEngine.MakeDir: end']); +// DebugMsg(['(II) TLocalTreeEngine.MakeDir: end']); end; (********************************************************************************************************************************) @@ -472,15 +468,15 @@ end; function TLocalTreeEngine.GetDirSize(APath: string): Int64; function InternalGetDirSize(APath: string): Int64; - var Handle : PDirectoryStream; + var Handle : PDIR; DirEnt : PDirent64; - StatBuf : PGlibc_stat64; + StatBuf : Pstat64; begin Result := 0; try if BreakProcessingType = 1 then Exit; APath := IncludeTrailingPathDelimiter(APath); - if __chdir(PChar(APath)) <> 0 then begin + if libc_chdir(PChar(APath)) <> 0 then begin Result := 0; Exit; end; @@ -494,14 +490,14 @@ function TLocalTreeEngine.GetDirSize(APath: string): Int64; if Assigned(DirEnt) and Assigned(PChar(@DirEnt^.d_name[0])) and (PChar(@DirEnt^.d_name[0]) <> '.') and (PChar(@DirEnt^.d_name[0]) <> '..') and (DirEnt^.d_name[0] <> #0) then begin - StatBuf := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(StatBuf, 0, sizeof(TGlibc_stat64)); - if glibc_lstat64(PChar(@DirEnt^.d_name[0]), StatBuf) <> 0 then Continue; + StatBuf := malloc(sizeof(Tstat64)); + memset(StatBuf, 0, sizeof(Tstat64)); + if lstat64(PChar(@DirEnt^.d_name[0]), StatBuf) <> 0 then Continue; if __S_ISTYPE(StatBuf^.st_mode, __S_IFDIR) then begin Inc(Result, InternalGetDirSize(APath + String(PChar(@DirEnt^.d_name[0])))); - __chdir(PChar(APath)); + libc_chdir(PChar(APath)); end else Inc(Result, StatBuf^.st_size); - Libc.free(StatBuf); + libc_free(StatBuf); end; until DirEnt = nil; closedir(Handle); @@ -526,15 +522,15 @@ end; function TLocalTreeEngine.Remove(APath: string): integer; begin APath := ExcludeTrailingPathDelimiter(APath); - Result := Libc.remove(PChar(APath)); + Result := libc_remove(PChar(APath)); if Result <> 0 then Result := errno; end; (********************************************************************************************************************************) procedure TLocalTreeEngine.FillDirFiles(APath: string; List: TList; ALevel: word); -var Handle : PDirectoryStream; +var Handle : PDIR; DirEnt : PDirent64; - StatBuf_global : PGlibc_stat64; + StatBuf_global : Pstat64; Item: PDataItemSL; i: integer; LnkBuf : array[0..1000] of char; @@ -542,18 +538,18 @@ var Handle : PDirectoryStream; procedure AddEntry(FPath: string; AddCurrDirStage, AStage1: boolean); - var StatBuf_local : PGlibc_stat64; + var StatBuf_local : Pstat64; begin // DebugMsg(['TLocalTreeEngine.FillDirFiles: addding "', FPath, '"']); FPath := ExcludeTrailingPathDelimiter(FPath); - StatBuf_local := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(StatBuf_local, 0, sizeof(TGlibc_stat64)); - if glibc_lstat64(PChar(FPath), StatBuf_local) <> 0 then begin + StatBuf_local := malloc(sizeof(Tstat64)); + memset(StatBuf_local, 0, sizeof(Tstat64)); + if lstat64(PChar(FPath), StatBuf_local) <> 0 then begin DebugMsg(['*** TLocalTreeEngine.FillDirFiles: Error reading file stat AddEntry("', FPath, '"): ', strerror(errno)]); Exit; end; - Item := Libc.malloc(SizeOf(TDataItemSL)); - Libc.memset(Item, 0, SizeOf(TDataItemSL)); + Item := malloc(SizeOf(TDataItemSL)); + memset(Item, 0, SizeOf(TDataItemSL)); with Item^ do begin FName := nil; FDisplayName := nil; @@ -573,32 +569,23 @@ var Handle : PDirectoryStream; else UID := StatBuf_local^.st_uid; if StatBuf_local^.st_gid = 4294967295 then GID := getgid else GID := StatBuf_local^.st_gid; -{$IFDEF KYLIX} - atime := StatBuf_local^.st_atime; - mtime := StatBuf_local^.st_mtime; -{$ELSE} atime := StatBuf_local^.st_atim.tv_sec; mtime := StatBuf_local^.st_mtim.tv_sec; -{$ENDIF} if IsLnk and AddCurrDirStage then DebugMsg(['*** Assertion failed AddEntry: Item^.IsLnk = True']); if IsLnk and (not AddCurrDirStage) then begin i := readlink(PChar(APath + String(PChar(@DirEnt^.d_name[0]))), LnkBuf, SizeOf(LnkBuf)); if i > 0 then begin LnkBuf[i] := #0; - LnkPointTo := Libc.malloc(i + 1); - Libc.memset(LnkPointTo, 0, i + 1); - LnkPointTo := Libc.strncpy(LnkPointTo, @LnkBuf[0], i); + LnkPointTo := malloc(i + 1); + memset(LnkPointTo, 0, i + 1); + LnkPointTo := strncpy(LnkPointTo, @LnkBuf[0], i); // StrLCopy(LnkPointTo, @LnkBuf[0], i); end; end; -{$IFDEF KYLIX} - ModifyTime := StatBuf_local^.st_mtime; -{$ELSE} ModifyTime := StatBuf_local^.st_mtim.tv_sec; -{$ENDIF} // DebugMsg([FormatDateTime('c', ModifyTime)]); Level := ALevel + Ord(not AddCurrDirStage); - Libc.free(StatBuf_local); + libc_free(StatBuf_local); end; if AddCurrDirStage then List.Add(Item) else FilesList.Add(Item); @@ -610,7 +597,7 @@ begin AddEntry(APath, True, True); FilesList := TList.Create; APath := IncludeTrailingPathDelimiter(APath); - if __chdir(PChar(APath)) <> 0 then begin + if libc_chdir(PChar(APath)) <> 0 then begin DebugMsg(['*** TLocalTreeEngine.FillDirFiles: chdir to "', APath, '" failed: ', strerror(errno)]); Exit; end; @@ -619,17 +606,17 @@ begin repeat DirEnt := readdir64(Handle); if Assigned(DirEnt) and Assigned(PChar(@DirEnt^.d_name[0])) and (PChar(@DirEnt^.d_name[0]) <> '.') and (PChar(@DirEnt^.d_name[0]) <> '..') then begin - StatBuf_global := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(StatBuf_global, 0, sizeof(TGlibc_stat64)); - if glibc_lstat64(PChar(@DirEnt^.d_name[0]), StatBuf_global) <> 0 then begin + StatBuf_global := malloc(sizeof(Tstat64)); + memset(StatBuf_global, 0, sizeof(Tstat64)); + if lstat64(PChar(@DirEnt^.d_name[0]), StatBuf_global) <> 0 then begin DebugMsg(['*** TLocalTreeEngine.FillDirFiles: Error lstat-ing ("', PChar(@DirEnt^.d_name[0]), '"): ', strerror(errno)]); Continue; end; if __S_ISTYPE(StatBuf_global^.st_mode, __S_IFDIR) then begin FillDirFiles(APath + String(PChar(@DirEnt^.d_name[0])), List, ALevel + 1); - __chdir(PChar(APath)); + libc_chdir(PChar(APath)); end else AddEntry(APath + String(PChar(@DirEnt^.d_name[0])), False, True); - Libc.free(StatBuf_global); + libc_free(StatBuf_global); end; until DirEnt = nil; CloseDir(Handle); @@ -645,21 +632,21 @@ end; (********************************************************************************************************************************) function TLocalTreeEngine.GetFileInfoSL(APath: string): PDataItemSL; -var StatBuf : PGlibc_stat64; +var StatBuf : Pstat64; i : integer; LnkBuf : array[0..1000] of char; begin Result := nil; try - StatBuf := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(StatBuf, 0, sizeof(TGlibc_stat64)); - if glibc_lstat64(PChar(APath), StatBuf) <> 0 then begin + StatBuf := malloc(sizeof(Tstat64)); + memset(StatBuf, 0, sizeof(Tstat64)); + if lstat64(PChar(APath), StatBuf) <> 0 then begin DebugMsg(['*** Error reading file stat GetFileInfoSL(lstat): ', strerror(errno)]); Exit; end; // DebugMsg(['x1']); - Result := Libc.malloc(SizeOf(TDataItemSL)); - Libc.memset(Result, 0, SizeOf(TDataItemSL)); + Result := malloc(SizeOf(TDataItemSL)); + memset(Result, 0, SizeOf(TDataItemSL)); // DebugMsg(['x1']); with Result^ do begin FName := nil; @@ -681,25 +668,16 @@ begin // DebugMsg(['x2']); ForceMove := False; // DebugMsg(['x2']); -{$IFDEF KYLIX} - ModifyTime := StatBuf^.st_mtime; -{$ELSE} ModifyTime := StatBuf^.st_mtim.tv_sec; -{$ENDIF} // DebugMsg(['x2']); if StatBuf^.st_uid = 4294967295 then UID := getuid else UID := StatBuf^.st_uid; if StatBuf^.st_gid = 4294967295 then GID := getgid else GID := StatBuf^.st_gid; -{$IFDEF KYLIX} - atime := StatBuf^.st_atime; - mtime := StatBuf^.st_mtime; -{$ELSE} atime := StatBuf^.st_atim.tv_sec; mtime := StatBuf^.st_mtim.tv_sec; -{$ENDIF} // DebugMsg(['x1']); - Libc.free(StatBuf); + libc_free(StatBuf); // DebugMsg(['x1']); Level := 1; // DebugMsg(['x1']); @@ -707,18 +685,18 @@ begin i := readlink(PChar(APath), LnkBuf, SizeOf(LnkBuf)); if i > 0 then begin LnkBuf[i] := #0; - LnkPointTo := Libc.malloc(i + 1); - Libc.memset(LnkPointTo, 0, i + 1); + LnkPointTo := malloc(i + 1); + memset(LnkPointTo, 0, i + 1); // StrLCopy(LnkPointTo, @LnkBuf[0], i); - LnkPointTo := Libc.strncpy(LnkPointTo, @LnkBuf[0], i); + LnkPointTo := strncpy(LnkPointTo, @LnkBuf[0], i); end; - StatBuf := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(StatBuf, 0, sizeof(TGlibc_stat64)); - if glibc_stat64(PChar(APath), StatBuf) = 0 then begin + StatBuf := malloc(sizeof(Tstat64)); + memset(StatBuf, 0, sizeof(Tstat64)); + if stat64(PChar(APath), StatBuf) = 0 then begin IsDir := __S_ISTYPE(StatBuf^.st_mode, __S_IFDIR); Mode := StatBuf^.st_mode; end; - Libc.free(StatBuf); + libc_free(StatBuf); end; end; // DebugMsg(['x1']); @@ -739,9 +717,9 @@ begin end; function TLocalTreeEngine.CopyFile(Sender: Pointer; SourceFile, DestFile: string; ProgressFunc: TEngineProgressFunc; ErrorFunc: TEngineErrorFunc; Append: boolean): boolean; -var fsrc, fdest: PIOFile; +var fsrc, fdest: PFILE; BytesDone, BytesRead: Int64; - offset: off_t; +// offset: __off_t; // Used due to sendfile bug while copying from NTFS and some 2.6.x kernels @@ -753,16 +731,16 @@ var fsrc, fdest: PIOFile; try Result := False; Res := True; - DebugMsg(['*** Using old copy function due to bug in sendfile']); +// DebugMsg(['*** Using old copy function due to bug in sendfile']); // WriteLn('x1'); - Buffer := Libc.malloc(FBlockSize); + Buffer := malloc(FBlockSize); // WriteLn('x2'); if Buffer = nil then begin ErrorFunc(Sender, 1, errno, SourceFile); // Memory allocation failed -// Libc.free(Buffer); +// libc_free(Buffer); Exit; end; - Libc.memset(Buffer, 0, FBlockSize); + memset(Buffer, 0, FBlockSize); // WriteLn('x3'); while feof(fsrc) = 0 do begin @@ -791,23 +769,23 @@ var fsrc, fdest: PIOFile; // WriteLn('x7'); end; // WriteLn('x8'); - Libc.free(Buffer); + libc_free(Buffer); // WriteLn('x9'); Result := Res; except on E: Exception do DebugMsg(['*** Exception raised in TLocalTreeEngine.CopyFile.OldCopyRoutine(Sender=', DWord(Sender), ', SourceFile=', SourceFile, ', DestFile=', DestFile, '): (', E.ClassName, '): ', E.Message]); end; end; - +(* function NewCopyRoutine: boolean; var Res: boolean; - StatBuf: PGlibc_stat64; + StatBuf: Pstat64; begin try Res := True; repeat DebugMsg(['Copy(sendfile): offset = ', offset, ', BytesDone = ', BytesDone, ', ftell(fsrc) = ', ftell(fsrc)]); - BytesRead := Libc.sendfile(glibc_fileno(fdest), glibc_fileno(fsrc), offset, FBlockSize); + BytesRead := sendfile(fileno(fdest), fileno(fsrc), offset, FBlockSize); if BytesRead = -1 then begin if errno = EINVAL then begin Result := OldCopyRoutine; @@ -822,21 +800,21 @@ var fsrc, fdest: PIOFile; end; until BytesRead < FBlockSize; - StatBuf := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(StatBuf, 0, sizeof(TGlibc_stat64)); - if glibc_lstat64(PChar(SourceFile), StatBuf) <> 0 then begin + StatBuf := malloc(sizeof(Tstat64)); + memset(StatBuf, 0, sizeof(Tstat64)); + if lstat64(PChar(SourceFile), StatBuf) <> 0 then begin DebugMsg(['*** TLocalTreeEngine.CopyFile.NewCopyRoutine(Sender=', DWord(Sender), ', SourceFile=', SourceFile, ', DestFile=', DestFile, '): Error reading file via lstat64: ', strerror(errno)]); Res := ErrorFunc(Sender, 6, errno, SourceFile); end else if (BytesDone < StatBuf^.st_size) and Res then Res := ErrorFunc(Sender, 6, errno, SourceFile); - Libc.free(StatBuf); + libc_free(StatBuf); Result := Res; except on E: Exception do DebugMsg(['*** Exception raised in TLocalTreeEngine.CopyFile.NewCopyRoutine(Sender=', DWord(Sender), ', SourceFile=', SourceFile, ', DestFile=', DestFile, '): (', E.ClassName, '): ', E.Message]); end; end; - +*) begin Result := False; try @@ -854,9 +832,9 @@ begin end; BytesDone := 0; - offset := 0; +// offset := 0; - Result := NewCopyRoutine; + Result := OldCopyRoutine; if fclose(fdest) <> 0 then begin fclose(fsrc); @@ -870,52 +848,52 @@ begin except on E: Exception do DebugMsg(['*** Exception raised in TLocalTreeEngine.CopyFile(Sender=', DWord(Sender), ', SourceFile=', SourceFile, ', DestFile=', DestFile, '): (', E.ClassName, '): ', E.Message]); end; - DebugMsg(['(II) TLocalTreeEngine.CopyFile: finished']); +// DebugMsg(['(II) TLocalTreeEngine.CopyFile: finished']); end; (********************************************************************************************************************************) function TLocalTreeEngine.FileExists(const FileName: string; const Use_lstat: boolean = False): Boolean; -var st: PGlibc_stat64; +var st: Pstat64; begin - st := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(st, 0, sizeof(TGlibc_stat64)); - if Use_lstat then Result := glibc_lstat64(PChar(FileName), st) = 0 - else Result := glibc_stat64(PChar(FileName), st) = 0; - Libc.free(st); + st := malloc(sizeof(Tstat64)); + memset(st, 0, sizeof(Tstat64)); + if Use_lstat then Result := lstat64(PChar(FileName), st) = 0 + else Result := stat64(PChar(FileName), st) = 0; + libc_free(st); end; (********************************************************************************************************************************) function TLocalTreeEngine.DirectoryExists(const FileName: string; const Use_lstat: boolean = False): Boolean; -var st: PGlibc_stat64; +var st: Pstat64; begin - st := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(st, 0, sizeof(TGlibc_stat64)); - if Use_lstat then Result := glibc_lstat64(PChar(FileName), st) = 0 else - if glibc_stat64(PChar(FileName), st) = 0 + st := malloc(sizeof(Tstat64)); + memset(st, 0, sizeof(Tstat64)); + if Use_lstat then Result := lstat64(PChar(FileName), st) = 0 else + if stat64(PChar(FileName), st) = 0 then Result := S_ISDIR(st^.st_mode) else Result := False; - Libc.free(st); + libc_free(st); end; (********************************************************************************************************************************) function TLocalTreeEngine.MakeSymLink(const NewFileName, PointTo: string): integer; begin // DebugMsg(['TLocalTreeEngine.MakeSymLink(NewFileName = "', NewFileName, '", PointTo = "', PointTo, '"']); - Result := Libc.symlink(PChar(PointTo), PChar(NewFileName)); + Result := symlink(PChar(PointTo), PChar(NewFileName)); if Result <> 0 then Result := errno; end; (********************************************************************************************************************************) function TLocalTreeEngine.Chmod(const FileName: string; const Mode: integer): integer; begin - Result := Libc.chmod(PChar(FileName), Mode); + Result := libc_chmod(PChar(FileName), Mode); if Result <> 0 then Result := errno; end; (********************************************************************************************************************************) function TLocalTreeEngine.Chown(const FileName: string; const UID, GID: integer): integer; begin - Result := Libc.chown(PChar(FileName), UID, GID); + Result := libc_chown(PChar(FileName), UID, GID); if Result <> 0 then Result := errno; end; @@ -927,48 +905,48 @@ end; (********************************************************************************************************************************) function TLocalTreeEngine.IsOnSameFS(const Path1, Path2: string): boolean; -var FStat1, FStat2: PGlibc_stat64; +var FStat1, FStat2: Pstat64; begin // DebugMsg(['** TLocalTreeEngine.IsOnSameFS("', Path1, '", "', Path2, '")']); Result := False; // Default fallback result (forces copy + delete) - FStat1 := Libc.malloc(sizeof(TGlibc_stat64)); - FStat2 := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(FStat1, 0, sizeof(TGlibc_stat64)); - Libc.memset(FStat2, 0, sizeof(TGlibc_stat64)); - if glibc_lstat64(PChar(Path1), FStat1) <> 0 then begin - DebugMsg(['** TLocalTreeEngine.IsOnSameFS: Libc.stat(', Path1, ') error: ', strerror(errno)]); + FStat1 := malloc(sizeof(Tstat64)); + FStat2 := malloc(sizeof(Tstat64)); + memset(FStat1, 0, sizeof(Tstat64)); + memset(FStat2, 0, sizeof(Tstat64)); + if lstat64(PChar(Path1), FStat1) <> 0 then begin + DebugMsg(['** TLocalTreeEngine.IsOnSameFS: stat(', Path1, ') error: ', strerror(errno)]); Exit; end; - if glibc_lstat64(PChar(Path2), FStat2) <> 0 then begin - DebugMsg(['** TLocalTreeEngine.IsOnSameFS: Libc.stat(', Path2, ') error: ', strerror(errno)]); + if lstat64(PChar(Path2), FStat2) <> 0 then begin + DebugMsg(['** TLocalTreeEngine.IsOnSameFS: stat(', Path2, ') error: ', strerror(errno)]); Exit; end; Result := FStat1^.st_dev = FStat2^.st_dev; - Libc.free(FStat1); - Libc.free(FStat2); + libc_free(FStat1); + libc_free(FStat2); // DebugMsg(['** TLocalTreeEngine.IsOnSameFS("', Path1, '", "', Path2, '") Result = ', Result]); end; (********************************************************************************************************************************) function TLocalTreeEngine.RenameFile(SourceFile, DestFile: string): integer; begin - Result := Libc.__rename(PChar(SourceFile), PChar(DestFile)); + Result := libc_rename(PChar(SourceFile), PChar(DestFile)); if Result <> 0 then Result := errno; end; (********************************************************************************************************************************) function TLocalTreeEngine.ChangeTimes(APath: string; mtime, atime: Int64): integer; -var timebuf: PGlibc_utimbuf; +var timebuf: Putimbuf; begin Result := errno; try - timebuf := Libc.malloc(sizeof(TGlibc_utimbuf)); - Libc.memset(timebuf, 0, sizeof(TGlibc_utimbuf)); + timebuf := malloc(sizeof(Tutimbuf)); + memset(timebuf, 0, sizeof(Tutimbuf)); timebuf^.actime := atime; timebuf^.modtime := mtime; - Result := glibc_utime(PChar(APath), timebuf); + Result := utime(PChar(APath), timebuf); if Result <> 0 then Result := errno; - Libc.free(timebuf); + libc_free(timebuf); except on E: Exception do DebugMsg(['*** Exception raised in TLocalTreeEngine.ChangeTimes(APath=', APath, '): (', E.ClassName, '): ', E.Message]); end; @@ -976,9 +954,9 @@ end; (********************************************************************************************************************************) procedure TLocalTreeEngine.GetFileSystemInfo(const APath: string; var FSSize, FSFree: Int64; var FSName: string); -var Stat: PGlibc_statfs64; - fd: PIOFile; - mntent: PMountEntry; +var Stat: Pstatfs64; + fd: PFILE; + mntent: Pmntent; mntdev: PChar; FoundLength: integer; Buffer: array[0..31] of char; @@ -987,9 +965,9 @@ begin FSFree := 0; FSName := ''; try - Stat := Libc.malloc(sizeof(TGlibc_statfs64)); - Libc.memset(Stat, 0, sizeof(TGlibc_statfs64)); - if glibc_statfs64(PChar(APath), Stat) <> 0 then Exit; + Stat := malloc(sizeof(Tstatfs64)); + memset(Stat, 0, sizeof(Tstatfs64)); + if statfs64(PChar(APath), Stat) <> 0 then Exit; FSSize := Stat^.f_bsize * Stat^.f_blocks; FSFree := Stat^.f_bsize * Stat^.f_bavail; fd := setmntent(_PATH_MOUNTED, 'r'); @@ -1017,7 +995,7 @@ begin fclose(fd); end; end; - Libc.free(Stat); + libc_free(Stat); except on E: Exception do DebugMsg(['*** Exception raised in TLocalTreeEngine.GetFileSystemInfo(APath=', APath, '): (', E.ClassName, '): ', E.Message]); end; @@ -1034,7 +1012,7 @@ begin omAppend: m := 'a'; else m := 'r'; end; - Result := Libc.fopen64(PChar(APath), m); + Result := fopen64(PChar(APath), m); if Result = nil then Error := errno; end; @@ -1042,7 +1020,7 @@ end; function TLocalTreeEngine.ReadFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; ABlockSize: integer; var Error: integer): integer; begin Error := 0; - Result := Libc.fread(Buffer, 1, ABlockSize, FileDescriptor); + Result := fread(Buffer, 1, ABlockSize, FileDescriptor); if (Result = 0) and (feof(FileDescriptor) = 0) then Error := errno; end; @@ -1050,16 +1028,16 @@ end; function TLocalTreeEngine.WriteFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; BytesCount: integer; var Error: integer): integer; begin Error := 0; -{ Result := Libc.__write(fileno(FileDescriptor), Buffer^, BytesCount); +{ Result := __write(fileno(FileDescriptor), Buffer^, BytesCount); if Result < BytesCount then Error := errno; } - Result := Libc.fwrite(Buffer, 1, BytesCount, FileDescriptor); + Result := fwrite(Buffer, 1, BytesCount, FileDescriptor); if Result < BytesCount then Error := ferror(FileDescriptor); end; (********************************************************************************************************************************) function TLocalTreeEngine.CloseFile(const FileDescriptor: TEngineFileDes): integer; begin - Result := Libc.fclose(FileDescriptor); + Result := fclose(FileDescriptor); if Result <> 0 then Result := errno; end; @@ -1067,21 +1045,21 @@ end; function TLocalTreeEngine.FileSeek(const FileDescriptor: TEngineFileDes; const AbsoluteOffset: Int64; var Error: integer): Int64; begin Error := 0; - Result := Libc.fseeko64(FileDescriptor, AbsoluteOffset, SEEK_SET); + Result := fseeko64(FileDescriptor, AbsoluteOffset, SEEK_SET); if Result = -1 then Error := errno; end; (********************************************************************************************************************************) function TLocalTreeEngine.IsOnROMedium(const FileName: string): boolean; -var Stat: PGlibc_statfs64; +var Stat: Pstatfs64; begin Result := False; try - Stat := Libc.malloc(sizeof(TGlibc_statfs64)); - Libc.memset(Stat, 0, sizeof(TGlibc_statfs64)); - if glibc_statfs64(PChar(FileName), Stat) <> 0 then Exit; + Stat := malloc(sizeof(Tstatfs64)); + memset(Stat, 0, sizeof(Tstatfs64)); + if statfs64(PChar(FileName), Stat) <> 0 then Exit; Result := (Stat^.f_type = $9660); { ISOFS_SUPER_MAGIC } - Libc.free(Stat); + libc_free(Stat); except on E: Exception do DebugMsg(['*** TLocalTreeEngine.IsOnROMedium(FileName=', FileName, ') -Exception: ', E.Message]); end; @@ -1090,7 +1068,7 @@ end; (********************************************************************************************************************************) function TLocalTreeEngine.FileCanRun(const FileName: string): boolean; begin - Result := Libc.access(PChar(FileName), R_OK or X_OK) = 0; + Result := access(PChar(FileName), R_OK or X_OK) = 0; end; (********************************************************************************************************************************) @@ -1107,19 +1085,19 @@ end; (********************************************************************************************************************************) function TLocalTreeEngine.TwoSameFiles(const Path1, Path2: string): boolean; -var st1, st2: PGlibc_stat64; +var st1, st2: Pstat64; begin Result := False; - st1 := Libc.malloc(sizeof(TGlibc_stat64)); - st2 := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(st1, 0, sizeof(TGlibc_stat64)); - Libc.memset(st2, 0, sizeof(TGlibc_stat64)); - if glibc_lstat64(PChar(Path1), st1) <> 0 then Exit; - if glibc_lstat64(PChar(Path2), st2) <> 0 then Exit; + st1 := malloc(sizeof(Tstat64)); + st2 := malloc(sizeof(Tstat64)); + memset(st1, 0, sizeof(Tstat64)); + memset(st2, 0, sizeof(Tstat64)); + if lstat64(PChar(Path1), st1) <> 0 then Exit; + if lstat64(PChar(Path2), st2) <> 0 then Exit; // DebugMsg(['*** TLocalTreeEngine.TwoSameFiles: ', st1^.st_ino, ' ', st2^.st_ino]); Result := st1^.st_ino = st2^.st_ino; - Libc.free(st1); - Libc.free(st2); + libc_free(st1); + libc_free(st2); end; @@ -1130,12 +1108,12 @@ begin try if Assigned(DataItem) then begin with DataItem^ do begin - if FName <> nil then Libc.free(FName); - if FDisplayName <> nil then Libc.free(FDisplayName); + if FName <> nil then libc_free(FName); + if FDisplayName <> nil then libc_free(FDisplayName); // if Assigned(ADestination) then Dispose(ADestination); - if LnkPointTo <> nil then Libc.free(LnkPointTo); + if LnkPointTo <> nil then libc_free(LnkPointTo); end; - Libc.free(DataItem); + libc_free(DataItem); end; except end; @@ -1147,13 +1125,13 @@ begin try if Assigned(DataItem) then begin with DataItem^ do begin - if FName <> nil then Libc.free(FName); - if FDisplayName <> nil then Libc.free(FDisplayName); - if LnkPointTo <> nil then Libc.free(LnkPointTo); + if FName <> nil then libc_free(FName); + if FDisplayName <> nil then libc_free(FDisplayName); + if LnkPointTo <> nil then libc_free(LnkPointTo); for i := 0 to Length(ColumnData) - 1 do - if ColumnData[i] <> nil then Libc.free(ColumnData[i]); + if ColumnData[i] <> nil then libc_free(ColumnData[i]); end; - Libc.free(DataItem); + libc_free(DataItem); end; except end; diff --git a/UGlibC_compat.pas b/UGlibC_compat.pas deleted file mode 100644 index 95cd75d..0000000 --- a/UGlibC_compat.pas +++ /dev/null @@ -1,267 +0,0 @@ -(* - Tux Commander - UGlibC_compat - glibc compatibility for 32- and 64-bit platforms - Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net> - Check for updates on tuxcmd.sourceforge.net - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*) -unit UGlibC_compat; - -interface -uses Classes, SysUtils {$IFNDEF CPU64}, Libc{$ENDIF}; - - -const GLIBC_LIB = 'libc.so.6'; - -type -{$IFDEF KYLIX} - QWORD = Int64; -{$ENDIF} - -{$IFNDEF CPU64} - TTimeT = DWORD; -{$ELSE} - TTimeT = QWORD; -{$ENDIF} - - PGlibc_IOFile = pointer; - - TGlibc_timespec = packed record -{$IFNDEF CPU64} // 32-bit platform - tv_sec: longint; // Seconds. - tv_nsec: longint; // Nanoseconds. -{$ELSE} // 64-bit platform - tv_sec: Int64; // Seconds. - tv_nsec: Int64; // Nanoseconds. -{$ENDIF} - end; - - PGlibc_stat = ^TGlibc_stat; -{$IFDEF KYLIX} - TGlibc_stat = TStatBuf; -{$ELSE} -{$IFNDEF CPU64} // 32-bit platform - TGlibc_stat = packed record - st_dev : __dev_t; - __pad1 : word; - __align_pad1 : word; - st_ino : __ino_t; - st_mode : __mode_t; - st_nlink : __nlink_t; - st_uid : __uid_t; - st_gid : __gid_t; - st_rdev : __dev_t; - __pad2 : word; - __align_pad2 : word; - st_size : __off_t; - st_blksize : __blksize_t; - st_blocks : __blkcnt_t; - - st_atim : TGlibc_timespec; - st_mtim : TGlibc_timespec; - st_ctim : TGlibc_timespec; - -{ st_atime : __time_t; - __unused1 : dword; - st_mtime : __time_t; - __unused2 : dword; - st_ctime : __time_t; - __unused3 : dword; } - - __unused4 : dword; - __unused5 : dword; - end; -{$ELSE} // 64-bit platform - TGlibc_stat = packed record - st_dev : QWORD; - st_ino : Int64; - st_nlink : QWORD; - st_mode : DWORD; - st_uid : DWORD; - st_gid : DWORD; - pad0 : DWORD; - st_rdev : QWORD; - st_size : Int64; - st_blksize : Int64; - st_blocks : Int64; - st_atim : TGlibc_timespec; - st_mtim : TGlibc_timespec; - st_ctim : TGlibc_timespec; - __unused : array[1..3] of QWORD; - end; -{$ENDIF} -{$ENDIF} - - PGlibc_stat64 = ^TGlibc_stat64; -{$IFDEF KYLIX} - TGlibc_stat64 = TStatBuf64; -{$ELSE} - TGlibc_stat64 = packed record -{$IFNDEF CPU64} // 32-bit platform - st_dev : __dev_t; - __pad1 : dword; - __st_ino : __ino_t; - st_mode : __mode_t; - st_nlink : __nlink_t; - st_uid : __uid_t; - st_gid : __gid_t; - st_rdev : __dev_t; - __pad2 : dword; - st_size : __off64_t; - st_blksize : __blksize_t; - st_blocks : __blkcnt64_t; - - st_atim : TGlibc_timespec; - st_mtim : TGlibc_timespec; - st_ctim : TGlibc_timespec; - -{ st_atime : __time_t; - __unused1 : dword; - st_mtime : __time_t; - __unused2 : dword; - st_ctime : __time_t; - __unused3 : dword; } - - st_ino : __ino64_t; -{$ELSE} // 64-bit platform - st_dev : QWORD; - st_ino : Int64; - st_nlink : QWORD; - st_mode : DWORD; - st_uid : DWORD; - st_gid : DWORD; - pad0 : DWORD; - st_rdev : QWORD; - st_size : Int64; - st_blksize : Int64; - st_blocks : Int64; - st_atim : TGlibc_timespec; - st_mtim : TGlibc_timespec; - st_ctim : TGlibc_timespec; - __unused : array[1..3] of QWORD; -{$ENDIF} - end; -{$ENDIF} - - - TGlibc_fsid_t = packed record - __val : array[0..1] of longint; - end; - - PGlibc_statfs64 = ^TGlibc_statfs64; - TGlibc_statfs64 = packed record -{$IFNDEF CPU64} // 32-bit platform - f_type : longint; - f_bsize : longint; - f_blocks : __fsblkcnt64_t; - f_bfree : __fsblkcnt64_t; - f_bavail : __fsblkcnt64_t; - f_files : __fsfilcnt64_t; - f_ffree : __fsfilcnt64_t; - f_fsid : __fsid_t; - f_namelen : longint; - f_spare : array[0..5] of longint; -{$ELSE} // 64-bit platform - f_type : Int64; - f_bsize : Int64; - f_blocks : QWORD; - f_bfree : QWORD; - f_bavail : QWORD; - f_files : QWORD; - f_ffree : QWORD; - f_fsid : TGlibc_fsid_t; - f_namelen : Int64; - f_spare : array[0..5] of Int64; -{$ENDIF} - end; - - PGlibc_utimbuf = ^TGlibc_utimbuf; - TGlibc_utimbuf = packed record -{$IFNDEF CPU64} // 32-bit platform - actime : __time_t; - modtime : __time_t; -{$ELSE} // 64-bit platform - actime : Int64; - modtime : Int64; -{$ENDIF} - end; - - PGlibc_mntent = ^TGlibc_mntent; - TGlibc_mntent = packed record -{$IFNDEF CPU64} // 32-bit platform - mnt_fsname : Pchar; - mnt_dir : Pchar; - mnt_type : Pchar; - mnt_opts : Pchar; - mnt_freq : longint; - mnt_passno : longint; -{$ELSE} // 64-bit platform - mnt_fsname : Pchar; - mnt_dir : Pchar; - mnt_type : Pchar; - mnt_opts : Pchar; - mnt_freq : Longint; - mnt_passno : Longint; -{$ENDIF} - end; - - - - - -{$IFNDEF KYLIX} -function glibc_stat64(const afile: PChar; buf: PGlibc_stat64): longint; cdecl; external GLIBC_LIB name 'stat64'; -function glibc_lstat64(const path: PChar; buf: PGlibc_stat64): longint; cdecl; external GLIBC_LIB name 'lstat64'; -{$ELSE} -function glibc_stat64(const afile: PChar; buf: PGlibc_stat64): longint; -function glibc_lstat64(const path: PChar; buf: PGlibc_stat64): longint; -{$ENDIF} - -{ -function glibc_localtime(timep: Pointer): Pointer; cdecl; external GLIBC_LIB name 'localtime'; -function glibc_strftime(s: PChar; max: Longint; format: PChar; tm: Pointer): Longint; cdecl; external GLIBC_LIB name 'strftime'; -} - -function glibc_statfs64(const path: PChar; buf: PGlibc_statfs64): longint; cdecl; external GLIBC_LIB name 'statfs64'; - -function glibc_fileno(stream: PGlibc_IOFile): integer; cdecl; external GLIBC_LIB name 'fileno'; - -function glibc_utime(const afile: Pchar; buf: PGlibc_utimbuf): Longint; cdecl; external GLIBC_LIB name 'utime'; - - -function glibc_setmntent(const afile: Pchar; mode: Pchar): PGlibc_IOFile; cdecl; external GLIBC_LIB name 'setmntent'; -function glibc_getmntent(stream: PGlibc_IOFile): PGlibc_mntent; cdecl; external GLIBC_LIB name 'getmntent'; -function glibc_endmntent(stream: PGlibc_IOFile): Longint; cdecl; external GLIBC_LIB name 'endmntent'; - - -implementation - -{$IFDEF KYLIX} -function glibc__xstat64(ver: integer; const afile: PChar; buf: PGlibc_stat64): longint; cdecl; external GLIBC_LIB name '__xstat64'; -function glibc__lxstat64(ver: integer; const path: PChar; buf: PGlibc_stat64): longint; cdecl; external GLIBC_LIB name '__lxstat64'; - -function glibc_stat64(const afile: PChar; buf: PGlibc_stat64): longint; -begin - Result := glibc__xstat64(_STAT_VER, afile, buf); -end; - -function glibc_lstat64(const path: PChar; buf: PGlibc_stat64): longint; -begin - Result := glibc__lxstat64(_STAT_VER, path, buf); -end; -{$ENDIF} - -end. - @@ -21,7 +21,7 @@ unit UGnome; interface -uses glib2, gdk2, gdk2pixbuf, gtk2, pango, Classes, Libc, +uses glib2, gdk2, gdk2pixbuf, gtk2, Classes, ULibc, GTKForms, GTKControls, GTKStdCtrls, GTKExtCtrls, GTKClasses, GTKDialogs, GTKUtils, GTKConsts; type TGnomeColorButton = class(TGTKButton) @@ -174,7 +174,7 @@ var libGlib2Handle, libGtk2Handle, libGnome2Handle, libGnomeUI2Handle: Pointer; gnome_icon_entry_set_pixmap_subdir: procedure (ientry: PGnomeIconEntry; const subdir: Pgchar); cdecl; gnome_icon_entry_get_filename: function (ientry: PGnomeIconEntry): Pgchar; cdecl; gnome_icon_entry_set_filename: function (ientry: PGnomeIconEntry; const filename: Pgchar): gboolean; cdecl; - gnome_date_edit_new: function (the_time: __time_t; show_time, use_24_format: gboolean): PGtkWidget; cdecl; + gnome_date_edit_new: function (the_time: time_t; show_time, use_24_format: gboolean): PGtkWidget; cdecl; gnome_date_edit_set_time: procedure (gde: PGnomeDateEdit; the_time: time_t); cdecl; gnome_date_edit_get_time: function (gde: PGnomeDateEdit): time_t; cdecl; gtk_event_box_set_visible_window: procedure (event_box: PGtkEventBox; visible_window: gboolean); cdecl; diff --git a/ULibc.pas b/ULibc.pas new file mode 100644 index 0000000..c11566d --- /dev/null +++ b/ULibc.pas @@ -0,0 +1,945 @@ +(* + Tux Commander - ULibc - translated glibc functions for all platforms + Copyright (C) 2008 Tomas Bzatek <tbzatek@users.sourceforge.net> + Check for updates on tuxcmd.sourceforge.net + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*) +unit ULibc; + +interface + + +const GLIBC_LIB = 'libc.so.6'; + DL_LIB = 'libdl.so.2'; + +type +{$IFDEF KYLIX} + DWORD = Cardinal; + QWORD = Int64; +{$ENDIF} + + sig_atomic_t = Longint; + size_t = Cardinal; + ssize_t = Longint; + error_t = Integer; + __mode_t = DWORD; + __dev_t = QWORD; + __pid_t = Longint; + __id_t = DWORD; + __uid_t = DWORD; + __gid_t = DWORD; + __off64_t = Int64; + __off_t = Longint; + __ino_t = DWORD; + __ino64_t = QWORD; + __nlink_t = DWORD; + __blksize_t = Longint; + __blkcnt_t = Longint; + __blkcnt64_t = Int64; + + + Pidtype_t = ^idtype_t; + idtype_t = (P_ALL,P_PID,P_PGID); + + Psiginfo_t = Pointer; + Prusage = Pointer; + PDIR = Pointer; + PFILE = Pointer; + Pfpos_t = Pointer; + Pfpos64_t = Pointer; + + Ttimespec = packed record +{$IFNDEF CPU64} // 32-bit platform + tv_sec: longint; + tv_nsec: longint; +{$ELSE} // 64-bit platform + tv_sec: Int64; + tv_nsec: Int64; +{$ENDIF} + end; + + Ptm = ^tm; + tm = record + tm_sec : longint; + tm_min : longint; + tm_hour : longint; + tm_mday : longint; + tm_mon : longint; + tm_year : longint; + tm_wday : longint; + tm_yday : longint; + tm_isdst : longint; + case boolean of + false : (tm_gmtoff : longint;tm_zone : Pchar); + true : (__tm_gmtoff : longint;__tm_zone : Pchar); + end; + + Pdirent64 = ^Tdirent64; + Tdirent64 = record + d_ino : QWORD; + d_off : Int64; + d_reclen : word; + d_type : byte; + d_name : array[0..255] of char; + end; + + Pstat64 = ^Tstat64; + Tstat64 = packed record +{$IFNDEF CPU64} // 32-bit platform + st_dev : __dev_t; + __pad1 : dword; + __st_ino : __ino_t; + st_mode : __mode_t; + st_nlink : __nlink_t; + st_uid : __uid_t; + st_gid : __gid_t; + st_rdev : __dev_t; + __pad2 : dword; + st_size : __off64_t; + st_blksize : __blksize_t; + st_blocks : __blkcnt64_t; + + st_atim : Ttimespec; + st_mtim : Ttimespec; + st_ctim : Ttimespec; + +{ st_atime : __time_t; + __unused1 : dword; + st_mtime : __time_t; + __unused2 : dword; + st_ctime : __time_t; + __unused3 : dword; } + + st_ino : __ino64_t; +{$ELSE} // 64-bit platform + st_dev : QWORD; + st_ino : Int64; + st_nlink : QWORD; + st_mode : DWORD; + st_uid : DWORD; + st_gid : DWORD; + pad0 : DWORD; + st_rdev : QWORD; + st_size : Int64; + st_blksize : Int64; + st_blocks : Int64; + st_atim : Ttimespec; + st_mtim : Ttimespec; + st_ctim : Ttimespec; + __unused : array[1..3] of QWORD; +{$ENDIF} + end; + + + fsid_t = packed record + __val : array[0..1] of longint; + end; + + Pstatfs64 = ^Tstatfs64; + Tstatfs64 = packed record +{$IFNDEF CPU64} // 32-bit platform + f_type : longint; + f_bsize : longint; + f_blocks : QWORD; + f_bfree : QWORD; + f_bavail : QWORD; + f_files : QWORD; + f_ffree : QWORD; + f_fsid : fsid_t; + f_namelen : longint; + f_spare : array[0..5] of longint; +{$ELSE} // 64-bit platform + f_type : Int64; + f_bsize : Int64; + f_blocks : QWORD; + f_bfree : QWORD; + f_bavail : QWORD; + f_files : QWORD; + f_ffree : QWORD; + f_fsid : fsid_t; + f_namelen : Int64; + f_spare : array[0..5] of Int64; +{$ENDIF} + end; + +{$IFNDEF CPU64} + time_t = longint; +{$ELSE} + time_t = Int64; +{$ENDIF} + Ptime_t = ^time_t; + + Putimbuf = ^Tutimbuf; + Tutimbuf = packed record + actime : time_t; + modtime : time_t; + end; + + Pmntent = ^Tmntent; + Tmntent = packed record +{$IFNDEF CPU64} // 32-bit platform + mnt_fsname : PChar; + mnt_dir : PChar; + mnt_type : PChar; + mnt_opts : PChar; + mnt_freq : Longint; + mnt_passno : Longint; +{$ELSE} // 64-bit platform + mnt_fsname : PChar; + mnt_dir : PChar; + mnt_type : PChar; + mnt_opts : PChar; + mnt_freq : Longint; + mnt_passno : Longint; +{$ENDIF} + end; + + PPasswd = ^TPasswd; + TPasswd = record + pw_name : PChar; + pw_passwd : PChar; + pw_uid : __uid_t; + pw_gid : __gid_t; + pw_gecos : PChar; + pw_dir : PChar; + pw_shell : PChar; + end; + PPPasswd = ^PPasswd; + + PGroup = ^TGroup; + TGroup = record + gr_name : PChar; + gr_passwd : PChar; + gr_gid : __gid_t; + gr_mem : ^PChar; + end; + PPGroup = ^PGroup; + + Psigval = ^sigval; + sigval = record + case longint of + 0 : ( sival_int : longint ); + 1 : ( sival_ptr : pointer ); + end; + sigval_t = sigval; + Psigval_t = ^sigval_t; + +const + _SIGSET_NWORDS = 1024 div (8 * (sizeof(dword))); + +type + __sighandler_t = procedure(SigNum: Integer); cdecl; + P__sigset_t = ^__sigset_t; + __sigset_t = record + __val : array[0..(_SIGSET_NWORDS)-1] of dword; + end; + sigset_t = __sigset_t; + Psigset_t = ^sigset_t; + P_sigaction = ^_sigaction; + _sigaction = record // Renamed, avoid conflict with sigaction function + case integer of + 1: (sa_handler : __sighandler_t; + sa_mask : __sigset_t; + sa_flags : longint; + sa_restorer : procedure ;cdecl; + ); + // Kylix compatibility + 2: (__sigaction_handler: __sighandler_t); + end; + TSigAction = _sigaction; + PSigAction = ^TSigAction; + TRestoreHandler = procedure; cdecl; + __sigaction = _sigaction; + TSigActionHandler = procedure(Signal: Integer); cdecl; + +const + EPERM = 1; + ENOENT = 2; + ESRCH = 3; + EINTR = 4; + EIO = 5; + ENXIO = 6; + E2BIG = 7; + ENOEXEC = 8; + EBADF = 9; + ECHILD = 10; + EAGAIN = 11; + ENOMEM = 12; + EACCES = 13; + EFAULT = 14; + ENOTBLK = 15; + EBUSY = 16; + EEXIST = 17; + EXDEV = 18; + ENODEV = 19; + ENOTDIR = 20; + EISDIR = 21; + EINVAL = 22; + ENFILE = 23; + EMFILE = 24; + ENOTTY = 25; + ETXTBSY = 26; + EFBIG = 27; + ENOSPC = 28; + ESPIPE = 29; + EROFS = 30; + EMLINK = 31; + EPIPE = 32; + EDOM = 33; + ERANGE = 34; + EDEADLK = 35; + ENAMETOOLONG = 36; + ENOLCK = 37; + ENOSYS = 38; + ENOTEMPTY = 39; + ELOOP = 40; + EWOULDBLOCK = EAGAIN; + ENOMSG = 42; + EIDRM = 43; + ECHRNG = 44; + EL2NSYNC = 45; + EL3HLT = 46; + EL3RST = 47; + ELNRNG = 48; + EUNATCH = 49; + ENOCSI = 50; + EL2HLT = 51; + EBADE = 52; + EBADR = 53; + EXFULL = 54; + ENOANO = 55; + EBADRQC = 56; + EBADSLT = 57; + EDEADLOCK = EDEADLK; + EBFONT = 59; + ENOSTR = 60; + ENODATA = 61; + ETIME = 62; + ENOSR = 63; + ENONET = 64; + ENOPKG = 65; + EREMOTE = 66; + ENOLINK = 67; + EADV = 68; + ESRMNT = 69; + ECOMM = 70; + EPROTO = 71; + EMULTIHOP = 72; + EDOTDOT = 73; + EBADMSG = 74; + EOVERFLOW = 75; + ENOTUNIQ = 76; + EBADFD = 77; + EREMCHG = 78; + ELIBACC = 79; + ELIBBAD = 80; + ELIBSCN = 81; + ELIBMAX = 82; + ELIBEXEC = 83; + EILSEQ = 84; + ERESTART = 85; + ESTRPIPE = 86; + EUSERS = 87; + ENOTSOCK = 88; + EDESTADDRREQ = 89; + EMSGSIZE = 90; + EPROTOTYPE = 91; + ENOPROTOOPT = 92; + EPROTONOSUPPORT = 93; + ESOCKTNOSUPPORT = 94; + EOPNOTSUPP = 95; + EPFNOSUPPORT = 96; + EAFNOSUPPORT = 97; + EADDRINUSE = 98; + EADDRNOTAVAIL = 99; + ENETDOWN = 100; + ENETUNREACH = 101; + ENETRESET = 102; + ECONNABORTED = 103; + ECONNRESET = 104; + ENOBUFS = 105; + EISCONN = 106; + ENOTCONN = 107; + ESHUTDOWN = 108; + ETOOMANYREFS = 109; + ETIMEDOUT = 110; + ECONNREFUSED = 111; + EHOSTDOWN = 112; + EHOSTUNREACH = 113; + EALREADY = 114; + EINPROGRESS = 115; + ESTALE = 116; + EUCLEAN = 117; + ENOTNAM = 118; + ENAVAIL = 119; + EISNAM = 120; + EREMOTEIO = 121; + EDQUOT = 122; + ENOMEDIUM = 123; + EMEDIUMTYPE = 124; + ENOTSUP = EOPNOTSUPP; + ECANCELED = 125; + +const + __S_IFMT = $F000; + __S_IFDIR = $4000; + __S_IFCHR = $2000; + __S_IFBLK = $6000; + __S_IFREG = $8000; + __S_IFIFO = $1000; + __S_IFLNK = $A000; + __S_IFSOCK = $C000; + + __S_ISUID = $800; + __S_ISGID = $400; + __S_ISVTX = $200; + __S_IREAD = $100; + __S_IWRITE = $80; + __S_IEXEC = $40; + + S_IFMT = __S_IFMT; + S_IFDIR = __S_IFDIR; + S_IFCHR = __S_IFCHR; + S_IFBLK = __S_IFBLK; + S_IFREG = __S_IFREG; + S_IFIFO = __S_IFIFO; + S_IFLNK = __S_IFLNK; + S_IFSOCK = __S_IFSOCK; + +function __S_ISTYPE(mode, mask : __mode_t) : boolean; +function S_ISDIR(mode : __mode_t) : boolean; +function S_ISCHR(mode : __mode_t) : boolean; +function S_ISBLK(mode : __mode_t) : boolean; +function S_ISREG(mode : __mode_t) : boolean; +function S_ISFIFO(mode : __mode_t) : boolean; +function S_ISLNK(mode : __mode_t) : boolean; +function S_ISSOCK(mode : __mode_t) : boolean; + +const + S_ISUID = __S_ISUID; + S_ISGID = __S_ISGID; + S_ISVTX = __S_ISVTX; + + S_IRUSR = __S_IREAD; + S_IWUSR = __S_IWRITE; + S_IXUSR = __S_IEXEC; + S_IRWXU = (__S_IREAD or __S_IWRITE) or __S_IEXEC; + + S_IREAD = S_IRUSR; + S_IWRITE = S_IWUSR; + S_IEXEC = S_IXUSR; + + S_IRGRP = S_IRUSR shr 3; + S_IWGRP = S_IWUSR shr 3; + S_IXGRP = S_IXUSR shr 3; + S_IRWXG = S_IRWXU shr 3; + S_IROTH = S_IRGRP shr 3; + S_IWOTH = S_IWGRP shr 3; + S_IXOTH = S_IXGRP shr 3; + S_IRWXO = S_IRWXG shr 3; + +const + ACCESSPERMS = (S_IRWXU or S_IRWXG) or S_IRWXO; + ALLPERMS = ((((S_ISUID or S_ISGID) or S_ISVTX) or S_IRWXU) or S_IRWXG) or S_IRWXO; + DEFFILEMODE = ((((S_IRUSR or S_IWUSR) or S_IRGRP) or S_IWGRP) or S_IROTH) or S_IWOTH; + S_BLKSIZE = 512; + +const + DT_UNKNOWN = 0; + DT_FIFO = 1; + DT_CHR = 2; + DT_DIR = 4; + DT_BLK = 6; + DT_REG = 8; + DT_LNK = 10; + DT_SOCK = 12; + DT_WHT = 14; + +const + RTLD_LAZY = $00001; + RTLD_NOW = $00002; + RTLD_BINDING_MASK = $3; + RTLD_NOLOAD = $00004; + RTLD_GLOBAL = $00100; + RTLD_LOCAL = 0; + RTLD_NODELETE = $01000; + +const + _PATH_DEFPATH = '/usr/bin:/bin'; + _PATH_STDPATH = '/usr/bin:/bin:/usr/sbin:/sbin'; + _PATH_BSHELL = '/bin/sh'; + _PATH_CONSOLE = '/dev/console'; + _PATH_CSHELL = '/bin/csh'; + _PATH_DEVDB = '/var/run/dev.db'; + _PATH_DEVNULL = '/dev/null'; + _PATH_DRUM = '/dev/drum'; + _PATH_KLOG = '/proc/kmsg'; + _PATH_KMEM = '/dev/kmem'; + _PATH_LASTLOG = '/var/log/lastlog'; + _PATH_MAILDIR = '/var/mail'; + _PATH_MAN = '/usr/share/man'; + _PATH_MEM = '/dev/mem'; + _PATH_MNTTAB = '/etc/fstab'; + _PATH_MOUNTED = '/etc/mtab'; + _PATH_NOLOGIN = '/etc/nologin'; + _PATH_PRESERVE = '/var/lib'; + _PATH_RWHODIR = '/var/spool/rwho'; + _PATH_SENDMAIL = '/usr/sbin/sendmail'; + _PATH_SHADOW = '/etc/shadow'; + _PATH_SHELLS = '/etc/shells'; + _PATH_TTY = '/dev/tty'; + _PATH_UNIX = '/boot/vmlinux'; + _PATH_UTMP = '/var/run/utmp'; + _PATH_VI = '/usr/bin/vi'; + _PATH_WTMP = '/var/log/wtmp'; + _PATH_DEV = '/dev/'; + _PATH_TMP = '/tmp/'; + _PATH_VARDB = '/var/db/'; + _PATH_VARRUN = '/var/run/'; + _PATH_VARTMP = '/var/tmp/'; + +const + WCOREFLAG = $80; + +const + SIG_ERR = (-1); + SIG_DFL = (0); + SIG_IGN = (1); + SIG_HOLD = (2); + +const + SIGHUP = 1; + SIGINT = 2; + SIGQUIT = 3; + SIGILL = 4; + SIGTRAP = 5; + SIGABRT = 6; + SIGIOT = 6; + SIGBUS = 7; + SIGFPE = 8; + SIGKILL = 9; + SIGUSR1 = 10; + SIGSEGV = 11; + SIGUSR2 = 12; + SIGPIPE = 13; + SIGALRM = 14; + SIGTERM = 15; + SIGSTKFLT = 16; + SIGCHLD = 17; + SIGCLD = SIGCHLD; + SIGCONT = 18; + SIGSTOP = 19; + SIGTSTP = 20; + SIGTTIN = 21; + SIGTTOU = 22; + SIGURG = 23; + SIGXCPU = 24; + SIGXFSZ = 25; + SIGVTALRM = 26; + SIGPROF = 27; + SIGWINCH = 28; + SIGIO = 29; + SIGPOLL = SIGIO; + SIGPWR = 30; + SIGSYS = 31; + SIGUNUSED = 31; + _NSIG = 64; + +const + WNOHANG = 1; + WUNTRACED = 2; + __WALL = $40000000; + __WCLONE = $80000000; + +const + STDIN_FILENO = 0; + STDOUT_FILENO = 1; + STDERR_FILENO = 2; + +const + R_OK = 4; + W_OK = 2; + X_OK = 1; + F_OK = 0; + +const + SEEK_SET = 0; + SEEK_CUR = 1; + SEEK_END = 2; + +const + _STAT_VER_LINUX_OLD = 1; + _STAT_VER_KERNEL = 1; + _STAT_VER_SVR4 = 2; + _STAT_VER_LINUX = 3; + _STAT_VER = _STAT_VER_LINUX; + + _MKNOD_VER_LINUX = 1; + _MKNOD_VER_SVR4 = 2; + _MKNOD_VER = _MKNOD_VER_LINUX; + +{$IFNDEF KYLIX} +function stat64(const afile: PChar; buf: Pstat64): longint; cdecl; external GLIBC_LIB name 'stat64'; +function lstat64(const path: PChar; buf: Pstat64): longint; cdecl; external GLIBC_LIB name 'lstat64'; +{$ELSE} +function stat64(const afile: PChar; buf: Pstat64): longint; +function lstat64(const path: PChar; buf: Pstat64): longint; +{$ENDIF} + +function statfs64(const path: PChar; buf: Pstatfs64): longint; cdecl; external GLIBC_LIB name 'statfs64'; + +function chmod(const path: PChar; mode: __mode_t): Longint; cdecl; external GLIBC_LIB name 'chmod'; +function libc_chmod(const path: PChar; mode: __mode_t): Longint; cdecl; external GLIBC_LIB name 'chmod'; +function fchmod(fildes: Longint; mode: __mode_t): Longint; cdecl; external GLIBC_LIB name 'fchmod'; +function umask(mask: __mode_t): __mode_t; cdecl; external GLIBC_LIB name 'umask'; +function getumask: __mode_t; cdecl; external GLIBC_LIB name 'getumask'; +function chown(const path: PChar; owner: __uid_t; group: __gid_t): Longint; cdecl; external GLIBC_LIB name 'chown'; +function libc_chown(const path: PChar; owner: __uid_t; group: __gid_t): Longint; cdecl; external GLIBC_LIB name 'chown'; +function fchown(fd: Longint; owner: __uid_t; group: __gid_t): Longint; cdecl; external GLIBC_LIB name 'fchown'; +function lchown(const path: PChar; owner: __uid_t; group:__gid_t): Longint; cdecl; external GLIBC_LIB name 'lchown'; + +function __mkdir(const pathname: PChar; mode: __mode_t): Longint; cdecl; external GLIBC_LIB name 'mkdir'; +function mkdir(const pathname: PChar; mode: __mode_t): Longint; cdecl; external GLIBC_LIB name 'mkdir'; +function libc_mkdir(const pathname: PChar; mode: __mode_t): Longint; cdecl; external GLIBC_LIB name 'mkdir'; +function mknod(const pathname: PChar; mode: __mode_t; dev: __dev_t): Longint; cdecl; external GLIBC_LIB name 'mknod'; +function mkfifo(const pathname: PChar; mode: __mode_t): Longint; cdecl; external GLIBC_LIB name 'mkfifo'; + +function fileno(stream: PFILE): integer; cdecl; external GLIBC_LIB name 'fileno'; + +function utime(const afile: Pchar; buf: Putimbuf): Longint; cdecl; external GLIBC_LIB name 'utime'; + +function setmntent(const afile: PChar; const mode: PChar): PFILE; cdecl; external GLIBC_LIB name 'setmntent'; +function getmntent(stream: PFILE): Pmntent; cdecl; external GLIBC_LIB name 'getmntent'; +function endmntent(stream: PFILE): Longint; cdecl; external GLIBC_LIB name 'endmntent'; + +function dlopen(const filename: PChar; flag: Longint): Pointer; cdecl; external DL_LIB name 'dlopen'; +function dlclose(handle: Pointer): Longint; cdecl; external DL_LIB name 'dlclose'; +function dlsym(handle: Pointer; const symbol: PChar): Pointer; cdecl; external DL_LIB name 'dlsym'; +function dlerror: PChar; cdecl; external GLIBC_LIB name 'dlerror'; + +function malloc(size: size_t): Pointer; cdecl; external GLIBC_LIB name 'malloc'; +function calloc(nmemb: size_t; size: size_t): Pointer; cdecl; external GLIBC_LIB name 'calloc'; +function realloc(ptr: Pointer; size: size_t): Pointer; cdecl; external GLIBC_LIB name 'realloc'; +procedure free(ptr: Pointer); cdecl; external GLIBC_LIB name 'free'; +procedure libc_free(ptr: Pointer); cdecl; external GLIBC_LIB name 'free'; +procedure cfree(ptr: Pointer); cdecl; external GLIBC_LIB name 'cfree'; +function memalign(boundary: size_t; size: size_t): Pointer; cdecl; external GLIBC_LIB name 'memalign'; +function valloc(size: size_t): Pointer; cdecl; external GLIBC_LIB name 'valloc'; + +function memcpy(dest: Pointer; src: Pointer; n: size_t): Pointer; cdecl; external GLIBC_LIB name 'memcpy'; +function memmove(dest: Pointer; src: Pointer; n: size_t): Pointer; cdecl; external GLIBC_LIB name 'memmove'; +function memccpy(dest: Pointer; src: Pointer; c: longint; n: size_t): Pointer; cdecl; external GLIBC_LIB name 'memccpy'; +function memset(s: Pointer; c: Longint; n: size_t): Pointer; cdecl; external GLIBC_LIB name 'memset'; +function memcmp(s1: Pointer; s2: Pointer; n: size_t): Longint; cdecl; external GLIBC_LIB name 'memcmp'; +function memchr(s: Pointer; c: Longint; n: size_t): Pointer; cdecl; external GLIBC_LIB name 'memchr'; +function strcpy(dest: PChar; const src: PChar): PChar; cdecl; external GLIBC_LIB name 'strcpy'; +function strncpy(dest: PChar; const src: PChar; n: size_t): PChar; cdecl; external GLIBC_LIB name 'strncpy'; +function strcat(dest: PChar; const src: PChar): PChar; cdecl; external GLIBC_LIB name 'strcat'; +function strncat(dest: PChar; const src: PChar; n: size_t): PChar; cdecl; external GLIBC_LIB name 'strncat'; +function strcmp(const s1: PChar; const s2: PChar): Longint; cdecl; external GLIBC_LIB name 'strcmp'; +function strncmp(const s1: PChar; const s2: PChar; n: size_t): Longint; cdecl; external GLIBC_LIB name 'strncmp'; +function strcasecmp(const s1: PChar; const s2: PChar): Longint; cdecl; external GLIBC_LIB name 'strcasecmp'; +function strncasecmp(const s1: PChar; const s2: PChar; n: size_t): Longint; cdecl; external GLIBC_LIB name 'strncasecmp'; +function strdup(const s: PChar): PChar; cdecl; external GLIBC_LIB name 'strdup'; +function strndup(const s: PChar; n: size_t): PChar; cdecl; external GLIBC_LIB name 'strndup'; +function strchr(const s: PChar; c: Longint): PChar; cdecl; external GLIBC_LIB name 'strchr'; +function strrchr(const s: PChar; c: Longint): PChar; cdecl; external GLIBC_LIB name 'strrchr'; +function strstr(const haystack: PChar; const needle: PChar): PChar; cdecl; external GLIBC_LIB name 'strstr'; +function strcasestr(const haystack: PChar; const needle: PChar): PChar; cdecl; external GLIBC_LIB name 'strcasestr'; +function strtok(s: PChar; const delim: PChar): PChar; cdecl; external GLIBC_LIB name 'strtok'; +function strtok_r(s: PChar; const delim: PChar; save_ptr: PPchar): PChar; cdecl; external GLIBC_LIB name 'strtok_r'; +function strsep(stringp: PPchar; const delim: PChar): PChar; cdecl; external GLIBC_LIB name 'strsep'; +function strlen(const s: PChar): size_t; cdecl; external GLIBC_LIB name 'strlen'; +function strnlen(const s: PChar; maxlen: size_t): size_t; cdecl; external GLIBC_LIB name 'strnlen'; +function strerror(errnum: Longint): PChar; cdecl; external GLIBC_LIB name 'strerror'; +function strerror_r(errnum: Longint; buf: PChar; buflen: size_t): PChar; cdecl; external GLIBC_LIB name 'strerror_r'; +function strsignal(sig: Longint): PChar; cdecl; external GLIBC_LIB name 'strsignal'; + +function __chdir(const path: PChar): Longint; cdecl; external GLIBC_LIB name 'chdir'; +function chdir(const path: PChar): Longint; cdecl; external GLIBC_LIB name 'chdir'; +function libc_chdir(const path: PChar): Longint; cdecl; external GLIBC_LIB name 'chdir'; + +function errno : error_t; +function __errno_location: PInteger; cdecl; external GLIBC_LIB name '__errno_location'; + +function fork: __pid_t; cdecl; external GLIBC_LIB name 'fork'; +function vfork: __pid_t; cdecl; external GLIBC_LIB name 'vfork'; +function link(const oldpath: PChar; const newpath: PChar): Longint; cdecl; external GLIBC_LIB name 'link'; +function symlink(const oldpath: PChar; const newpath: PChar): Longint; cdecl; external GLIBC_LIB name 'symlink'; +function readlink(const path: PChar; buf: PChar; bufsiz: size_t): Longint; cdecl; external GLIBC_LIB name 'readlink'; +function unlink(const pathname: PChar): Longint; cdecl; external GLIBC_LIB name 'unlink'; +function __rmdir(const pathname: PChar): Longint; cdecl; external GLIBC_LIB name 'rmdir'; +function rmdir(const pathname: PChar): Longint; cdecl; external GLIBC_LIB name 'rmdir'; +function libc_rmdir(const pathname: PChar): Longint; cdecl; external GLIBC_LIB name 'rmdir'; +function remove(const pathname: PChar): Longint; cdecl; external GLIBC_LIB name 'remove'; +function libc_remove(const pathname: PChar): Longint; cdecl; external GLIBC_LIB name 'remove'; +function __rename(const oldpath: PChar; const newpath: PChar): Longint; cdecl; external GLIBC_LIB name 'rename'; +function libc_rename(const oldpath: PChar; const newpath: PChar): Longint; cdecl; external GLIBC_LIB name 'rename'; +function wait(status: PLongint): __pid_t; cdecl; external GLIBC_LIB name 'wait'; +function waitpid(pid: __pid_t; status: Plongint; options: Longint): __pid_t; cdecl; external GLIBC_LIB name 'waitpid'; +function waitid(idtype: idtype_t; id: __id_t; infop: Psiginfo_t; options: Longint): Longint; cdecl; external GLIBC_LIB name 'waitid'; +function wait3(status: Plongint; options: Longint; rusage: Prusage): __pid_t; cdecl; external GLIBC_LIB name 'wait3'; +function wait4(pid: __pid_t; status: Plongint; options: Longint; rusage: Prusage): __pid_t; cdecl; external GLIBC_LIB name 'wait4'; + +function opendir(const name: PChar): PDIR; cdecl; external GLIBC_LIB name 'opendir'; +function closedir(dir: PDIR): Longint; cdecl; external GLIBC_LIB name 'closedir'; +function readdir64(dir: PDIR): PDirent64; cdecl; external GLIBC_LIB name 'readdir64'; +procedure rewinddir(dir: PDIR); cdecl; external GLIBC_LIB name 'rewinddir'; +procedure seekdir(dir: PDIR; pos: Longint); cdecl; external GLIBC_LIB name 'seekdir'; +function telldir(dir: PDIR): Longint; cdecl; external GLIBC_LIB name 'telldir'; +function dirfd(dir: PDIR): Longint; cdecl; external GLIBC_LIB name 'dirfd'; + +function getcwd(buf: PChar; size: size_t): PChar; cdecl; external GLIBC_LIB name 'getcwd'; +function get_current_dir_name: PChar; cdecl; external GLIBC_LIB name 'get_current_dir_name'; +function getwd(buf: PChar): PChar; cdecl; external GLIBC_LIB name 'getwd'; + +function dup(oldfd: Longint): Longint; cdecl; external GLIBC_LIB name 'dup'; +function dup2(oldfd: Longint; newfd: Longint): Longint; cdecl; external GLIBC_LIB name 'dup2'; + +function execve(const filename: PChar; const argv: PPchar; const envp: PPchar): Longint; cdecl; external GLIBC_LIB name 'execve'; +function execv(const path: PChar; const argv: PPchar): Longint; cdecl; external GLIBC_LIB name 'execv'; +function execle(const path: PChar; const arg: PChar): Longint; cdecl; varargs; external GLIBC_LIB name 'execle'; +function execl(const path: PChar; const arg: PChar): Longint; cdecl; varargs; external GLIBC_LIB name 'execl'; +function execvp(const afile: PChar; const argv: PPchar): Longint; cdecl; external GLIBC_LIB name 'execvp'; +function execlp(const afile: PChar; const arg: PChar): Longint; cdecl; varargs; external GLIBC_LIB name 'execlp'; + +function getpid: __pid_t; cdecl; external GLIBC_LIB name 'getpid'; +function getppid: __pid_t; cdecl; external GLIBC_LIB name 'getppid'; +function getpgrp: __pid_t; cdecl; external GLIBC_LIB name 'getpgrp'; + +procedure setpwent; cdecl; external GLIBC_LIB name 'setpwent'; +procedure endpwent; cdecl; external GLIBC_LIB name 'endpwent'; +function getpwent: PPasswd; cdecl; external GLIBC_LIB name 'getpwent'; +function fgetpwent(stream: PFILE): PPasswd; cdecl; external GLIBC_LIB name 'fgetpwent'; +function putpwent(const p: PPasswd; stream: PFILE): Longint; cdecl; external GLIBC_LIB name 'putpwent'; +function getpwuid(uid: __uid_t): PPasswd; cdecl; external GLIBC_LIB name 'getpwuid'; +function getpwnam(const name: PChar): PPasswd; cdecl; external GLIBC_LIB name 'getpwnam'; + +procedure setgrent; cdecl; external GLIBC_LIB name 'setgrent'; +procedure endgrent; cdecl; external GLIBC_LIB name 'endgrent'; +function getgrent:PGroup; cdecl; external GLIBC_LIB name 'getgrent'; +function fgetgrent(stream: PFILE): PGroup; cdecl; external GLIBC_LIB name 'fgetgrent'; +function putgrent(p: PGroup; stream: PFILE): Longint; cdecl; external GLIBC_LIB name 'putgrent'; +function getgrgid(gid: __gid_t): PGroup; cdecl; external GLIBC_LIB name 'getgrgid'; +function getgrnam(name: PChar): PGroup; cdecl; external GLIBC_LIB name 'getgrnam'; + +function __time(t: Ptime_t): time_t; cdecl; external GLIBC_LIB name 'time'; +function time(t: Ptime_t): time_t; cdecl; external GLIBC_LIB name 'time'; +function libc_time(t: Ptime_t): time_t; cdecl; external GLIBC_LIB name 'time'; +function mktime(timep: Ptm): time_t; cdecl; external GLIBC_LIB name 'mktime'; +function strftime(s: PChar; max: size_t; const format: PChar; tm: Ptm): size_t; cdecl; external GLIBC_LIB name 'strftime'; +function gmtime(timep: Ptime_t): Ptm; cdecl; external GLIBC_LIB name 'gmtime'; +function localtime(timep: Ptime_t): Ptm; cdecl; external GLIBC_LIB name 'localtime'; +function ctime(timep: Ptime_t): PChar; cdecl; external GLIBC_LIB name 'ctime'; +function usleep(usec: DWord): Longint; cdecl; external GLIBC_LIB name 'usleep'; + +function mktemp(template: PChar): PChar; cdecl; external GLIBC_LIB name 'mktemp'; +function mkstemp(template: PChar): Longint; cdecl; external GLIBC_LIB name 'mkstemp'; +function mkstemp64(template: PChar): Longint; cdecl; external GLIBC_LIB name 'mkstemp64'; +function mkdtemp(template: PChar): PChar; cdecl; external GLIBC_LIB name 'mkdtemp'; + +function fprintf(stream: PFILE; const format: PChar): Longint; cdecl; varargs; external GLIBC_LIB name 'fprintf'; +function printf(const format: PChar): Longint; cdecl; varargs; external GLIBC_LIB name 'printf'; +function sprintf(s: PChar; const format: PChar): Longint; varargs; cdecl; external GLIBC_LIB name 'sprintf'; +function snprintf(s: PChar; size: size_t; const format: PChar): Longint; varargs; cdecl; external GLIBC_LIB name 'snprintf'; + +function WEXITSTATUS(Status: longint): longint; +function WTERMSIG(Status: longint): longint; +function WSTOPSIG(Status: longint): longint; +function WIFEXITED(Status: longint): Boolean; +function WIFSIGNALED(Status: longint): Boolean; +function WIFSTOPPED(Status: longint): Boolean; +function WCOREDUMP(Status: longint): Boolean; +function W_EXITCODE(ReturnCode, Signal: longint): longint; +function W_STOPCODE(Signal: longint): longint; + +function gethostname(name: PChar; len: size_t): Longint; cdecl; external GLIBC_LIB name 'gethostname'; + +function sigqueue(pid: __pid_t; sig: Longint; val: sigval): Longint; cdecl; external GLIBC_LIB name 'sigqueue'; +function sigaction(sig: Longint; Action: PSigAction; OldAction: PSigAction): Integer; cdecl; external GLIBC_LIB name 'sigaction'; +function __system(const command: PChar): Longint; cdecl; external GLIBC_LIB name 'system'; +function system(const command: PChar): Longint; cdecl; external GLIBC_LIB name 'system'; +function libc_system(const command: PChar): Longint; cdecl; external GLIBC_LIB name 'system'; + +procedure perror(const s: PChar); cdecl; external GLIBC_LIB name 'perror'; +function popen(const command: PChar; const _type: PChar): PFILE; cdecl; external GLIBC_LIB name 'popen'; +function pclose(stream: PFILE): Longint; cdecl; external GLIBC_LIB name 'pclose'; +function pipe(pipedes: Plongint): Longint; cdecl; external GLIBC_LIB name 'pipe'; + +function fopen(const path: PChar; const mode: PChar): PFILE; cdecl; external GLIBC_LIB name 'fopen'; +function fopen64(const path: PChar; const mode: PChar): PFILE; cdecl; external GLIBC_LIB name 'fopen64'; +function fdopen(fd: Longint; mode: PChar): PFILE; cdecl; external GLIBC_LIB name 'fdopen'; +function fclose(fp: PFILE): Longint; cdecl; external GLIBC_LIB name 'fclose'; +function fflush(stream: PFILE): Longint; cdecl; external GLIBC_LIB name 'fflush'; +function fflush_unlocked(stream: PFILE): Longint; cdecl; external GLIBC_LIB name 'fflush_unlocked'; +function fread(ptr: Pointer; size: size_t; n: size_t; stream: PFILE): size_t; cdecl; external GLIBC_LIB name 'fread'; +function fwrite(const ptr: Pointer; size: size_t; n: size_t; stream: PFILE): size_t; cdecl; external GLIBC_LIB name 'fwrite'; +function fseek(stream: PFILE; off: Longint; whence: Longint): Longint; cdecl; external GLIBC_LIB name 'fseek'; +function ftell(stream:PFILE): Longint; cdecl; external GLIBC_LIB name 'ftell'; +procedure rewind(stream:PFILE); cdecl; external GLIBC_LIB name 'rewind'; + +function fseeko(stream: PFILE; offset: __off_t; whence: Longint): Longint; cdecl; external GLIBC_LIB name 'fseeko'; +function ftello(stream: PFILE): __off_t; cdecl; external GLIBC_LIB name 'ftello'; +function fgetpos(stream: PFILE; pos: Pfpos_t): Longint; cdecl; external GLIBC_LIB name 'fgetpos'; +function fsetpos(stream: PFILE; pos: Pfpos_t): Longint; cdecl; external GLIBC_LIB name 'fsetpos'; +function fseeko64(stream: PFILE; offset: __off64_t; whence: Longint): Longint; cdecl; external GLIBC_LIB name 'fseeko64'; +function ftello64(stream: PFILE): __off64_t; cdecl; external GLIBC_LIB name 'ftello64'; +function fgetpos64(stream: PFILE; pos: Pfpos64_t): Longint; cdecl; external GLIBC_LIB name 'fgetpos64'; +function fsetpos64(stream: PFILE; pos: Pfpos64_t): Longint; cdecl; external GLIBC_LIB name 'fsetpos64'; +function feof(stream: PFILE): Longint; cdecl; external GLIBC_LIB name 'feof'; +function ferror(stream: PFILE): Longint; cdecl; external GLIBC_LIB name 'ferror'; + +function fcntl(fd: Longint; cmd: Longint): Longint; cdecl; varargs; external GLIBC_LIB name 'fcntl'; +function open(const pathname: PChar; flags: Longint): Longint; cdecl; varargs; external GLIBC_LIB name 'open'; +function open64(const pathname: PChar; flags: Longint): Longint; cdecl; varargs; external GLIBC_LIB name 'open64'; +function creat(const pathname: PChar; mode: __mode_t): Longint; cdecl; external GLIBC_LIB name 'creat'; +function creat64(const pathname: PChar; mode: __mode_t): Longint; cdecl; external GLIBC_LIB name 'creat64'; + +function __read(Handle: Integer; var Buffer; Count: size_t): ssize_t; cdecl; external GLIBC_LIB name 'read'; +function libc_read(Handle: Integer; var Buffer; Count: size_t): ssize_t; cdecl; external GLIBC_LIB name 'read'; +function __write(Handle: Integer; const Buffer; Count: size_t): ssize_t; cdecl; external GLIBC_LIB name 'write'; +function libc_write(Handle: Integer; const Buffer; Count: size_t): ssize_t; cdecl; external GLIBC_LIB name 'write'; +function __close(Handle: Integer): Integer; cdecl; external GLIBC_LIB name 'close'; +function libc_close(Handle: Integer): Integer; cdecl; external GLIBC_LIB name 'close'; + +function getuid: __uid_t; cdecl; external GLIBC_LIB name 'getuid'; +function geteuid: __uid_t; cdecl; external GLIBC_LIB name 'geteuid'; +function getgid: __gid_t; cdecl; external GLIBC_LIB name 'getgid'; +function getegid: __gid_t; cdecl; external GLIBC_LIB name 'getegid'; + +function access(pathname: PChar; mode: Longint): Longint; cdecl; external GLIBC_LIB name 'access'; +function euidaccess(pathname: PChar; mode: Longint): Longint; cdecl; external GLIBC_LIB name 'euidaccess'; + + + + +implementation + +{$IFDEF KYLIX} +function glibc__xstat64(ver: integer; const afile: PChar; buf: Pstat64): longint; cdecl; external GLIBC_LIB name '__xstat64'; +function glibc__lxstat64(ver: integer; const path: PChar; buf: Pstat64): longint; cdecl; external GLIBC_LIB name '__lxstat64'; + +function stat64(const afile: PChar; buf: Pstat64): longint; +begin + Result := glibc__xstat64(_STAT_VER, afile, buf); +end; + +function lstat64(const path: PChar; buf: Pstat64): longint; +begin + Result := glibc__lxstat64(_STAT_VER, path, buf); +end; +{$ENDIF} + +function errno : error_t; +begin + Result := __errno_location()^; +end; + +function __S_ISTYPE(mode, mask : __mode_t) : boolean; +begin + Result := (mode and __S_IFMT) = mask; +end; + +function S_ISDIR(mode : __mode_t) : boolean; +begin + Result := __S_ISTYPE(mode, __S_IFDIR); +end; + +function S_ISCHR(mode : __mode_t) : boolean; +begin + Result := __S_ISTYPE(mode, __S_IFCHR); +end; + +function S_ISBLK(mode : __mode_t) : boolean; +begin + Result := __S_ISTYPE(mode, __S_IFBLK); +end; + +function S_ISREG(mode : __mode_t) : boolean; +begin + Result := __S_ISTYPE(mode, __S_IFREG); +end; + +function S_ISFIFO(mode : __mode_t) : boolean; +begin + Result := __S_ISTYPE(mode, __S_IFIFO); +end; + +function S_ISLNK(mode : __mode_t) : boolean; +begin + Result := __S_ISTYPE(mode, __S_IFLNK); +end; + +function S_ISSOCK(mode : __mode_t) : boolean; +begin + Result := __S_ISTYPE(mode, __S_IFSOCK); +end; + +Function WEXITSTATUS(Status: longint): longint; +begin + Result:=(Status and $FF00) shr 8; +end; + + +Function WTERMSIG(Status: longint): longint; +begin + Result:=(Status and $7F); +end; + + +Function WSTOPSIG(Status: longint): longint; +begin + Result:=WEXITSTATUS(Status); +end; + + +Function WIFEXITED(Status: longint): Boolean; +begin + Result:=(WTERMSIG(Status)=0); +end; + + +Function WIFSIGNALED(Status: longint): Boolean; +begin + Result:=(not WIFSTOPPED(Status)) and (not WIFEXITED(Status)); +end; + + +Function WIFSTOPPED(Status: longint): Boolean; +begin + Result:=((Status and $FF)=$7F); +end; + + +Function WCOREDUMP(Status: longint): Boolean; +begin + Result:=((Status and WCOREFLAG)<>0); +end; + + +Function W_EXITCODE(ReturnCode, Signal: longint): longint; +begin + Result:=(ReturnCode shl 8) or Signal; +end; + + +Function W_STOPCODE(Signal: longint): longint; +begin + Result:=(Signal shl 8) or $7F; +end; + +end. + @@ -245,7 +245,7 @@ var implementation -uses Libc, +uses ULibc, UCore, USelect, UNewDir, UDirDelete, UProgress, UCopyMove, UCoreUtils, ULocale, UChecksum, UChecksumDruid, USplitFile, UFileTypeSettings, UFileAssoc, UChmod, UChown, USymlink, @@ -2735,7 +2735,7 @@ begin if ConfQuickRenameSkipExt and (ListView.Columns[i - 1].FColumn^.editable_widget <> nil) then begin s := gtk_entry_get_text(PGtkEntry(ListView.Columns[i - 1].FColumn^.editable_widget)); if (s <> nil) and (g_utf8_strlen(s, -1) > 0) then begin - DebugMsg(['TFMain.DoQuickRename: s = "', s, '", g_utf8_strlen(s) = ', g_utf8_strlen(s, -1)]); +// DebugMsg(['TFMain.DoQuickRename: s = "', s, '", g_utf8_strlen(s) = ', g_utf8_strlen(s, -1)]); if AnsiPos('.', s) > 0 then gtk_editable_select_region(PGtkEditable(ListView.Columns[i - 1].FColumn^.editable_widget), 0, g_utf8_strlen(s, -1) - g_utf8_strlen(PChar(ExtractFileExt(s)), -1)); end; @@ -2902,7 +2902,7 @@ begin g_utf8_strncpy(g, PChar(Entry.Text), g_utf8_strlen(PChar(Entry.Text), -1) - 1); // DebugMsg(['TFMain.QuickFindSendKey: after delete: "', g, '", ansi = "', UTF8ToStr(g), '"']); Entry.Text := g; - Libc.free(g); + libc_free(g); end; NewText := Entry.Text; end else @@ -3533,9 +3533,9 @@ begin b := True; if Engine is TVFSEngine then b := HandleRunFromArchive(Path, Engine, Command, FileTypeDesc, False); // not a local engine, extract to local first if b then begin - Libc.__chdir(PChar(ExtractFilePath(Path))); + libc_chdir(PChar(ExtractFilePath(Path))); b := ExecuteProgram(QuoteStr(Path), ExtractFilePath(Path), AutodetectGUI, RunInTerminal, i); - Libc.__chdir(PChar('/')); + libc_chdir(PChar('/')); end else b := True; // Mask cancelled extraction from VFS end else begin if Engine is TVFSEngine then begin @@ -3556,9 +3556,9 @@ begin else s := Format('%s %s', [s, QuoteStr(Path)]); // DebugMsg(['execute: ', s, ' , ', Command, ' , ', QuoteStr(Path)]); if b then begin - Libc.__chdir(PChar(ExtractFilePath(Path))); + libc_chdir(PChar(ExtractFilePath(Path))); b := ExecuteProgram(s, ExtractFilePath(Path), AutodetectGUI, RunInTerminal, i); - Libc.__chdir(PChar('/')); + libc_chdir(PChar('/')); end else b := True; // Mask cancelled extraction from VFS end; if not b then Application.MessageBox(Format(LANGCannotExecuteSPleaseCheckTheConfiguration, [s]), [mbOK], mbError, mbNone, mbOK); @@ -3611,10 +3611,10 @@ begin ChangingDir(LeftLastFocused, ProcessPattern(Engine, UTF8ToStr(Copy(Orig, 4, Length(Orig) - 3)), Engine.Path, '', True)); end else begin while not (Engine is TLocalTreeEngine) do Engine := Engine.ParentEngine; - ChDir(Engine.Path); + libc_chdir(PChar(Engine.Path)); if not ExecuteProgram(UTF8ToStr(Orig), Engine.Path, ConfCmdLineTerminalBehaviour = 0 , ConfCmdLineTerminalBehaviour = 1, Error) then Application.MessageBox(LANGErrorExecutingCommand, [mbOK], mbError, mbNone, mbOK); - ChDir('/'); + libc_chdir('/'); end; end; CommandLineCombo.Entry.Text := ''; @@ -4348,9 +4348,9 @@ begin b := True; if Engine is TVFSEngine then b := HandleRunFromArchive(FileName, Engine, '', '', False); // not a local engine, extract to local first if b then begin - Libc.__chdir(PChar(ExtractFilePath(FileName))); + libc_chdir(PChar(ExtractFilePath(FileName))); b := ExecuteProgram(QuoteStr(FileName), ExtractFilePath(FileName), True, False, Error); - Libc.__chdir(PChar('/')); + libc_chdir(PChar('/')); end else b := True; // Mask cancelled extraction from VFS if not b then Application.MessageBox(LANGErrorExecutingCommand, [mbOK], mbError, mbNone, mbOK); end; @@ -4363,10 +4363,10 @@ begin if Pos('%s', s) > 0 then s := Format(s, ['''' + QuoteStr(FileName) + '''']) else s := Format('%s %s', [s, QuoteStr(FileName)]); if b then begin - Libc.__chdir(PChar(ExtractFilePath(FileName))); + libc_chdir(PChar(ExtractFilePath(FileName))); b := ExecuteProgram(s, ExtractFilePath(FileName), TAssocAction((Sender as TGTKMenuItem).Data).AutodetectGUI, TAssocAction((Sender as TGTKMenuItem).Data).RunInTerminal, Error); - Libc.__chdir(PChar('/')); + libc_chdir(PChar('/')); end else b := True; // Mask cancelled extraction from VFS if not b then Application.MessageBox(Format(LANGCannotExecuteSPleaseCheckTheConfiguration, [FileName]), [mbOK], mbError, mbNone, mbOK); end; @@ -5632,7 +5632,7 @@ begin memset(g, 0, Length(ALabel) + 4); g_utf8_strncpy(g, PChar(ALabel), ConfTabMaxLength); ALabel := g + '...'; - Libc.free(g); + libc_free(g); end; Notebook.SetTabCaption(PageIndex, ALabel); Notebook.SetTabTooltip(PageIndex, Tooltip); @@ -6023,9 +6023,9 @@ begin else AEngine := RightPanelEngine; while not (AEngine is TLocalTreeEngine) do AEngine := AEngine.ParentEngine; CurrentPath := AEngine.Path; - ChDir(CurrentPath); + libc_chdir(PChar(CurrentPath)); ExecuteProgram('bash', CurrentPath, False, True, Error); - ChDir('/'); + libc_chdir('/'); end; @@ -6305,7 +6305,7 @@ begin DebugMsg(['(II) HandleRunFromArchive: New path = ', APath]); - Libc.free(tmp); + libc_free(tmp); DebugMsg(['(II) HandleRunFromArchive: Copy OK, Result = ', Result]); end; diff --git a/UPreferences.pas b/UPreferences.pas index 9c73adc..6a799d5 100644 --- a/UPreferences.pas +++ b/UPreferences.pas @@ -23,7 +23,7 @@ interface uses glib2, gtk2, pango, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, - GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKMenus, Libc, + GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKMenus, ULibc, UCoreClasses, UGnome; type @@ -254,7 +254,7 @@ begin Table2.AddControlEx(1, 6, 1, 1, CmdLineBehaviourLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2); Table2.AddControlEx(2, 6, 2, 1, TerminalOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2); - FormatTime := Libc.__time(nil); + FormatTime := libc_time(nil); DateFormatLabel := TGTKLabel.Create(Self); DateFormatLabel.Caption := 'Date _format:'; DateFormatLabel.XAlign := 0; diff --git a/USearch.pas b/USearch.pas index 45c75f9..0156d59 100644 --- a/USearch.pas +++ b/USearch.pas @@ -104,7 +104,7 @@ var implementation -uses Math, UMain, ULocale, UCoreUtils, Libc, UCore, DateUtils, UViewer, UConfig, UVFSCore; +uses Math, UMain, ULocale, UCoreUtils, ULibc, UCore, DateUtils, UViewer, UConfig, UVFSCore; type TFileListItem = class CRC: LongWord; @@ -924,10 +924,10 @@ begin if Matches then begin GUIMutex.Acquire; FList.Add(LocalList[i]); - Libc.free(Data^.FDisplayName); + libc_free(Data^.FDisplayName); PDataItem(LocalList[i])^.FDisplayName := strdup(PChar(StartDir + FileName)); if Assigned(PDataItem(LocalList[i])^.LnkPointTo) then begin - Libc.free(PDataItem(LocalList[i])^.LnkPointTo); + libc_free(PDataItem(LocalList[i])^.LnkPointTo); PDataItem(LocalList[i])^.LnkPointTo := nil; end; if FEngine is TVFSEngine then PDataItem(LocalList[i])^.LnkPointTo := strdup(PChar((FEngine as TVFSEngine).SavePath)); @@ -968,7 +968,7 @@ begin end; end; - if not Matches then Libc.free(LocalList[i]); + if not Matches then libc_free(LocalList[i]); end; end; LocalList.Free; @@ -987,9 +987,9 @@ begin Result := False; try Error := 0; - Buffer := Libc.malloc(BlockSize); + Buffer := malloc(BlockSize); if Buffer = nil then Exit; - Libc.memset(Buffer, 0, BlockSize); + memset(Buffer, 0, BlockSize); fd := FEngine.OpenFile(FileName, omRead, Error); if (fd = nil) or (Error <> 0) then Exit; @@ -1005,7 +1005,7 @@ begin if Pos > Length(FStringFind) then begin Result := True; FEngine.CloseFile(fd); - Libc.free(Buffer); + libc_free(Buffer); Exit; end; end else Pos := 1; @@ -1015,7 +1015,7 @@ begin if CancelIt then Break; until Read < BlockSize; FEngine.CloseFile(fd); - Libc.free(Buffer); + libc_free(Buffer); except end; end; diff --git a/UViewer.pas b/UViewer.pas index d10b8a7..ae56d2c 100644 --- a/UViewer.pas +++ b/UViewer.pas @@ -65,7 +65,7 @@ var implementation -uses UCoreUtils, UCoreClasses, UConfig, DateUtils, Libc; +uses UCoreUtils, UCoreClasses, UConfig, DateUtils, ULibc; @@ -63,7 +63,7 @@ uses USearch in 'USearch.pas', UGlibThreads in 'UGlibThreads.pas', URunFromVFS in 'URunFromVFS.pas', - UGlibC_compat in 'UGlibC_compat.pas', + ULibc in 'ULibc.pas', USetPassword in 'USetPassword.pas', UTranslation_EN in 'translations/UTranslation_EN.pas', UTranslation_CZ in 'translations/UTranslation_CZ.pas', diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas index ded912a..5ca80d5 100644 --- a/vfs/UVFSCore.pas +++ b/vfs/UVFSCore.pas @@ -25,7 +25,7 @@ unit UVFSCore; interface -uses GTKForms, Libc, {$IFDEF KYLIX}UGlibC_compat,{$ENDIF} Classes, uVFSprototypes, UEngines, UCoreUtils; +uses GTKForms, ULibc, Classes, uVFSprototypes, UEngines, UCoreUtils; type @@ -295,11 +295,11 @@ begin ArchiveMode := False; BreakProcessingKind := 0; if @FSourcePlugin.FVFSAllocNeeded <> nil then begin - FGlobs := Libc.malloc(FSourcePlugin.FVFSAllocNeeded); - Libc.memset(FGlobs, 0, FSourcePlugin.FVFSAllocNeeded); + FGlobs := malloc(FSourcePlugin.FVFSAllocNeeded); + memset(FGlobs, 0, FSourcePlugin.FVFSAllocNeeded); end else begin - FGlobs := Libc.malloc(SizeOf(FGlobs)); - Libc.memset(FGlobs, 0, SizeOf(FGlobs)); + FGlobs := malloc(SizeOf(FGlobs)); + memset(FGlobs, 0, SizeOf(FGlobs)); end; {$IFNDEF KYLIX} @@ -342,7 +342,7 @@ destructor TVFSEngine.Destroy; begin try if @FSourcePlugin.FVFSDestroy <> nil then FSourcePlugin.FVFSDestroy(FGlobs); - libc.free(FGlobs); + libc_free(FGlobs); except on E: Exception do DebugMsg(['*** TVFSEngine.Destroy() -Exception: ', E.Message]); end; @@ -357,8 +357,8 @@ begin Result := 0; try if @FSourcePlugin.FVFSListFirst = nil then Exit; - P := Libc.malloc(SizeOf(TVFSItem)); - Libc.memset(P, 0, SizeOf(TVFSItem)); + P := malloc(SizeOf(TVFSItem)); + memset(P, 0, SizeOf(TVFSItem)); // DebugMsg(['Item = ', Int64(P)]); // DebugMsg(['FVFSListFirst']); Res := FSourcePlugin.FVFSListFirst(FGlobs, PChar(APath), P); @@ -366,7 +366,7 @@ begin FSourcePlugin.FVFSListClose(FGlobs); if Res = cVFS_Not_More_Files then Result := 0 else Result := Res; - Libc.free(P); + libc_free(P); Exit; end; @@ -374,8 +374,8 @@ begin // DebugMsg(['begin--']); if AddDotFiles or (not ((Length(P^.sFileName) > 1) and (P^.sFileName[0] = '.') and (P^.sFileName[1] <> '.'))) then begin // DebugMsg(['Checkpoint 1']); - Item := Libc.malloc(SizeOf(TDataItem)); - Libc.memset(Item, 0, SizeOf(TDataItem)); + Item := malloc(SizeOf(TDataItem)); + memset(Item, 0, SizeOf(TDataItem)); // DebugMsg(['Checkpoint 2']); for i := 0 to Length(Item^.ColumnData) - 1 do Item^.ColumnData[i] := nil; // DebugMsg(['Checkpoint 3']); @@ -418,10 +418,10 @@ begin DebugMsg(['^^VFS (EE): GetListing: Item-Exception: ', E.Message]); end; end; // of if AddDotFiles - Libc.free(P); // Not needed - just zero-erase the memory + libc_free(P); // Not needed - just zero-erase the memory // DebugMsg(['Checkpoint 13']); - P := Libc.malloc(SizeOf(TVFSItem)); - Libc.memset(P, 0, SizeOf(TVFSItem)); + P := malloc(SizeOf(TVFSItem)); + memset(P, 0, SizeOf(TVFSItem)); // DebugMsg(['Item = ', Int64(P)]); // DebugMsg(['Checkpoint 14']); // DebugMsg(['FVFSListNext --begin']); @@ -431,7 +431,7 @@ begin until (Res <> cVFS_OK) or (BreakProcessingKind = 2); if BreakProcessingKind <> 0 then DebugMsg(['^^VFS (WW): GetListing: stopped by BreakProcessing']); - Libc.free(P); + libc_free(P); FSourcePlugin.FVFSListClose(FGlobs); if Res <> cVFS_Not_More_Files then Result := Res; except @@ -449,7 +449,7 @@ end; function TVFSEngine.ExplicitChDir(const NewPath: string): integer; begin - Result := __chdir(PChar(NewPath)); + Result := libc_chdir(PChar(NewPath)); if Result <> 0 then Result := errno; end; @@ -546,11 +546,11 @@ begin if @FSourcePlugin.FVFSFileExists <> nil then begin Result := FSourcePlugin.FVFSFileExists(FGlobs, PChar(FileName), Use_lstat); if Result and (@FSourcePlugin.FVFSFileInfo <> nil) then begin - P := Libc.malloc(SizeOf(TVFSItem)); - Libc.memset(P, 0, SizeOf(TVFSItem)); + P := malloc(SizeOf(TVFSItem)); + memset(P, 0, SizeOf(TVFSItem)); Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(FileName), P); if (Res <> cVFS_OK) or (P = nil) or (TVFSItemType(P^.ItemType) <> vDirectory) then Result := False; - Libc.free(P); + libc_free(P); end; end else Result := False; end; @@ -562,8 +562,8 @@ var P: PVFSItem; begin Result := nil; if @FSourcePlugin.FVFSFileInfo = nil then Exit; - P := Libc.malloc(SizeOf(TVFSItem)); - Libc.memset(P, 0, SizeOf(TVFSItem)); + P := malloc(SizeOf(TVFSItem)); + memset(P, 0, SizeOf(TVFSItem)); Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(APath), P); if Res <> cVFS_OK then begin @@ -572,8 +572,8 @@ begin end; try - Item := Libc.malloc(SizeOf(TDataItemSL)); - Libc.memset(Item, 0, SizeOf(TDataItemSL)); + Item := malloc(SizeOf(TDataItemSL)); + memset(Item, 0, SizeOf(TDataItemSL)); with Item^ do begin FName := strdup(P^.sFileName); FDisplayName := StrToUTF8(P^.sFileName); @@ -594,7 +594,7 @@ begin UID := P^.iUID; GID := P^.iGID; Size := P^.iSize; - Libc.free(P); + libc_free(P); end; Result := Item; except @@ -630,11 +630,11 @@ var Item: PDataItemSL; procedure AddEntry(FPath: string; AddCurrDirStage, AStage1: boolean); begin - Item := Libc.malloc(SizeOf(TDataItemSL)); - Libc.memset(Item, 0, SizeOf(TDataItemSL)); + Item := malloc(SizeOf(TDataItemSL)); + memset(Item, 0, SizeOf(TDataItemSL)); with Item^ do begin -// AName := Libc.malloc(Length(FPath) + 1); -// Libc.memset(AName, 0, Length(FPath) + 1); +// AName := malloc(Length(FPath) + 1); +// memset(AName, 0, Length(FPath) + 1); FName := strdup(PChar(FPath)); FDisplayName := StrToUTF8(PChar(FPath)); if P^.sLinkTo <> nil then LnkPointTo := strdup(P^.sLinkTo) @@ -654,9 +654,7 @@ var Item: PDataItemSL; UID := P^.iUID; GID := P^.iGID; Size := P^.iSize; - {$WARNINGS OFF} Level := ALevel + Ord(not AddCurrDirStage); - {$WARNINGS ON} end; if AddCurrDirStage then List.Add(Item) else FilesList.Add(Item); @@ -668,12 +666,12 @@ begin LocalList := TStringList.Create; try try - P := Libc.malloc(SizeOf(TVFSItem)); - Libc.memset(P, 0, SizeOf(TVFSItem)); + P := malloc(SizeOf(TVFSItem)); + memset(P, 0, SizeOf(TVFSItem)); Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(APath), P); if Res <> cVFS_OK then DebugMsg(['*** FillDirFiles - VFSFileInfo(', APath, ') failed. Code = ', Res]); AddEntry(APath, True, True); - Libc.free(P); + libc_free(P); APath := IncludeTrailingPathDelimiter(APath); if @FSourcePlugin.FVFSChangeDir <> nil then Res := FSourcePlugin.FVFSChangeDir(FGlobs, PChar(APath)) @@ -681,12 +679,12 @@ begin if Res <> 0 then Exit; if @FSourcePlugin.FVFSListFirst = nil then Exit; - P := Libc.malloc(SizeOf(TVFSItem)); - Libc.memset(P, 0, SizeOf(TVFSItem)); + P := malloc(SizeOf(TVFSItem)); + memset(P, 0, SizeOf(TVFSItem)); Res := FSourcePlugin.FVFSListFirst(FGlobs, PChar(APath), P); if Res <> cVFS_OK then begin FSourcePlugin.FVFSListClose(FGlobs); - Libc.free(P); + libc_free(P); Exit; end; @@ -694,13 +692,13 @@ begin if TVFSItemType(P^.ItemType) = vDirectory then LocalList.Add(APath + String(P^.sFileName)) else AddEntry(APath + String(P^.sFileName), False, True); - Libc.free(P); - P := Libc.malloc(SizeOf(TVFSItem)); - Libc.memset(P, 0, SizeOf(TVFSItem)); + libc_free(P); + P := malloc(SizeOf(TVFSItem)); + memset(P, 0, SizeOf(TVFSItem)); Res := FSourcePlugin.FVFSListNext(FGlobs, PChar(GetPath), P); until (Res <> cVFS_OK); - Libc.free(P); + libc_free(P); FSourcePlugin.FVFSListClose(FGlobs); {$WARNINGS OFF} @@ -716,12 +714,12 @@ begin on E: Exception do DebugMsg(['*** TVFSEngine.FillDirFiles(APath=', APath, ', Level=', ALevel, ') -Exception: ', E.Message]); end; finally - P := Libc.malloc(SizeOf(TVFSItem)); - Libc.memset(P, 0, SizeOf(TVFSItem)); + P := malloc(SizeOf(TVFSItem)); + memset(P, 0, SizeOf(TVFSItem)); Res := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(APath), P); if Res <> cVFS_OK then DebugMsg(['*** FillDirFiles - VFSFileInfo(', APath, ') failed. Code = ', Res]); AddEntry(APath, True, False); - Libc.free(P); + libc_free(P); LocalList.Free; FilesList.Free; @@ -959,7 +957,7 @@ end; procedure QueryModules(APath: string); -var Handle: PDirectoryStream; +var Handle: PDIR; DirEnt: PDirent64; s: string; PluginItem: TVFSPlugin; @@ -979,7 +977,7 @@ begin if APath[1] <> '/' then begin s := ExtractFilePath(BinaryPath); DebugMsg(['----> Changing dir to ', s]); - i := __chdir(PChar(s)); + i := libc_chdir(PChar(s)); if i <> 0 then DebugMsg(['Something went wrong during chdir: ', string(strerror(errno))]); s := get_current_dir_name; DebugMsg([' [II] Changed dir to ', s]); @@ -988,7 +986,7 @@ begin // Change to the required directory s := APath; DebugMsg(['----> Changing dir to ', s]); - i := __chdir(PChar(s)); + i := libc_chdir(PChar(s)); if i <> 0 then begin DebugMsg(['Something went wrong during chdir: ', string(strerror(errno))]); Exit; |
