overlaymgr.pp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. {$MACRO ON}
  2. {$define Rsc := }
  3. (******************************************************************************
  4. *
  5. * Copyright (c) 1999-2000 Palm, Inc. or its subsidiaries.
  6. * All rights reserved.
  7. *
  8. * File: OverlayMgr.h
  9. *
  10. * Release: Palm OS SDK 4.0 (63220)
  11. *
  12. * Description:
  13. * Public header for routines that support overlays.
  14. *
  15. * History:
  16. * 06/24/99 kwk Created by Ken Krugler.
  17. * 07/06/99 CS Added omSpecAttrForBase
  18. * (and renumbered omSpecAttrStripped).
  19. * 07/29/99 CS Added omOverlayKindBase for the entries in the base
  20. * DBs 'ovly' resource (they had been set to
  21. * omOverlayKindReplace before).
  22. * 07/29/99 CS Bumped version to 3, since now we're supposed to
  23. * support omOverlayKindAdd.
  24. * 09/29/99 kwk Bumped version to 4, since we added the baseChecksum
  25. * field to OmOverlaySpecType, as a way of speeding up
  26. * overlay validation.
  27. * 09/29/99 CS Actually bumped version to 4, which Ken forgot.
  28. * 10/08/99 kwk Added OmGetRoutineAddress selector/declaration.
  29. * Moved OmDispatch, OmInit, and OmOpenOverlayDatabase
  30. * into OverlayPrv.h
  31. * ===== Palm OS 3.5 Released =====
  32. * 03/12/00 kwk Fixed comment for omOverlayKindHide.
  33. * 05/18/00 kwk Added omFtrDefaultLocale feature selector.
  34. * Added OmGetNextSystemLocale routine. Changed OmLocaleType
  35. * to LmLocaleType. Deleted omOverlayDBType (use sysFileTOverlay).
  36. * Moved more private stuff into OverlayPrv.h.
  37. * 07/29/00 kwk Added note about using OmGetNextSystemLocale vs OmGetIndexedLocale.
  38. * 09/14/00 kwk Added didNoOverlaySystem & foundSystem to OmSearchStateType,
  39. * plus 6 more reserved bytes for future expansion.
  40. * 09/18/00 kwk Added omErrNoNextSystemLocale.
  41. *
  42. *****************************************************************************)
  43. unit overlaymgr;
  44. interface
  45. uses palmos, coretraps, errorbase, datamgr, localemgr;
  46. (***********************************************************************
  47. * Overlay Manager constants
  48. **********************************************************************)
  49. const
  50. omOverlayRscType_ = Rsc('ovly'); // Overlay desc resource type
  51. omOverlayRscID = 1000; // Overlay desc resource ID
  52. omFtrCreator = Rsc('ovly'); // For get/set of Overlay features.
  53. omFtrShowErrorsFlag = 0; // Boolean - True => display overlay errors.
  54. omFtrDefaultLocale = 1; // LmLocaleType record => default locale to
  55. // try with stripped bases & no valid overlay.
  56. // OmFindOverlayDatabase called with stripped base, and no appropriate overlay was found.
  57. omErrBaseRequiresOverlay = omErrorClass or 1;
  58. // OmOverlayDBNameToLocale or OmLocaleToOverlayDBName were passed an unknown locale.
  59. mErrUnknownLocale = omErrorClass or 2;
  60. // OmOverlayDBNameToLocale was passed a poorly formed string.
  61. mErrBadOverlayDBName = omErrorClass or 3;
  62. // OmGetIndexedLocale was passed an invalid index.
  63. mErrInvalidLocaleIndex = omErrorClass or 4;
  64. // OmSetSystemLocale was passed an invalid locale (doesn't correspond to available
  65. // system overlay).
  66. mErrInvalidLocale = omErrorClass or 5;
  67. // OmSetSystemLocale was passed a locale that referenced an invalid system overlay
  68. // (missing one or more required resources)
  69. mErrInvalidSystemOverlay = omErrorClass or 6;
  70. // OmGetNextSystemLocale was called, but there were no more valid system
  71. // locales to return.
  72. omErrNoNextSystemLocale = omErrorClass or 7;
  73. (***********************************************************************
  74. * Selectors & macros used for calling Overlay Manager routines
  75. **********************************************************************)
  76. // Selectors used for getting to the right Overlay Manager routine via
  77. // the OmDispatch trap.
  78. type
  79. OmSelector = WordEnum;
  80. const
  81. omInit = 0;
  82. omOpenOverlayDatabase = Succ(omInit);
  83. omLocaleToOverlayDBName_ = Succ(omOpenOverlayDatabase);
  84. omOverlayDBNameToLocale_ = Succ(omLocaleToOverlayDBName_);
  85. omGetCurrentLocale_ = Succ(omOverlayDBNameToLocale_);
  86. omGetIndexedLocale_ = Succ(omGetCurrentLocale_);
  87. omGetSystemLocale_ = Succ(omGetIndexedLocale_);
  88. omSetSystemLocale_ = Succ(omGetSystemLocale_);
  89. omGetRoutineAddress_ = Succ(omSetSystemLocale_);
  90. omGetNextSystemLocale_ = Succ(omGetRoutineAddress_);
  91. omMaxSelector = omGetNextSystemLocale_;
  92. (***********************************************************************
  93. * Overlay Manager types
  94. **********************************************************************)
  95. // DOLATER kwk - decide how to deprecate this.
  96. type
  97. OmLocaleType = LmLocaleType;
  98. // Structure passed to OmGetNextSystemLocale.
  99. type
  100. OmSearchStateType = record
  101. searchState: DmSearchStateType;
  102. systemDBRef: DmOpenRef;
  103. systemDBCard: UInt16;
  104. systemDBName: array [0..dmDBNameLength-1] of Char;
  105. systemDBNameLen: Int16;
  106. curLocale: LmLocaleType;
  107. didNoOverlaySystem: Boolean;
  108. foundSystem: Boolean;
  109. reserved: array [0..5] of UInt8;
  110. end;
  111. (***********************************************************************
  112. * Overlay Manager routines
  113. **********************************************************************)
  114. // Return in <overlayDBName> an overlay database name that's appropriate
  115. // for the base name <baseDBName> and the locale <targetLocale>. If the
  116. // <targetLocale> param in NULL, use the current locale. The <overlayDBName>
  117. // buffer must be at least dmDBNameLength bytes.
  118. function OmLocaleToOverlayDBName(const baseDBName: PChar; {const} var targetLocale: LmLocaleType;
  119. overlayDBName: PChar): Err;
  120. // Given the name of an overlay database in <overlayDBName>, return back
  121. // the overlay in overlayLocale. If the name isn't an overlay name,
  122. // return omErrBadOverlayDBName.
  123. function OmOverlayDBNameToLocale(const overlayDBName: PChar; var overlayLocale: LmLocaleType): Err;
  124. // Return the current locale in <currentLocale>. This may not be the same as
  125. // the system locale, which will take effect after the next reset.
  126. procedure OmGetCurrentLocale(var currentLocale: LmLocaleType);
  127. // Return the nth valid system locale in <theLocale>. Indexes are zero-based,
  128. // and omErrInvalidLocaleIndex will be returned if <localeIndex> is out of
  129. // bounds. Note that OmGetNextSystemLocale should be used on Palm OS 4.0 or
  130. // later, since OmGetIndexedLocale can be slow on ROMs with more than few
  131. // valid system locales.
  132. function OmGetIndexedLocale(localeIndex: UInt16; var theLocale: LmLocaleType): Err;
  133. // Return the system locale in <systemLocale>. This may not be the same as
  134. // the current locale. WARNING!!! This routine should only be used in very
  135. // special situations; typically OmGetCurrentLocale should be used to determine
  136. // the "active" locale.
  137. procedure OmGetSystemLocale(var systemLocale: LmLocaleType);
  138. // Set the post-reset system locale to be <systemLocale>. Return omErrInvalidLocale if
  139. // the passed locale doesnմ correspond to a valid System.prc overlay.
  140. function OmSetSystemLocale({const} var systemLocale: LmLocaleType): Err;
  141. // Return back the address of the routine indicated by <inSelector>. If
  142. // <inSelector> isn't a valid routine selector, return back NULL.
  143. function OmGetRoutineAddress(inSelector: OmSelector): Pointer;
  144. // NEW in 4.0. Return back the next valid system locale in <oLocaleP>. The first
  145. // time the routine is called, <iNewSearch> must be true. When there are no more
  146. // valid system locales, omErrInvalidLocaleIndex will be returned. This routine
  147. // should be used in place of OmGetIndexedLocale on Palm OS 4.0 or later, since
  148. // it's much faster.
  149. function OmGetNextSystemLocale(iNewSearch: Boolean; var ioStateInfoP: OmSearchStateType; var oLocaleP: LmLocaleType): Err;
  150. implementation
  151. function __OmLocaleToOverlayDBName(const baseDBName: PChar; {const} var targetLocale: LmLocaleType;
  152. overlayDBName: PChar): Err; syscall sysTrapOmDispatch;
  153. function __OmOverlayDBNameToLocale(const overlayDBName: PChar; var overlayLocale: LmLocaleType): Err; syscall sysTrapOmDispatch;
  154. procedure __OmGetCurrentLocale(var currentLocale: LmLocaleType); syscall sysTrapOmDispatch;
  155. function __OmGetIndexedLocale(localeIndex: UInt16; var theLocale: LmLocaleType): Err; syscall sysTrapOmDispatch;
  156. procedure __OmGetSystemLocale(var systemLocale: LmLocaleType); syscall sysTrapOmDispatch;
  157. function __OmSetSystemLocale({const} var systemLocale: LmLocaleType): Err; syscall sysTrapOmDispatch;
  158. function __OmGetRoutineAddress(inSelector: OmSelector): Pointer; syscall sysTrapOmDispatch;
  159. function __OmGetNextSystemLocale(iNewSearch: Boolean; var ioStateInfoP: OmSearchStateType; var oLocaleP: LmLocaleType): Err; syscall sysTrapOmDispatch;
  160. function OmLocaleToOverlayDBName(const baseDBName: PChar; var targetLocale: LmLocaleType;
  161. overlayDBName: PChar): Err;
  162. begin
  163. asm
  164. move.l #$omLocaleToOverlayDBName_,D2;
  165. end;
  166. OmLocaleToOverlayDBName := __OmLocaleToOverlayDBName(baseDBName, targetLocale, overlayDBName);
  167. end;
  168. function OmOverlayDBNameToLocale(const overlayDBName: PChar; var overlayLocale: LmLocaleType): Err;
  169. begin
  170. asm
  171. move.l #$omOverlayDBNameToLocale_,D2;
  172. end;
  173. OmOverlayDBNameToLocale := __OmOverlayDBNameToLocale(overlayDBName, overlayLocale);
  174. end;
  175. procedure OmGetCurrentLocale(var currentLocale: LmLocaleType);
  176. begin
  177. asm
  178. move.l #$omGetCurrentLocale_,D2;
  179. end;
  180. __OmGetCurrentLocale(currentLocale);
  181. end;
  182. function OmGetIndexedLocale(localeIndex: UInt16; var theLocale: LmLocaleType): Err;
  183. begin
  184. asm
  185. move.l #$omGetIndexedLocale_,D2;
  186. end;
  187. OmGetIndexedLocale := __OmGetIndexedLocale(localeIndex, theLocale);
  188. end;
  189. procedure OmGetSystemLocale(var systemLocale: LmLocaleType);
  190. begin
  191. asm
  192. move.l #$omGetSystemLocale_,D2;
  193. end;
  194. __OmGetSystemLocale(systemLocale);
  195. end;
  196. function OmSetSystemLocale(var systemLocale: LmLocaleType): Err;
  197. begin
  198. asm
  199. move.l #$omSetSystemLocale_,D2;
  200. end;
  201. OmSetSystemLocale := __OmSetSystemLocale(systemLocale);
  202. end;
  203. function OmGetRoutineAddress(inSelector: OmSelector): Pointer;
  204. begin
  205. asm
  206. move.l #$omGetRoutineAddress_,D2;
  207. end;
  208. OmGetRoutineAddress := __OmGetRoutineAddress(inSelector);
  209. end;
  210. function OmGetNextSystemLocale(iNewSearch: Boolean; var ioStateInfoP: OmSearchStateType; var oLocaleP: LmLocaleType): Err;
  211. begin
  212. asm
  213. move.l #$omGetNextSystemLocale_,D2;
  214. end;
  215. OmGetNextSystemLocale := __OmGetNextSystemLocale(iNewSearch, ioStateInfoP, oLocaleP);
  216. end;
  217. end.