diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-06-07 20:34:49 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-06-07 20:34:49 +0200 |
| commit | ecde167da74c86bc047aaf84c5e548cf65a5da98 (patch) | |
| tree | a015dfda84f28a65811e3aa0d369f8f211ec8c60 /UGlibC_compat.pas | |
| download | tuxcmd-ecde167da74c86bc047aaf84c5e548cf65a5da98.tar.xz | |
Initial commitv0.6.36release-0.6.36-dev
Diffstat (limited to 'UGlibC_compat.pas')
| -rw-r--r-- | UGlibC_compat.pas | 256 |
1 files changed, 256 insertions, 0 deletions
diff --git a/UGlibC_compat.pas b/UGlibC_compat.pas new file mode 100644 index 0000000..342ab2d --- /dev/null +++ b/UGlibC_compat.pas @@ -0,0 +1,256 @@ +(* + 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 + 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; + +{$IFDEF KYLIX} + QWORD = Int64; +{$ENDIF} + + + + +{$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_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. + |
