sysutilh.inc 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. { Using inlining for small system functions/wrappers }
  13. {$ifdef HASINLINE}
  14. {$inline on}
  15. {$define SYSUTILSINLINE}
  16. {$endif}
  17. { Read date & Time function declarations }
  18. {$i osutilsh.inc}
  19. {$i datih.inc}
  20. { Read String Handling functions declaration }
  21. {$i sysstrh.inc}
  22. type
  23. { some helpful data types }
  24. {$IFDEF VER1_0}
  25. (* System type alias cannot be used under version *)
  26. (* 1.0 because of different names of System unit. *)
  27. THandle = longint;
  28. {$ELSE VER1_0}
  29. THandle = System.THandle;
  30. {$ENDIF VER1_0}
  31. TProcedure = procedure;
  32. TFilename = String;
  33. TIntegerSet = Set of 0..SizeOf(Integer)*8-1;
  34. LongRec = packed record
  35. case Integer of
  36. 0 : (Lo,Hi : Word);
  37. 1 : (Bytes : Array[0..3] of Byte);
  38. end;
  39. WordRec = packed record
  40. Lo,Hi : Byte;
  41. end;
  42. Int64Rec = packed record
  43. case integer of
  44. 0 : (Lo,Hi : Cardinal);
  45. 1 : (Words : Array[0..3] of Word);
  46. 2 : (Bytes : Array[0..7] of Byte);
  47. end;
  48. PByteArray = ^TByteArray;
  49. TByteArray = Array[0..32767] of Byte;
  50. PWordarray = ^TWordArray;
  51. TWordArray = array[0..16383] of Word;
  52. { exceptions }
  53. Exception = class(TObject)
  54. private
  55. fmessage : string;
  56. fhelpcontext : longint;
  57. public
  58. constructor Create(const msg : string);
  59. constructor CreateFmt(const msg : string; const args : array of const);
  60. constructor CreateRes(ResString: PString);
  61. constructor CreateResFmt(ResString: PString; const Args: array of const);
  62. constructor CreateHelp(const Msg: string; AHelpContext: Integer);
  63. constructor CreateFmtHelp(const Msg: string; const Args: array of const;
  64. AHelpContext: Integer);
  65. constructor CreateResHelp(ResString: PString; AHelpContext: Integer);
  66. constructor CreateResFmtHelp(ResString: PString; const Args: array of const;
  67. AHelpContext: Integer);
  68. { !!!! }
  69. property HelpContext : longint read fhelpcontext write fhelpcontext;
  70. property Message : string read fmessage write fmessage;
  71. end;
  72. ExceptClass = class of Exception;
  73. EExternal = class(Exception)
  74. public
  75. {$ifdef win32}
  76. ExceptionRecord : PExceptionRecord;
  77. {$endif win32}
  78. end;
  79. { integer math exceptions }
  80. EInterror = Class(EExternal);
  81. EDivByZero = Class(EIntError);
  82. ERangeError = Class(EIntError);
  83. EIntOverflow = Class(EIntError);
  84. { General math errors }
  85. EMathError = Class(EExternal);
  86. EInvalidOp = Class(EMathError);
  87. EZeroDivide = Class(EMathError);
  88. EOverflow = Class(EMathError);
  89. EUnderflow = Class(EMathError);
  90. { Run-time and I/O Errors }
  91. EInOutError = class(Exception)
  92. public
  93. ErrorCode : Longint;
  94. end;
  95. EHeapMemoryError = class(Exception)
  96. protected
  97. AllowFree : boolean;
  98. procedure FreeInstance;override;
  99. end;
  100. EHeapException = EHeapMemoryError;
  101. EExternalException = class(EExternal);
  102. EInvalidPointer = Class(EHeapMemoryError);
  103. EOutOfMemory = Class(EHeapMemoryError);
  104. EInvalidCast = Class(Exception);
  105. EVariantError = Class(Exception);
  106. EAccessViolation = Class(EExternal);
  107. EPrivilege = class(EExternal);
  108. EStackOverflow = class(EExternal);
  109. EControlC = class(EExternal);
  110. { String conversion errors }
  111. EConvertError = class(Exception);
  112. { Other errors }
  113. EAbort = Class(Exception);
  114. EAbstractError = Class(Exception);
  115. EAssertionFailed = Class(Exception);
  116. EPropReadOnly = class(Exception);
  117. EPropWriteOnly = class(Exception);
  118. EIntfCastError = class(Exception);
  119. EInvalidContainer = class(Exception);
  120. EInvalidInsert = class(Exception);
  121. EPackageError = class(Exception);
  122. EOSError = class(Exception)
  123. public
  124. ErrorCode: Longint;
  125. end;
  126. ESafecallException = class(Exception);
  127. ENoThreadSupport = Class(Exception);
  128. { Exception handling routines }
  129. function ExceptObject: TObject;
  130. function ExceptAddr: Pointer;
  131. function ExceptionErrorMessage(ExceptObject: TObject; ExceptAddr: Pointer;
  132. Buffer: PChar; Size: Integer): Integer;
  133. procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);
  134. procedure Abort;
  135. procedure OutOfMemoryError;
  136. procedure Beep;
  137. function SysErrorMessage(ErrorCode: Integer): String;
  138. type
  139. TTerminateProc = Function: Boolean;
  140. procedure AddTerminateProc(TermProc: TTerminateProc);
  141. function CallTerminateProcs: Boolean;
  142. Var
  143. OnShowException : Procedure (Msg : ShortString);
  144. { FileRec/TextRec }
  145. {$i filerec.inc}
  146. {$i textrec.inc}
  147. Const
  148. HexDisplayPrefix : string = '$';
  149. const
  150. // commenting is VP fix. These idents are in a different unit there.
  151. PathDelim={System.}DirectorySeparator;
  152. DriveDelim={System.}DriveSeparator;
  153. PathSep={System.}PathSeparator;
  154. MAX_PATH={System.}MaxPathLen;
  155. Type
  156. TFileRec=FileRec;
  157. TTextRec=TextRec;
  158. { Read internationalization settings }
  159. {$i sysinth.inc}
  160. { Read pchar handling functions declaration }
  161. {$IFNDEF VIRTUALPASCAL}
  162. {$i syspchh.inc}
  163. {$ENDIF}
  164. { MCBS functions }
  165. {$i sysansih.inc}
  166. {$ifndef VER1_0}
  167. { wide string functions }
  168. {$i syswideh.inc}
  169. {$endif VER1_0}
  170. { Read filename handling functions declaration }
  171. {$i finah.inc}
  172. { Read other file handling function declarations }
  173. {$i filutilh.inc}
  174. { Read disk function declarations }
  175. {$i diskh.inc}
  176. { read thread handling }
  177. {$i systhrdh.inc}
  178. procedure FreeAndNil(var obj);
  179. {$ifdef HASINTF}
  180. { interface handling }
  181. {$i intfh.inc}
  182. {$endif HASINTF}
  183. {
  184. $Log$
  185. Revision 1.15 2005-05-12 20:30:51 michael
  186. + Added MAX_PATH for Delphi/Kylix compatibility.
  187. Revision 1.14 2005/03/12 14:56:22 florian
  188. + added Ansi* routines to widestring manager
  189. * made them using OS calls on windows
  190. Revision 1.13 2005/02/14 17:13:31 peter
  191. * truncate log
  192. Revision 1.12 2005/02/03 18:40:02 florian
  193. * compilation with 1.0.x fixed
  194. + infrastructure for WideCompareText implemented
  195. Revision 1.11 2005/02/03 16:21:59 peter
  196. * 1.0.x fix
  197. Revision 1.10 2005/02/01 20:22:50 florian
  198. * improved widestring infrastructure manager
  199. }