sysutilh.inc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. {$i osutilsh.inc}
  14. {$i datih.inc}
  15. { Read String Handling functions declaration }
  16. {$i sysstrh.inc}
  17. type
  18. { some helpful data types }
  19. {$IFDEF VER1_0}
  20. (* System type alias cannot be used under version *)
  21. (* 1.0 because of different names of System unit. *)
  22. THandle = longint;
  23. {$ELSE VER1_0}
  24. THandle = System.THandle;
  25. {$ENDIF VER1_0}
  26. TProcedure = procedure;
  27. TFilename = String;
  28. TIntegerSet = Set of 0..SizeOf(Integer)*8-1;
  29. LongRec = packed record
  30. case Integer of
  31. 0 : (Lo,Hi : Word);
  32. 1 : (Bytes : Array[0..3] of Byte);
  33. end;
  34. WordRec = packed record
  35. Lo,Hi : Byte;
  36. end;
  37. Int64Rec = packed record
  38. case integer of
  39. 0 : (Lo,Hi : Cardinal);
  40. 1 : (Words : Array[0..3] of Word);
  41. 2 : (Bytes : Array[0..7] of Byte);
  42. end;
  43. PByteArray = ^TByteArray;
  44. TByteArray = Array[0..32767] of Byte;
  45. PWordarray = ^TWordArray;
  46. TWordArray = array[0..16383] of Word;
  47. { exceptions }
  48. Exception = class(TObject)
  49. private
  50. fmessage : string;
  51. fhelpcontext : longint;
  52. public
  53. constructor Create(const msg : string);
  54. constructor CreateFmt(const msg : string; const args : array of const);
  55. constructor CreateRes(ResString: PString);
  56. constructor CreateResFmt(ResString: PString; const Args: array of const);
  57. constructor CreateHelp(const Msg: string; AHelpContext: Integer);
  58. constructor CreateFmtHelp(const Msg: string; const Args: array of const;
  59. AHelpContext: Integer);
  60. constructor CreateResHelp(ResString: PString; AHelpContext: Integer);
  61. constructor CreateResFmtHelp(ResString: PString; const Args: array of const;
  62. AHelpContext: Integer);
  63. { !!!! }
  64. property HelpContext : longint read fhelpcontext write fhelpcontext;
  65. property Message : string read fmessage write fmessage;
  66. end;
  67. ExceptClass = class of Exception;
  68. EExternal = class(Exception)
  69. public
  70. {$ifdef win32}
  71. ExceptionRecord : PExceptionRecord;
  72. {$endif win32}
  73. end;
  74. { integer math exceptions }
  75. EInterror = Class(EExternal);
  76. EDivByZero = Class(EIntError);
  77. ERangeError = Class(EIntError);
  78. EIntOverflow = Class(EIntError);
  79. { General math errors }
  80. EMathError = Class(EExternal);
  81. EInvalidOp = Class(EMathError);
  82. EZeroDivide = Class(EMathError);
  83. EOverflow = Class(EMathError);
  84. EUnderflow = Class(EMathError);
  85. { Run-time and I/O Errors }
  86. EInOutError = class(Exception)
  87. public
  88. ErrorCode : Longint;
  89. end;
  90. EHeapMemoryError = class(Exception)
  91. protected
  92. AllowFree : boolean;
  93. procedure FreeInstance;override;
  94. end;
  95. EHeapException = EHeapMemoryError;
  96. EExternalException = class(EExternal);
  97. EInvalidPointer = Class(EHeapMemoryError);
  98. EOutOfMemory = Class(EHeapMemoryError);
  99. EInvalidCast = Class(Exception);
  100. EVariantError = Class(Exception);
  101. EAccessViolation = Class(EExternal);
  102. EPrivilege = class(EExternal);
  103. EStackOverflow = class(EExternal);
  104. EControlC = class(EExternal);
  105. { String conversion errors }
  106. EConvertError = class(Exception);
  107. { Other errors }
  108. EAbort = Class(Exception);
  109. EAbstractError = Class(Exception);
  110. EAssertionFailed = Class(Exception);
  111. EPropReadOnly = class(Exception);
  112. EPropWriteOnly = class(Exception);
  113. EIntfCastError = class(Exception);
  114. EInvalidContainer = class(Exception);
  115. EInvalidInsert = class(Exception);
  116. EPackageError = class(Exception);
  117. EOSError = class(Exception)
  118. public
  119. ErrorCode: Longint;
  120. end;
  121. ESafecallException = class(Exception);
  122. ENoThreadSupport = Class(Exception);
  123. { Exception handling routines }
  124. function ExceptObject: TObject;
  125. function ExceptAddr: Pointer;
  126. function ExceptionErrorMessage(ExceptObject: TObject; ExceptAddr: Pointer;
  127. Buffer: PChar; Size: Integer): Integer;
  128. procedure ShowException(ExceptObject: TObject; ExceptAddr: Pointer);
  129. procedure Abort;
  130. procedure OutOfMemoryError;
  131. procedure Beep;
  132. function SysErrorMessage(ErrorCode: Integer): String;
  133. type
  134. TTerminateProc = Function: Boolean;
  135. procedure AddTerminateProc(TermProc: TTerminateProc);
  136. function CallTerminateProcs: Boolean;
  137. Var
  138. OnShowException : Procedure (Msg : ShortString);
  139. { FileRec/TextRec }
  140. {$i filerec.inc}
  141. {$i textrec.inc}
  142. Const
  143. HexDisplayPrefix : string = '$';
  144. const
  145. // commenting is VP fix. These idents are in a different unit there.
  146. PathDelim={System.}DirectorySeparator;
  147. DriveDelim={System.}DriveSeparator;
  148. PathSep={System.}PathSeparator;
  149. Type
  150. TFileRec=FileRec;
  151. TTextRec=TextRec;
  152. { Read internationalization settings }
  153. {$i sysinth.inc}
  154. { Read pchar handling functions declaration }
  155. {$IFNDEF VIRTUALPASCAL}
  156. {$i syspchh.inc}
  157. {$ENDIF}
  158. { MCBS functions }
  159. {$i sysansih.inc}
  160. { wide string functions }
  161. {$i syswideh.inc}
  162. { Read filename handling functions declaration }
  163. {$i finah.inc}
  164. { Read other file handling function declarations }
  165. {$i filutilh.inc}
  166. { Read disk function declarations }
  167. {$i diskh.inc}
  168. { read thread handling }
  169. {$i systhrdh.inc}
  170. procedure FreeAndNil(var obj);
  171. {$ifdef HASINTF}
  172. { interface handling }
  173. {$i intfh.inc}
  174. {$endif HASINTF}
  175. {
  176. $Log$
  177. Revision 1.10 2005-02-01 20:22:50 florian
  178. * improved widestring infrastructure manager
  179. Revision 1.9 2004/08/31 11:03:35 michael
  180. + Some capitalization added for documentation purposes
  181. Revision 1.8 2004/08/31 10:34:11 michael
  182. + Some capitalization added for documentation purposes
  183. Revision 1.7 2004/01/28 22:09:52 peter
  184. * EOSError.errorcode change to Longint which is more compatible
  185. with unix platforms
  186. Revision 1.6 2004/01/05 22:37:24 florian
  187. * changed sysutils.exec to ExecuteProcess
  188. Revision 1.5 2003/11/26 22:17:42 michael
  189. + Merged fixbranch fixes, missing in main branch
  190. Revision 1.4 2003/11/26 20:12:08 michael
  191. + New runerror 231 (exception stack error) and 232 (nothread support)
  192. Revision 1.3 2003/11/26 20:00:19 florian
  193. * error handling for Variants improved
  194. Revision 1.2 2003/10/25 23:43:59 hajny
  195. * THandle in sysutils common using System.THandle
  196. Revision 1.1 2003/10/06 21:01:06 peter
  197. * moved classes unit to rtl
  198. Revision 1.20 2003/09/06 20:49:54 marco
  199. * Two minimal VP fixes
  200. Revision 1.19 2003/01/01 20:58:07 florian
  201. + added invalid instruction exception
  202. Revision 1.18 2002/10/07 19:43:24 florian
  203. + empty prototypes for the AnsiStr* multi byte functions added
  204. Revision 1.17 2002/09/07 16:01:22 peter
  205. * old logs removed and tabs fixed
  206. Revision 1.16 2002/01/25 17:42:03 peter
  207. * interface helpers
  208. }