sysutilh.inc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. case integer of
  27. 0 : (lo,hi : word);
  28. 1 : (bytes : array[0..3] of byte);
  29. end;
  30. wordrec = packed record
  31. lo,hi : byte;
  32. end;
  33. int64rec = packed record
  34. case integer of
  35. 0 : (lo,hi : cardinal);
  36. 1 : (words : array[0..3] of word);
  37. 2 : (bytes : array[0..7] of byte);
  38. end;
  39. pbytearray = ^tbytearray;
  40. tbytearray = array[0..32767] of byte;
  41. pwordarray = ^twordarray;
  42. twordarray = array[0..16383] of word;
  43. TMethod = packed record
  44. Code, Data: Pointer;
  45. end;
  46. { exceptions }
  47. Exception = class(TObject)
  48. private
  49. fmessage : string;
  50. fhelpcontext : longint;
  51. public
  52. constructor Create(const msg : string);
  53. constructor CreateFmt(const msg : string; const args : array of const);
  54. constructor CreateRes(ResString: PString);
  55. constructor CreateResFmt(ResString: PString; const Args: array of const);
  56. constructor CreateHelp(const Msg: string; AHelpContext: Integer);
  57. constructor CreateFmtHelp(const Msg: string; const Args: array of const;
  58. AHelpContext: Integer);
  59. constructor CreateResHelp(ResString: PString; AHelpContext: Integer);
  60. constructor CreateResFmtHelp(ResString: PString; const Args: array of const;
  61. AHelpContext: Integer);
  62. { !!!! }
  63. property helpcontext : longint read fhelpcontext write fhelpcontext;
  64. property message : string read fmessage write fmessage;
  65. end;
  66. ExceptClass = class of Exception;
  67. { integer math exceptions }
  68. EInterror = Class(Exception);
  69. EDivByZero = Class(EIntError);
  70. ERangeError = Class(EIntError);
  71. EIntOverflow = Class(EIntError);
  72. { General math errors }
  73. EMathError = Class(Exception);
  74. EInvalidOp = Class(EMathError);
  75. EZeroDivide = Class(EMathError);
  76. EOverflow = Class(EMathError);
  77. EUnderflow = Class(EMathError);
  78. { Run-time and I/O Errors }
  79. EInOutError = class(Exception)
  80. public
  81. ErrorCode : Longint;
  82. end;
  83. EHeapMemoryError = class(Exception)
  84. protected
  85. AllowFree : boolean;
  86. procedure FreeInstance;override;
  87. end;
  88. EInvalidPointer = Class(EHeapMemoryError);
  89. EOutOfMemory = Class(EHeapMemoryError);
  90. EAccessViolation = Class(Exception);
  91. EInvalidCast = Class(Exception);
  92. EVariantError = Class(Exception);
  93. { String conversion errors }
  94. EConvertError = class(Exception);
  95. { Other errors }
  96. EAbort = Class(Exception);
  97. EAbstractError = Class(Exception);
  98. EAssertionFailed = Class(Exception);
  99. { Exception handling routines }
  100. function ExceptObject: TObject;
  101. function ExceptAddr: Pointer;
  102. function ExceptionErrorMessage(ExceptObject: TObject; ExceptAddr: Pointer;
  103. Buffer: PChar; Size: Integer): Integer;
  104. procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);
  105. procedure Abort;
  106. procedure OutOfMemoryError;
  107. procedure Beep;
  108. function SysErrorMessage(ErrorCode: Integer): String;
  109. Var
  110. OnShowException : Procedure (Msg : ShortString);
  111. { FileRec/TextRec }
  112. {$i filerec.inc}
  113. {$i textrec.inc}
  114. Const
  115. HexDisplayPrefix : string = '$';
  116. const
  117. PathDelim=System.DirectorySeparator;
  118. DriveDelim=System.DriveSeparator;
  119. PathSep=System.PathSeparator;
  120. Type
  121. TFileRec=FileRec;
  122. TTextRec=TextRec;
  123. { Read internationalization settings }
  124. {$i sysinth.inc}
  125. { Read pchar handling functions declration }
  126. {$i syspchh.inc}
  127. { Read filename handling functions declaration }
  128. {$i finah.inc}
  129. { Read other file handling function declarations }
  130. {$i filutilh.inc}
  131. { Read disk function declarations }
  132. {$i diskh.inc}
  133. { read thread handling }
  134. {$i systhrdh.inc}
  135. procedure FreeAndNil(var obj);
  136. {
  137. $Log$
  138. Revision 1.15 2001-11-07 14:58:24 michael
  139. + Added PathDelim,DriveDelim,PathSep; Removed PathSeparator
  140. Revision 1.14 2001/10/23 21:51:03 peter
  141. * criticalsection renamed to rtlcriticalsection for kylix compatibility
  142. Revision 1.13 2001/08/22 21:19:16 florian
  143. + some new stuff of D6/Kylix added
  144. Revision 1.12 2001/08/22 14:11:28 florian
  145. + HexDisplayPrefix added
  146. Revision 1.11 2001/08/19 21:02:02 florian
  147. * fixed and added a lot of stuff to get the Jedi DX8 headers
  148. compiled
  149. Revision 1.10 2001/08/12 22:11:48 peter
  150. * freeandnil added
  151. Revision 1.9 2001/06/03 15:18:01 peter
  152. * eoutofmemory and einvalidpointer fix
  153. Revision 1.8 2001/02/20 22:14:19 peter
  154. * merged getenvironmentvariable
  155. Revision 1.7 2001/01/18 22:09:09 michael
  156. + Merged fixes from fixbranch - file modes
  157. Revision 1.6 2000/12/07 09:15:18 florian
  158. + tintegerset added
  159. Revision 1.5 2000/09/24 21:55:07 peter
  160. * ttextrec,tfilerec added (merged)
  161. Revision 1.4 2000/08/30 18:29:34 hajny
  162. * OS/2 fix - datih.inc moved to the beginning
  163. Revision 1.3 2000/08/29 17:56:32 michael
  164. Merged syserrormsg fix
  165. Revision 1.2 2000/08/20 15:46:46 peter
  166. * sysutils.pp moved to target and merged with disk.inc, filutil.inc
  167. Revision 1.1.2.2 2000/08/22 19:21:48 michael
  168. + Implemented syserrormessage. Made dummies for go32v2 and OS/2
  169. * Changed linux/errors.pp so it uses pchars for storage.
  170. Revision 1.1.2.1 2000/08/20 15:07:36 peter
  171. * sysutils.pp moved into target specific directory and merged
  172. disk.inc and filutil.inc in it
  173. }