sysutilh.inc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. EVariantError = Class(Exception);
  81. { String conversion errors }
  82. EConvertError = class(Exception);
  83. { Other errors }
  84. EAbort = Class(Exception);
  85. EAbstractError = Class(Exception);
  86. EAssertionFailed = Class(Exception);
  87. { Exception handling routines }
  88. function ExceptObject: TObject;
  89. function ExceptAddr: Pointer;
  90. function ExceptionErrorMessage(ExceptObject: TObject; ExceptAddr: Pointer;
  91. Buffer: PChar; Size: Integer): Integer;
  92. procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);
  93. procedure Abort;
  94. procedure OutOfMemoryError;
  95. procedure Beep;
  96. function SysErrorMessage(ErrorCode: Integer): String;
  97. Var
  98. OnShowException : Procedure (Msg : ShortString);
  99. { FileRec/TextRec }
  100. {$i filerec.inc}
  101. {$i textrec.inc}
  102. Const
  103. HexDisplayPrefix : string = '$';
  104. Type
  105. TFileRec=FileRec;
  106. TTextRec=TextRec;
  107. { Read internationalization settings }
  108. {$i sysinth.inc}
  109. { Read pchar handling functions declration }
  110. {$i syspchh.inc}
  111. { Read filename handling functions declaration }
  112. {$i finah.inc}
  113. { Read other file handling function declarations }
  114. {$i filutilh.inc}
  115. { Read disk function declarations }
  116. {$i diskh.inc}
  117. { read thread handling }
  118. {$i systhrdh.inc}
  119. procedure FreeAndNil(var obj);
  120. {
  121. $Log$
  122. Revision 1.13 2001-08-22 21:19:16 florian
  123. + some new stuff of D6/Kylix added
  124. Revision 1.12 2001/08/22 14:11:28 florian
  125. + HexDisplayPrefix added
  126. Revision 1.11 2001/08/19 21:02:02 florian
  127. * fixed and added a lot of stuff to get the Jedi DX8 headers
  128. compiled
  129. Revision 1.10 2001/08/12 22:11:48 peter
  130. * freeandnil added
  131. Revision 1.9 2001/06/03 15:18:01 peter
  132. * eoutofmemory and einvalidpointer fix
  133. Revision 1.8 2001/02/20 22:14:19 peter
  134. * merged getenvironmentvariable
  135. Revision 1.7 2001/01/18 22:09:09 michael
  136. + Merged fixes from fixbranch - file modes
  137. Revision 1.6 2000/12/07 09:15:18 florian
  138. + tintegerset added
  139. Revision 1.5 2000/09/24 21:55:07 peter
  140. * ttextrec,tfilerec added (merged)
  141. Revision 1.4 2000/08/30 18:29:34 hajny
  142. * OS/2 fix - datih.inc moved to the beginning
  143. Revision 1.3 2000/08/29 17:56:32 michael
  144. Merged syserrormsg fix
  145. Revision 1.2 2000/08/20 15:46:46 peter
  146. * sysutils.pp moved to target and merged with disk.inc, filutil.inc
  147. Revision 1.1.2.2 2000/08/22 19:21:48 michael
  148. + Implemented syserrormessage. Made dummies for go32v2 and OS/2
  149. * Changed linux/errors.pp so it uses pchars for storage.
  150. Revision 1.1.2.1 2000/08/20 15:07:36 peter
  151. * sysutils.pp moved into target specific directory and merged
  152. disk.inc and filutil.inc in it
  153. }