summaryrefslogtreecommitdiff
path: root/rtl/unix/errors.pp
blob: 2eef7eb0966350732e170929da3e3974cee04a52 (plain)
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
{
    This file is part of the Free Pascal run time library.
    Copyright (c) 1999-2000 by the Free Pascal development team.

    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.

    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.

 **********************************************************************}

Unit errors;

Interface

uses strings,unixtype;

{$i errnostr.inc} // BSD or Linux ones

Function  StrError(err:cint):string;
Procedure PError(const s:string; Errno : cint);

Implementation

Function StrError(err:cint):string;
var s : string[12];
begin
  if (err<0) or (err>=sys_errn) then
   begin
     str(err,s);
     StrError:='Unknown Error ('+s+')';
   end
  else
   StrError:=StrPas(Sys_ErrList[err]);
end;


procedure PError(const s:string; Errno : cint);
begin
  WriteLn(stderr,s,': ',StrError(ErrNo));
end;

end.