1 { 2 This unit contains all access functions to libc (unix like OS like 3 Linux, Mac OS X, BSD), which are needed by the IDE, but are not provided 4 by FPC units SysUtils, Unix and BaseUnix. 5 6 Before adding stuff here always check if fpc units Unix or BaseUnix already 7 contains corresponding functions. 8 Always use types from the ctypes unit. 9 } 10 unit IDEMiniLibC; 11 {$IFDEF linux} {$DEFINE DBG_ENABLE_TERMINAL} {$ENDIF} 12 13 {$mode objfpc}{$H+} 14 15 {$packrecords c} 16 17 interface 18 19 uses 20 ctypes 21 {$IFDEF DBG_ENABLE_TERMINAL} 22 , BaseUnix 23 {$ENDIF} 24 //,libc 25 ; 26 27 const 28 clib = 'c'; 29 InvalHandle = -1; 30 ICANON = $0000002; 31 ECHO = $0000008; 32 VMIN = 6; 33 VTIME = 5; 34 TCSANOW = 0; 35 F_DUPFD = 0; 36 F_GETFD = 1; 37 F_SETFD = 2; 38 F_GETFL = 3; 39 F_SETFL = 4; 40 {$IFDEF DBG_ENABLE_TERMINAL} 41 O_NONBLOCK = BaseUnix.O_NONBLOCK; 42 {$ENDIF} 43 EINTR = 4; 44 NCCS = 32; 45 46 type 47 error_t = cint; 48 tcflag_t = cuint; 49 cc_t = cchar; 50 speed_t = cuint; 51 size_t = cuint; 52 ssize_t = cint; 53 54 Ptermios = ^termios; 55 termios = record 56 c_iflag : tcflag_t; 57 c_oflag : tcflag_t; 58 c_cflag : tcflag_t; 59 c_lflag : tcflag_t; 60 c_line : cc_t; 61 c_cc : array[0..(NCCS)-1] of cc_t; 62 c_ispeed : speed_t; 63 c_ospeed : speed_t; 64 end; 65 tcgetattrnull66function tcgetattr(__fd:cint; __termios_p: Ptermios):cint;cdecl;external clib name 'tcgetattr'; tcsetattrnull67function tcsetattr(__fd:cint; __optional_actions:cint; __termios_p: Ptermios):cint;cdecl;external clib name 'tcsetattr'; __readnull68function __read(Handle: cint; var Buffer; Count: size_t): ssize_t; cdecl;external clib name 'read'; __writenull69function __write(Handle: cint; const Buffer; Count: size_t): ssize_t; cdecl;external clib name 'write'; __closenull70function __close(Handle: cint): cint; cdecl;external clib name 'close'; getptnull71function getpt:cint;cdecl;external clib name 'getpt'; grantptnull72function grantpt(__fd:cint):cint;cdecl;external clib name 'grantpt'; unlockptnull73function unlockpt(__fd:cint):cint;cdecl;external clib name 'unlockpt'; ptsname_rnull74function ptsname_r(__fd:cint; __buf:Pchar; __buflen:size_t):cint;cdecl;external clib name 'ptsname_r'; fcntlnull75function fcntl(Handle: cint; Command: cint; Arg: clong): cint; cdecl;external clib name 'fcntl'; 76 77 implementation 78 79 end. 80 81