1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
|
(*
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
{$PACKRECORDS C}
const GLIBC_LIB = 'libc.so.6';
DL_LIB = 'libdl.so.2';
type
cUShort = Word;
cInt = LongInt;
cuInt = LongWord;
cLongLong = Int64;
cuLongLong = QWord;
cuChar = Byte;
{$IFDEF CPU64}
cLong = Int64;
cuLong = QWord;
{$ELSE}
cLong = Longint;
cuLong = Cardinal;
{$ENDIF}
{$IFDEF CPU64}
size_t = QWORD;
ssize_t = Int64;
clock_t = QWORD;
{$ELSE}
size_t = Cardinal;
ssize_t = LongInt;
clock_t = Cardinal;
{$ENDIF}
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;
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 = packed record
d_ino : QWORD;
d_off : Int64;
d_reclen : word;
d_type : byte;
d_name : array[0..255] of char;
end;
Pstat64 = ^Tstat64;
Tstat64 = record
{$IFNDEF CPU64}
{$IFNDEF CPUPOWERPC} // i386
st_dev: cuLongLong;
__pad0_: array[0..3] of cuChar;
__st_ino: cuLong;
st_mode: cuInt;
st_nlink: cuInt;
st_uid: cuLong;
st_gid: cuLong;
st_rdev: cuLongLong;
__pad3_: array[0..3] of cuChar;
st_size: cLongLong;
st_blksize: cuLong;
st_blocks: cuLongLong; //* Number 512-byte blocks allocated. */
st_atime: cuLong;
st_atime_nsec: cuLong;
st_mtime: cuLong;
st_mtime_nsec: cuInt;
st_ctime: cuLong;
st_ctime_nsec: cuLong;
st_ino: cuLongLong
{$ELSE} // PPC32
st_dev : cULongLong;
st_ino : cULongLong;
st_mode : cUInt;
st_nlink : cUInt;
st_uid : cUInt;
st_gid : cUInt;
st_rdev : cULongLong;
__pad2 : cUShort;
st_size : cLongLong;
st_blksize : cInt;
st_blocks : cULongLong;
st_atime,
st_atime_nsec,
st_mtime,
st_mtime_nsec,
st_ctime,
st_ctime_nsec,
__unused4,
__unused5 : cULong;
{$ENDIF}
{$ELSE}
{$IFNDEF CPUPOWERPC} // x86_64
st_dev: cuLong;
st_ino: cuLong;
st_nlink: cuLong;
st_mode: cuInt;
st_uid: cuInt;
st_gid: cuInt;
__pad1: cuInt;
st_rdev: cuLong;
st_size: cLong;
st_blksize: cLong;
st_blocks: cLong; //* Number 512-byte blocks allocated. */
st_atime: cuLong;
st_atime_nsec: cuLong;
st_mtime: cuLong;
st_mtime_nsec: cuLong;
st_ctime: cuLong;
st_ctime_nsec: cuLong;
__unused2: array[0..2] of cLong;
{$ELSE} // PPC64
st_dev : cuLong;
st_ino : cuLong; { wrongly defined in RTL? }
st_nlink : cuLong; { wrongly defined in RTL? }
st_mode : cuInt;
st_uid : cuInt;
st_gid : cuInt;
st_rdev : cULong;
st_size : cLong;
st_blksize : cULong;
st_blocks : cULong; { Number 512-byte blocks allocated. }
st_atime : cULong;
st_atime_nsec : cULong;
st_mtime : cULong;
st_mtime_nsec : cULong;
st_ctime : cULong;
st_ctime_nsec : cULong;
__unused : array[0..2] of cULong;
{$ENDIF}
{$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 = record
actime : time_t;
modtime : time_t;
end;
Pmntent = ^Tmntent;
Tmntent = record
mnt_fsname : PChar;
mnt_dir : PChar;
mnt_type : PChar;
mnt_opts : PChar;
mnt_freq : Longint;
mnt_passno : Longint;
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;
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
RTLD_LAZY = $00001;
RTLD_NOW = $00002;
RTLD_BINDING_MASK = $3;
RTLD_NOLOAD = $00004;
RTLD_GLOBAL = $00100;
RTLD_LOCAL = 0;
RTLD_NODELETE = $01000;
const
_PATH_MNTTAB = '/etc/fstab';
_PATH_MOUNTED = '/etc/mtab';
const
R_OK = 4;
W_OK = 2;
X_OK = 1;
F_OK = 0;
const
SEEK_SET = 0;
SEEK_CUR = 1;
SEEK_END = 2;
const
O_RDONLY = 0;
O_WRONLY = 1;
O_RDWR = 2;
O_CREAT = $40;
O_EXCL = $80;
O_NOCTTY = $100;
O_TRUNC = $200;
O_APPEND = $400;
O_NONBLOCK = $800;
O_NDELAY = O_NONBLOCK;
O_SYNC = $1000;
O_DIRECT = $4000;
O_DIRECTORY = $10000;
O_NOFOLLOW = $20000;
O_CLOEXEC = $80000;
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';
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 libc_malloc(size: size_t): Pointer; cdecl; external GLIBC_LIB name 'malloc';
function malloc(size: size_t): Pointer; cdecl; external GLIBC_LIB name 'malloc';
procedure free(ptr: Pointer); cdecl; external GLIBC_LIB name 'free';
procedure libc_free(ptr: Pointer); cdecl; external GLIBC_LIB name 'free';
function memcpy(dest: Pointer; src: Pointer; n: size_t): Pointer; cdecl; external GLIBC_LIB name 'memcpy';
function memset(s: Pointer; c: Longint; n: size_t): Pointer; cdecl; external GLIBC_LIB name 'memset';
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 __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 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 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 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 localtime(timep: Ptime_t): Ptm; cdecl; external GLIBC_LIB name 'localtime';
function ctime(timep: Ptime_t): PChar; cdecl; external GLIBC_LIB name 'ctime';
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 open(const pathname: PChar; flags: Longint; mode: Longint): Longint; cdecl; varargs; external GLIBC_LIB name 'open';
function open64(const pathname: PChar; flags: Longint; mode: Longint): Longint; cdecl; varargs; external GLIBC_LIB name 'open64';
function lseek(fd: longint; offset: __off_t; whence: longint):__off_t; cdecl; external GLIBC_LIB name 'lseek';
function lseek64(fd: longint; offset: __off64_t; whence: longint):__off64_t; cdecl; external GLIBC_LIB name 'lseek64';
function __read(Handle: Integer; Buffer: Pointer; Count: size_t): ssize_t; cdecl; external GLIBC_LIB name 'read';
function libc_read(Handle: Integer; Buffer: Pointer; Count: size_t): ssize_t; cdecl; external GLIBC_LIB name 'read';
function __write(Handle: Integer; Buffer: Pointer; Count: size_t): ssize_t; cdecl; external GLIBC_LIB name 'write';
function libc_write(Handle: Integer; Buffer: Pointer; 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';
implementation
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;
end.
|