File: ideminilibc.pas

package info (click to toggle)
lazarus 2.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 214,460 kB
  • sloc: pascal: 1,862,622; xml: 265,709; cpp: 56,595; sh: 3,008; java: 609; makefile: 535; perl: 297; sql: 222; ansic: 137
file content (80 lines) | stat: -rw-r--r-- 2,142 bytes parent folder | download | duplicates (3)
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
{
  This unit contains all access functions to libc (unix like OS like
  Linux, Mac OS X, BSD), which are needed by the IDE, but are not provided
  by FPC units SysUtils, Unix and BaseUnix.

  Before adding stuff here always check if fpc units Unix or BaseUnix already
  contains corresponding functions.
  Always use types from the ctypes unit.
}
unit IDEMiniLibC;
{$IFDEF linux} {$DEFINE DBG_ENABLE_TERMINAL} {$ENDIF}

{$mode objfpc}{$H+}

{$packrecords c}

interface

uses
  ctypes
{$IFDEF DBG_ENABLE_TERMINAL}
  , BaseUnix
{$ENDIF}
  //,libc
  ;

const
  clib = 'c';
  InvalHandle = -1;
  ICANON    = $0000002;
  ECHO      = $0000008;
  VMIN = 6;
  VTIME = 5;
  TCSANOW = 0;
  F_DUPFD   = 0;
  F_GETFD   = 1;
  F_SETFD   = 2;
  F_GETFL   = 3;
  F_SETFL   = 4;
{$IFDEF DBG_ENABLE_TERMINAL}
  O_NONBLOCK = BaseUnix.O_NONBLOCK;
{$ENDIF}
  EINTR = 4;
  NCCS = 32;

type
  error_t = cint;
  tcflag_t = cuint;
  cc_t = cchar;
  speed_t = cuint;
  size_t = cuint;
  ssize_t = cint;

  Ptermios = ^termios;
  termios = record
    c_iflag : tcflag_t;
    c_oflag : tcflag_t;
    c_cflag : tcflag_t;
    c_lflag : tcflag_t;
    c_line : cc_t;
    c_cc : array[0..(NCCS)-1] of cc_t;
    c_ispeed : speed_t;
    c_ospeed : speed_t;
  end;

function tcgetattr(__fd:cint; __termios_p: Ptermios):cint;cdecl;external clib name 'tcgetattr';
function tcsetattr(__fd:cint; __optional_actions:cint; __termios_p: Ptermios):cint;cdecl;external clib name 'tcsetattr';
function __read(Handle: cint; var Buffer; Count: size_t): ssize_t; cdecl;external clib name 'read';
function __write(Handle: cint; const Buffer; Count: size_t): ssize_t; cdecl;external clib name 'write';
function __close(Handle: cint): cint; cdecl;external clib name 'close';
function getpt:cint;cdecl;external clib name 'getpt';
function grantpt(__fd:cint):cint;cdecl;external clib name 'grantpt';
function unlockpt(__fd:cint):cint;cdecl;external clib name 'unlockpt';
function ptsname_r(__fd:cint; __buf:Pchar; __buflen:size_t):cint;cdecl;external clib name 'ptsname_r';
function fcntl(Handle: cint; Command: cint; Arg: clong): cint; cdecl;external clib name 'fcntl';

implementation

end.