2
0

errors.pp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY;without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. {$IFNDEF FPC_DOTTEDUNITS}
  11. Unit errors;
  12. {$ENDIF FPC_DOTTEDUNITS}
  13. Interface
  14. {$IFDEF FPC_DOTTEDUNITS}
  15. uses UnixApi.Types;
  16. {$ELSE FPC_DOTTEDUNITS}
  17. uses unixtype;
  18. {$ENDIF FPC_DOTTEDUNITS}
  19. {$i errnostr.inc} // BSD or Linux ones
  20. Function StrError(err:cint):string;
  21. Procedure PError(const s:string; Errno : cint);
  22. Implementation
  23. Function StrError(err:cint):string;
  24. var s : string[12];
  25. begin
  26. if (err<0) or (err>=sys_errn) then
  27. begin
  28. str(err,s);
  29. StrError:='Unknown Error ('+s+')';
  30. end
  31. else
  32. StrError:=StrPas(Sys_ErrList[err]);
  33. end;
  34. procedure PError(const s:string; Errno : cint);
  35. begin
  36. WriteLn(stderr,s,': ',StrError(ErrNo));
  37. end;
  38. end.