1{
2    This file is part of the Free Pascal run time library.
3    Copyright (c) 1999-2000 by the Free Pascal development team.
4
5    See the file COPYING.FPC, included in this distribution,
6    for details about the copyright.
7
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY;without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
12 **********************************************************************}
13
14Unit errors;
15
16Interface
17
18uses unixtype;
19
20{$i errnostr.inc} // BSD or Linux ones
21
22Function  StrError(err:cint):string;
23Procedure PError(const s:string; Errno : cint);
24
25Implementation
26
27Function StrError(err:cint):string;
28var s : string[12];
29begin
30  if (err<0) or (err>=sys_errn) then
31   begin
32     str(err,s);
33     StrError:='Unknown Error ('+s+')';
34   end
35  else
36   StrError:=StrPas(Sys_ErrList[err]);
37end;
38
39
40procedure PError(const s:string; Errno : cint);
41begin
42  WriteLn(stderr,s,': ',StrError(ErrNo));
43end;
44
45end.
46