sysutilh.inc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Florian Klaempfl
  5. member of the Free Pascal development team
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  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. { Read date & Time function declarations }
  13. (* This must be placed before other functions, because TDateTime from DosCalls
  14. would be used under OS/2 instead of that one from datih.inc otherwise. *)
  15. {$i osutilsh.inc}
  16. {$i datih.inc}
  17. { Read String Handling functions declaration }
  18. {$i sysstrh.inc}
  19. type
  20. { some helpful data types }
  21. tprocedure = procedure;
  22. tfilename = string;
  23. tsyscharset = set of char;
  24. tintegerset = set of 0..sizeof(integer)*8-1;
  25. longrec = packed record
  26. lo,hi : word;
  27. end;
  28. wordrec = packed record
  29. lo,hi : byte;
  30. end;
  31. TMethod = packed record
  32. Code, Data: Pointer;
  33. end;
  34. { exceptions }
  35. Exception = class(TObject)
  36. private
  37. fmessage : string;
  38. fhelpcontext : longint;
  39. public
  40. constructor Create(const msg : string);
  41. constructor CreateFmt(const msg : string; const args : array of const);
  42. constructor CreateRes(ResString: PString);
  43. constructor CreateResFmt(ResString: PString; const Args: array of const);
  44. constructor CreateHelp(const Msg: string; AHelpContext: Integer);
  45. constructor CreateFmtHelp(const Msg: string; const Args: array of const;
  46. AHelpContext: Integer);
  47. constructor CreateResHelp(ResString: PString; AHelpContext: Integer);
  48. constructor CreateResFmtHelp(ResString: PString; const Args: array of const;
  49. AHelpContext: Integer);
  50. { !!!! }
  51. property helpcontext : longint read fhelpcontext write fhelpcontext;
  52. property message : string read fmessage write fmessage;
  53. end;
  54. ExceptClass = class of Exception;
  55. { integer math exceptions }
  56. EInterror = Class(Exception);
  57. EDivByZero = Class(EIntError);
  58. ERangeError = Class(EIntError);
  59. EIntOverflow = Class(EIntError);
  60. { General math errors }
  61. EMathError = Class(Exception);
  62. EInvalidOp = Class(EMathError);
  63. EZeroDivide = Class(EMathError);
  64. EOverflow = Class(EMathError);
  65. EUnderflow = Class(EMathError);
  66. { Run-time and I/O Errors }
  67. EInOutError = class(Exception)
  68. public
  69. ErrorCode : Longint;
  70. end;
  71. EHeapMemoryError = class(Exception)
  72. protected
  73. AllowFree : boolean;
  74. procedure FreeInstance;override;
  75. end;
  76. EInvalidPointer = Class(EHeapMemoryError);
  77. EOutOfMemory = Class(EHeapMemoryError);
  78. EAccessViolation = Class(Exception);
  79. EInvalidCast = Class(Exception);
  80. { String conversion errors }
  81. EConvertError = class(Exception);
  82. { Other errors }
  83. EAbort = Class(Exception);
  84. EAbstractError = Class(Exception);
  85. EAssertionFailed = Class(Exception);
  86. { Exception handling routines }
  87. function ExceptObject: TObject;
  88. function ExceptAddr: Pointer;
  89. function ExceptionErrorMessage(ExceptObject: TObject; ExceptAddr: Pointer;
  90. Buffer: PChar; Size: Integer): Integer;
  91. procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);
  92. procedure Abort;
  93. procedure OutOfMemoryError;
  94. procedure Beep;
  95. function SysErrorMessage(ErrorCode: Integer): String;
  96. Var
  97. OnShowException : Procedure (Msg : ShortString);
  98. { FileRec/TextRec }
  99. {$i filerec.inc}
  100. {$i textrec.inc}
  101. Type
  102. TFileRec=FileRec;
  103. TTextRec=TextRec;
  104. { Read internationalization settings }
  105. {$i sysinth.inc}
  106. { Read pchar handling functions declration }
  107. {$i syspchh.inc}
  108. { Read filename handling functions declaration }
  109. {$i finah.inc}
  110. { Read other file handling function declarations }
  111. {$i filutilh.inc}
  112. { Read disk function declarations }
  113. {$i diskh.inc}
  114. {
  115. $Log$
  116. Revision 1.9 2001-06-03 15:18:01 peter
  117. * eoutofmemory and einvalidpointer fix
  118. Revision 1.8 2001/02/20 22:14:19 peter
  119. * merged getenvironmentvariable
  120. Revision 1.7 2001/01/18 22:09:09 michael
  121. + Merged fixes from fixbranch - file modes
  122. Revision 1.6 2000/12/07 09:15:18 florian
  123. + tintegerset added
  124. Revision 1.5 2000/09/24 21:55:07 peter
  125. * ttextrec,tfilerec added (merged)
  126. Revision 1.4 2000/08/30 18:29:34 hajny
  127. * OS/2 fix - datih.inc moved to the beginning
  128. Revision 1.3 2000/08/29 17:56:32 michael
  129. Merged syserrormsg fix
  130. Revision 1.2 2000/08/20 15:46:46 peter
  131. * sysutils.pp moved to target and merged with disk.inc, filutil.inc
  132. Revision 1.1.2.2 2000/08/22 19:21:48 michael
  133. + Implemented syserrormessage. Made dummies for go32v2 and OS/2
  134. * Changed linux/errors.pp so it uses pchars for storage.
  135. Revision 1.1.2.1 2000/08/20 15:07:36 peter
  136. * sysutils.pp moved into target specific directory and merged
  137. disk.inc and filutil.inc in it
  138. }