Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1104 lines
37 KiB

  1. /*
  2. * M A P I U T I L . H
  3. *
  4. * Definitions and prototypes for utility functions provided by MAPI
  5. * in MAPIU[xx].DLL.
  6. *
  7. * Copyright 1993-1995 Microsoft Corporation. All Rights Reserved.
  8. */
  9. #ifndef _MAPIUTIL_H_
  10. #define _MAPIUTIL_H_
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. #ifndef MAPIX_H
  15. #include <mapix.h>
  16. #endif
  17. #ifdef WIN16
  18. #include <storage.h>
  19. #endif
  20. #ifndef BEGIN_INTERFACE
  21. #define BEGIN_INTERFACE
  22. #endif
  23. /* IMAPITable in memory */
  24. /* ITableData Interface ---------------------------------------------------- */
  25. DECLARE_MAPI_INTERFACE_PTR(ITableData, LPTABLEDATA);
  26. typedef void (STDAPICALLTYPE CALLERRELEASE)(
  27. ULONG ulCallerData,
  28. LPTABLEDATA lpTblData,
  29. LPMAPITABLE lpVue
  30. );
  31. #define MAPI_ITABLEDATA_METHODS(IPURE) \
  32. MAPIMETHOD(HrGetView) \
  33. (THIS_ LPSSortOrderSet lpSSortOrderSet, \
  34. CALLERRELEASE FAR * lpfCallerRelease, \
  35. ULONG ulCallerData, \
  36. LPMAPITABLE FAR * lppMAPITable) IPURE; \
  37. MAPIMETHOD(HrModifyRow) \
  38. (THIS_ LPSRow) IPURE; \
  39. MAPIMETHOD(HrDeleteRow) \
  40. (THIS_ LPSPropValue lpSPropValue) IPURE; \
  41. MAPIMETHOD(HrQueryRow) \
  42. (THIS_ LPSPropValue lpsPropValue, \
  43. LPSRow FAR * lppSRow, \
  44. ULONG FAR * lpuliRow) IPURE; \
  45. MAPIMETHOD(HrEnumRow) \
  46. (THIS_ ULONG ulRowNumber, \
  47. LPSRow FAR * lppSRow) IPURE; \
  48. MAPIMETHOD(HrNotify) \
  49. (THIS_ ULONG ulFlags, \
  50. ULONG cValues, \
  51. LPSPropValue lpSPropValue) IPURE; \
  52. MAPIMETHOD(HrInsertRow) \
  53. (THIS_ ULONG uliRow, \
  54. LPSRow lpSRow) IPURE; \
  55. MAPIMETHOD(HrModifyRows) \
  56. (THIS_ ULONG ulFlags, \
  57. LPSRowSet lpSRowSet) IPURE; \
  58. MAPIMETHOD(HrDeleteRows) \
  59. (THIS_ ULONG ulFlags, \
  60. LPSRowSet lprowsetToDelete, \
  61. ULONG FAR * cRowsDeleted) IPURE; \
  62. #undef INTERFACE
  63. #define INTERFACE ITableData
  64. DECLARE_MAPI_INTERFACE_(ITableData, IUnknown)
  65. {
  66. BEGIN_INTERFACE
  67. MAPI_IUNKNOWN_METHODS(PURE)
  68. MAPI_ITABLEDATA_METHODS(PURE)
  69. };
  70. /* Entry Point for in memory ITable */
  71. /* CreateTable()
  72. * Creates the internal memory structures and object handle
  73. * to bring a new table into existence.
  74. *
  75. * lpInterface
  76. * Interface ID of the TableData object (IID_IMAPITableData)
  77. *
  78. * lpAllocateBuffer, lpAllocateMore, and lpFreeBuffer
  79. * Function addresses are provided by the caller so that
  80. * this DLL allocates/frees memory appropriately.
  81. * lpvReserved
  82. * Reserved. Should be NULL.
  83. * ulTableType
  84. * TBLTYPE_DYNAMIC, etc. Visible to the calling application
  85. * as part of the GetStatus return data on its views
  86. * ulPropTagIndexColumn
  87. * Index column for use when changing the data
  88. * lpSPropTagArrayColumns
  89. * Column proptags for the minimum set of columns in the table
  90. * lppTableData
  91. * Address of the pointer which will receive the TableData object
  92. */
  93. STDAPI_(SCODE)
  94. CreateTable( LPCIID lpInterface,
  95. ALLOCATEBUFFER FAR * lpAllocateBuffer,
  96. ALLOCATEMORE FAR * lpAllocateMore,
  97. FREEBUFFER FAR * lpFreeBuffer,
  98. LPVOID lpvReserved,
  99. ULONG ulTableType,
  100. ULONG ulPropTagIndexColumn,
  101. LPSPropTagArray lpSPropTagArrayColumns,
  102. LPTABLEDATA FAR * lppTableData );
  103. /* HrGetView()
  104. * This function obtains a new view on the underlying data
  105. * which supports the IMAPITable interface. All rows and columns
  106. * of the underlying table data are initially visible
  107. * lpSSortOrderSet
  108. * if specified, results in the view being sorted
  109. * lpfCallerRelease
  110. * pointer to a routine to be called when the view is released, or
  111. * NULL.
  112. * ulCallerData
  113. * arbitrary data the caller wants saved with this view and returned in
  114. * the Release callback.
  115. */
  116. /* HrModifyRows()
  117. * Add or modify a set of rows in the table data
  118. * ulFlags
  119. * Must be zero
  120. * lpSRowSet
  121. * Each row in the row set contains all the properties for one row
  122. * in the table. One of the properties must be the index column. Any
  123. * row in the table with the same value for its index column is
  124. * replaced, or if there is no current row with that value the
  125. * row is added.
  126. * Each row in LPSRowSet MUST have a unique Index column!
  127. * If any views are open, the view is updated as well.
  128. * The properties do not have to be in the same order as the
  129. * columns in the current table
  130. */
  131. /* HrModifyRow()
  132. * Add or modify one row in the table
  133. * lpSRow
  134. * This row contains all the properties for one row in the table.
  135. * One of the properties must be the index column. Any row in
  136. * the table with the same value for its index column is
  137. * replaced, or if there is no current row with that value the
  138. * row is added
  139. * If any views are open, the view is updated as well.
  140. * The properties do not have to be in the same order as the
  141. * columns in the current table
  142. */
  143. /* HrDeleteRows()
  144. * Delete a row in the table.
  145. * ulFlags
  146. * TAD_ALL_ROWS - Causes all rows in the table to be deleted
  147. * lpSRowSet is ignored in this case.
  148. * lpSRowSet
  149. * Each row in the row set contains all the properties for one row
  150. * in the table. One of the properties must be the index column. Any
  151. * row in the table with the same value for its index column is
  152. * deleted.
  153. * Each row in LPSRowSet MUST have a unique Index column!
  154. * If any views are open, the view is updated as well.
  155. * The properties do not have to be in the same order as the
  156. * columns in the current table
  157. */
  158. #define TAD_ALL_ROWS 1
  159. /* HrDeleteRow()
  160. * Delete a row in the table.
  161. * lpSPropValue
  162. * This property value specifies the row which has this value
  163. * for its index column
  164. */
  165. /* HrQueryRow()
  166. * Returns the values of a specified row in the table
  167. * lpSPropValue
  168. * This property value specifies the row which has this value
  169. * for its index column
  170. * lppSRow
  171. * Address of where to return a pointer to an SRow
  172. * lpuliRow
  173. * Address of where to return the row number. This can be NULL
  174. * if the row number is not required.
  175. *
  176. */
  177. /* HrEnumRow()
  178. * Returns the values of a specific (numbered) row in the table
  179. * ulRowNumber
  180. * Indicates row number 0 to n-1
  181. * lppSRow
  182. * Address of where to return a pointer to a SRow
  183. */
  184. /* HrInsertRow()
  185. * Inserts a row into the table.
  186. * uliRow
  187. * The row number before which this row will be inserted into the table.
  188. * Row numbers can be from 0 to n where o to n-1 result in row insertion
  189. * a row number of n results in the row being appended to the table.
  190. * lpSRow
  191. * This row contains all the properties for one row in the table.
  192. * One of the properties must be the index column. Any row in
  193. * the table with the same value for its index column is
  194. * replaced, or if there is no current row with that value the
  195. * row is added
  196. * If any views are open, the view is updated as well.
  197. * The properties do not have to be in the same order as the
  198. * columns in the current table
  199. */
  200. /* IMAPIProp in memory */
  201. /* IPropData Interface ---------------------------------------------------- */
  202. #define MAPI_IPROPDATA_METHODS(IPURE) \
  203. MAPIMETHOD(HrSetObjAccess) \
  204. (THIS_ ULONG ulAccess) IPURE; \
  205. MAPIMETHOD(HrSetPropAccess) \
  206. (THIS_ LPSPropTagArray lpPropTagArray, \
  207. ULONG FAR * rgulAccess) IPURE; \
  208. MAPIMETHOD(HrGetPropAccess) \
  209. (THIS_ LPSPropTagArray FAR * lppPropTagArray, \
  210. ULONG FAR * FAR * lprgulAccess) IPURE; \
  211. MAPIMETHOD(HrAddObjProps) \
  212. (THIS_ LPSPropTagArray lppPropTagArray, \
  213. LPSPropProblemArray FAR * lprgulAccess) IPURE;
  214. #undef INTERFACE
  215. #define INTERFACE IPropData
  216. DECLARE_MAPI_INTERFACE_(IPropData, IMAPIProp)
  217. {
  218. BEGIN_INTERFACE
  219. MAPI_IUNKNOWN_METHODS(PURE)
  220. MAPI_IMAPIPROP_METHODS(PURE)
  221. MAPI_IPROPDATA_METHODS(PURE)
  222. };
  223. DECLARE_MAPI_INTERFACE_PTR(IPropData, LPPROPDATA);
  224. /* Entry Point for in memory IMAPIProp */
  225. /* CreateIProp()
  226. * Creates the internal memory structures and object handle
  227. * to bring a new property interface into existance.
  228. *
  229. * lpInterface
  230. * Interface ID of the TableData object (IID_IMAPIPropData)
  231. *
  232. * lpAllocateBuffer, lpAllocateMore, and lpFreeBuffer
  233. * Function addresses are provided by the caller so that
  234. * this DLL allocates/frees memory appropriately.
  235. * lppPropData
  236. * Address of the pointer which will receive the IPropData object
  237. * lpvReserved
  238. * Reserved. Should be NULL.
  239. */
  240. STDAPI_(SCODE)
  241. CreateIProp( LPCIID lpInterface,
  242. ALLOCATEBUFFER FAR * lpAllocateBuffer,
  243. ALLOCATEMORE FAR * lpAllocateMore,
  244. FREEBUFFER FAR * lpFreeBuffer,
  245. LPVOID lpvReserved,
  246. LPPROPDATA FAR * lppPropData );
  247. /*
  248. * Defines for prop/obj access
  249. */
  250. #define IPROP_READONLY ((ULONG) 0x00000001)
  251. #define IPROP_READWRITE ((ULONG) 0x00000002)
  252. #define IPROP_CLEAN ((ULONG) 0x00010000)
  253. #define IPROP_DIRTY ((ULONG) 0x00020000)
  254. /*
  255. - HrSetPropAccess
  256. -
  257. * Sets access right attributes on a per-property basis. By default,
  258. * all properties are read/write.
  259. *
  260. */
  261. /*
  262. - HrSetObjAccess
  263. -
  264. * Sets access rights for the object itself. By default, the object has
  265. * read/write access.
  266. *
  267. */
  268. /* IDLE Engine */
  269. #ifndef NOIDLEENGINE
  270. /* Idle time scheduler */
  271. /*
  272. * PRI
  273. *
  274. * Priority. Idle function priority where 0 is the priority of
  275. * a "user event" (mouse click, WM_PAINT, etc). Idle routines
  276. * can have priorities greater than or less than 0, but not
  277. * equal to 0. Priorities greater than zero are background
  278. * tasks that have a higher priority than user events and are
  279. * dispatched as part of the standard message pump loop. Priorities
  280. * less than zero are idle tasks that only run during message pump
  281. * idle time. The priorities are sorted and the one with the higher
  282. * value runs first. For negative priorities, for example, -3 is
  283. * higher than -5. Within a priority level, the functions are called
  284. * round-robin.
  285. *
  286. * Example priorities (subject to change):
  287. *
  288. * Foreground submission 1
  289. * Power Edit char insertion -1
  290. * Autoscrolling -1
  291. * Background redraw -2
  292. * Misc FW fixups -2
  293. * Clock -2
  294. * Download new mail -3
  295. * Background submission -4
  296. * Poll for MTA back up -4
  297. * Poll for new mail -4
  298. * ISAM buffer flush -5
  299. * MS compaction -6
  300. *
  301. */
  302. #define PRILOWEST -32768
  303. #define PRIHIGHEST 32767
  304. #define PRIUSER 0
  305. /*
  306. * SCH
  307. *
  308. * Idle Scheduler state. This is the state of the system when the
  309. * idle routine dispatcher, FDoNextIdleTask() is called.
  310. * This is a combined bit mask consisting of individual fsch's.
  311. * Listed below are the possible bit flags.
  312. *
  313. * fschUserEvent - FDoNextIdleTask() is being called while in
  314. * the user event loop, i.e. not during idle
  315. * time. This is to allow background routines
  316. * to run that have a higher priority than user
  317. * events.
  318. */
  319. #define SCHNULL ((USHORT) 0x0000)
  320. #define FSCHUSEREVENT ((USHORT) 0x0008)
  321. /*
  322. * IRO
  323. *
  324. * Idle routine options. This is a combined bit mask consisting of
  325. * individual firo's. Listed below are the possible bit flags.
  326. *
  327. * The following two flags are considered mutually exclusive:
  328. * If neither of the flags are specified, the default action
  329. * is to ignore the time parameter of the idle function and
  330. * call it as often as possible if firoPerBlock is not set;
  331. * otherwise call it one time only during the idle block
  332. * once the time constraint has been set. Note that firoInterval
  333. * is incompatible with firoPerBlock.
  334. *
  335. * firoWait - time given is minimum idle time before calling
  336. * for the first time in the block of idle time,
  337. * afterwhich call as often as possible.
  338. * firoInterval - time given is minimum interval between each
  339. * successive call
  340. *
  341. * firoPerBlock - called only once per contiguous block of idle
  342. * time
  343. *
  344. * firoDisabled - initially disabled when registered, the
  345. * default is to enable the function when registered.
  346. * firoOnceOnly - called only one time by the scheduler and then
  347. * deregistered automatically.
  348. */
  349. #define IRONULL ((USHORT) 0x0000)
  350. #define FIROWAIT ((USHORT) 0x0001)
  351. #define FIROINTERVAL ((USHORT) 0x0002)
  352. #define FIROPERBLOCK ((USHORT) 0x0004)
  353. #define FIRODISABLED ((USHORT) 0x0020)
  354. #define FIROONCEONLY ((USHORT) 0x0040)
  355. /*
  356. * CSEC
  357. *
  358. * Hundreths of a second. Used in specifying idle function parameters.
  359. * Each idle function has a time associated with it. This time can
  360. * represent the minimum length of user idle time that must elapse
  361. * before the function is called, after which it is called as often as
  362. * possible (firoWait option). Alternatively, the time can represent
  363. * the minimum interval between calls to the function (firoInterval
  364. * option). Finally, the time can be ignored, in which case the
  365. * function will be called as often as possible.
  366. *
  367. */
  368. #define csecNull ((ULONG) 0x00000000)
  369. /*
  370. * IRC
  371. *
  372. * Idle routine change options. This is a combined bit mask consisting of
  373. * individual firc's. Listed below are the possible bit flags.
  374. *
  375. */
  376. #define IRCNULL ((USHORT) 0x0000)
  377. #define FIRCPFN ((USHORT) 0x0001) /* change function pointer */
  378. #define FIRCPV ((USHORT) 0x0002) /* change parameter block */
  379. #define FIRCPRI ((USHORT) 0x0004) /* change priority */
  380. #define FIRCCSEC ((USHORT) 0x0008) /* change time */
  381. #define FIRCIRO ((USHORT) 0x0010) /* change routine options */
  382. /*
  383. * Type definition for idle functions. An idle function takes one
  384. * parameter, an PV, and returns a BOOL value.
  385. */
  386. typedef BOOL (STDAPICALLTYPE FNIDLE) (LPVOID);
  387. typedef FNIDLE *PFNIDLE;
  388. /*
  389. * FTG
  390. *
  391. * Function Tag. Used to identify a registered idle function.
  392. *
  393. */
  394. typedef void far *FTG, **PFTG;
  395. #define FTGNULL ((FTG) NULL)
  396. /*
  397. *
  398. * What follows is declarations for the idle engine functions in mapiu.dll,
  399. * with some description of each function
  400. *
  401. */
  402. /*
  403. - Idle_InitDLL
  404. -
  405. * Purpose:
  406. * Initialises the idle engine
  407. * If the initialisation succeded, returns 0, else returns -1
  408. *
  409. * Arguments:
  410. * pMemAlloc Pointer to memory allocator to be used by the DLL for
  411. * maintaining it's data structures of registered callbacks.
  412. * Only the first such memory allocator is accepted. Multiple
  413. * calls to Idle_InitDLL result in the first call returning
  414. * success and subsequent calls failing.
  415. */
  416. STDAPI_(LONG)
  417. Idle_InitDLL (LPMALLOC pMemAlloc);
  418. STDAPI_(VOID)
  419. Idle_DeInitDLL (VOID);
  420. STDAPI_(VOID)
  421. InstallFilterHook (BOOL);
  422. /*
  423. * FtgRegisterIdleRoutine
  424. *
  425. * Purpose:
  426. * Registers the function pfn of type PFNIDLE, i.e., (BOOL (*)(LPVOID))
  427. * as an idle function. Resorts the idle table based on the priority of
  428. * the newly registered routine.
  429. *
  430. * It will be called with the parameter pv by the scheduler
  431. * FDoNextIdleTask(). The function has initial priority priIdle,
  432. * associated time csecIdle, and options iroIdle.
  433. *
  434. * Arguments:
  435. * pfnIdle Pointer to the idle loop routine. The routine
  436. * will be called with the argument pvIdleParam (which
  437. * is initially given at registration) and must return a
  438. * BOOL. The function should always return FALSE
  439. * unless the idle routine is being called via
  440. * IdleExit() instead of the scheduler FDoNextIdleTask().
  441. * In this case, the global flag fIdleExit will be set
  442. * and the idle function should return TRUE if it
  443. * is ready to quit the application; else it should
  444. * return FALSE. IdleExit() will repeatedly call the
  445. * idle function until it returns TRUE.
  446. *
  447. * pvIdleParam Every time the idle function is called, this value
  448. * is passed as the idle function's parameter. The
  449. * routine can use this as a pointer to a state buffer
  450. * for length operations. This pointer can be changed
  451. * via a call to ChangeIdleRoutine().
  452. *
  453. * priIdle Initial priority of the idle routine. This can be
  454. * changed via a call to ChangeIdleRoutine().
  455. *
  456. * csecIdle Initial time value associated with idle routine.
  457. * This can be changed via ChangeIdleRoutine().
  458. *
  459. * iroIdle Initial options associated with idle routine. This
  460. * can be changed via ChangeIdleRoutine().
  461. *
  462. * Returns:
  463. * FTG identifying the routine.
  464. * If the function could not be registered, perhaps due to
  465. * memory problems, then ftgNull is returned.
  466. *
  467. */
  468. STDAPI_(FTG)
  469. FtgRegisterIdleRoutine (PFNIDLE pfnIdle, LPVOID pvIdleParam,
  470. short priIdle, ULONG csecIdle, USHORT iroIdle);
  471. /*
  472. * DeregisterIdleRoutine
  473. *
  474. * Purpose:
  475. * Removes the given routine from the list of idle routines.
  476. * The routine will not be called again. It is the responsibility
  477. * of the caller to clean up any data structures pointed to by the
  478. * pvIdleParam parameter; this routine does not free the block.
  479. *
  480. * An idle routine is only deregistered if it is not currently
  481. * active. Thus if an idle routine directly or indirectly calls
  482. * DeregisterIdleRoutine(), then the flag fDeregister is set, and
  483. * the idle routine will be deregistered after it finishes.
  484. * There are no checks made to make sure that the idle routine is in
  485. * an exitable state.
  486. *
  487. * Parameters:
  488. * ftg Identifies the routine to deregister.
  489. *
  490. * Returns:
  491. * void
  492. *
  493. */
  494. STDAPI_(void)
  495. DeregisterIdleRoutine (FTG ftg);
  496. /*
  497. * EnableIdleRoutine
  498. *
  499. * Purpose:
  500. * Enables or disables an idle routine. Disabled routines are
  501. * not called during the idle loop.
  502. *
  503. * Parameters:
  504. * ftg Identifies the idle routine to be disabled.
  505. * fEnable TRUE if routine should be enabled, FALSE if
  506. * routine should be disabled.
  507. *
  508. * Returns:
  509. * void
  510. *
  511. */
  512. STDAPI_(void)
  513. EnableIdleRoutine (FTG ftg, BOOL fEnable);
  514. /*
  515. * ChangeIdleRoutine
  516. *
  517. * Purpose:
  518. * Changes some or all of the characteristics of the given idle
  519. * function. The changes to make are indicated with flags in the
  520. * ircIdle parameter. If the priority of an idle function is
  521. * changed, the pInst->pftgIdle table is re-sorted.
  522. *
  523. * Arguments:
  524. * ftg Identifies the routine to change
  525. * pfnIdle New idle function to call
  526. * pvIdleParam New parameter block to use
  527. * priIdle New priority for idle function
  528. * csecIdle New time value for idle function
  529. * iroIdle New options for idle function
  530. * ircIdle Change options
  531. *
  532. * Returns:
  533. * void
  534. *
  535. */
  536. STDAPI_(void)
  537. ChangeIdleRoutine (FTG ftg, PFNIDLE pfnIdle, LPVOID pvIdleParam,
  538. short priIdle, ULONG csecIdle, USHORT iroIdle, USHORT ircIdle);
  539. /*
  540. * FDoNextIdleTask
  541. *
  542. * Purpose:
  543. * Calls the highest priority, registered, enabled, "eligible",
  544. * idle routine. Eligibility is determined by calling,
  545. * FEligibleIdle()
  546. * If all enabled routines of the highest priority level are not
  547. * "eligible" at this time, the routines that are one notch lower
  548. * in priority are checked next. This continues until either a
  549. * routine is actually run, or no routines are left to run.
  550. * Routines of equal priority are called in a round-robin fashion.
  551. * If an idle routine is actually dispatched, the function returns
  552. * TRUE; else FALSE.
  553. *
  554. * Returns:
  555. * TRUE if an eligible routine is dispatched; else FALSE.
  556. *
  557. */
  558. STDAPI_(BOOL) FDoNextIdleTask (void);
  559. /*
  560. * FIsIdleExit
  561. *
  562. * Purpose:
  563. * Returns state of fIdleExit flag, which is TRUE while
  564. * IdleExit() is being called, so that idle routines can
  565. * check the flag. See IdleExit() for description of flag
  566. *
  567. * Arguments:
  568. * void
  569. *
  570. * Returns:
  571. * State of the fIdleExit flag.
  572. *
  573. */
  574. STDAPI_(BOOL)
  575. FIsIdleExit (void);
  576. #ifdef DEBUG
  577. /*
  578. * DumpIdleTable
  579. *
  580. * Purpose:
  581. * Used for debugging only. Writes information in the PGD(hftgIdle)
  582. * table to COM1.
  583. *
  584. * Parameters:
  585. * none
  586. *
  587. * Returns:
  588. * void
  589. *
  590. */
  591. STDAPI_(void)
  592. DumpIdleTable (void);
  593. #endif
  594. #endif /* ! NOIDLEENGINE */
  595. /* IMalloc Utilities */
  596. STDAPI_(LPMALLOC) MAPIGetDefaultMalloc();
  597. /* StreamOnFile (SOF) */
  598. /*
  599. * Methods and #define's for implementing an OLE 2.0 storage stream
  600. * (as defined in the OLE 2.0 specs) on top of a system file.
  601. */
  602. #define SOF_UNIQUEFILENAME ((ULONG) 0x80000000)
  603. STDMETHODIMP OpenStreamOnFile(
  604. LPALLOCATEBUFFER lpAllocateBuffer,
  605. LPFREEBUFFER lpFreeBuffer,
  606. ULONG ulFlags,
  607. LPTSTR szFileName,
  608. LPTSTR szPrefix,
  609. LPSTREAM FAR * lppStream);
  610. typedef HRESULT (STDMETHODCALLTYPE FAR * LPOPENSTREAMONFILE) (
  611. LPALLOCATEBUFFER lpAllocateBuffer,
  612. LPFREEBUFFER lpFreeBuffer,
  613. ULONG ulFlags,
  614. LPTSTR szFileName,
  615. LPTSTR szPrefix,
  616. LPSTREAM FAR * lppStream);
  617. #ifdef WIN32
  618. #define OPENSTREAMONFILE "OpenStreamOnFile"
  619. #endif
  620. #ifdef WIN16
  621. #define OPENSTREAMONFILE "_OPENSTREAMONFILE"
  622. #endif
  623. /* Property interface utilities */
  624. /*
  625. * Copies a single SPropValue from Src to Dest. Handles all the various
  626. * types of properties and will link its allocations given the master
  627. * allocation object and an allocate more function.
  628. */
  629. STDAPI_(SCODE)
  630. PropCopyMore( LPSPropValue lpSPropValueDest,
  631. LPSPropValue lpSPropValueSrc,
  632. ALLOCATEMORE * lpfAllocMore,
  633. LPVOID lpvObject );
  634. /*
  635. * Returns the size in bytes of structure at lpSPropValue, including the
  636. * Value.
  637. */
  638. STDAPI_(ULONG)
  639. UlPropSize( LPSPropValue lpSPropValue );
  640. STDAPI_(BOOL)
  641. FEqualNames( LPMAPINAMEID lpName1, LPMAPINAMEID lpName2 );
  642. #if defined(WIN32) && !defined(NT) && !defined(CHICAGO) && !defined(_MAC)
  643. #define NT
  644. #endif
  645. STDAPI_(void)
  646. GetInstance(LPSPropValue pvalMv, LPSPropValue pvalSv, ULONG uliInst);
  647. STDAPI_(BOOL)
  648. FRKFindSubpb( LPSPropValue lpSPropValueDst, LPSPropValue lpsPropValueSrc );
  649. extern char rgchCsds[];
  650. extern char rgchCids[];
  651. extern char rgchCsdi[];
  652. extern char rgchCidi[];
  653. STDAPI_(BOOL)
  654. FRKFindSubpsz( LPSPropValue lpSPropValueDst, LPSPropValue lpsPropValueSrc,
  655. ULONG ulFuzzyLevel );
  656. STDAPI_(BOOL)
  657. FPropContainsProp( LPSPropValue lpSPropValueDst,
  658. LPSPropValue lpSPropValueSrc,
  659. ULONG ulFuzzyLevel );
  660. STDAPI_(BOOL)
  661. FPropCompareProp( LPSPropValue lpSPropValue1,
  662. ULONG ulRelOp,
  663. LPSPropValue lpSPropValue2 );
  664. STDAPI_(LONG)
  665. LPropCompareProp( LPSPropValue lpSPropValueA,
  666. LPSPropValue lpSPropValueB );
  667. STDAPI_(HRESULT)
  668. HrAddColumns( LPMAPITABLE lptbl,
  669. LPSPropTagArray lpproptagColumnsNew,
  670. LPALLOCATEBUFFER lpAllocateBuffer,
  671. LPFREEBUFFER lpFreeBuffer);
  672. STDAPI_(HRESULT)
  673. HrAddColumnsEx( LPMAPITABLE lptbl,
  674. LPSPropTagArray lpproptagColumnsNew,
  675. LPALLOCATEBUFFER lpAllocateBuffer,
  676. LPFREEBUFFER lpFreeBuffer,
  677. void (FAR *lpfnFilterColumns)(LPSPropTagArray ptaga));
  678. /* Notification utilities */
  679. /*
  680. * Function that creates an advise sink object given a notification
  681. * callback function and context.
  682. */
  683. STDAPI
  684. HrAllocAdviseSink( LPNOTIFCALLBACK lpfnCallback,
  685. LPVOID lpvContext,
  686. LPMAPIADVISESINK FAR *lppAdviseSink );
  687. /*
  688. * Wraps an existing advise sink with another one which guarantees
  689. * that the original advise sink will be called in the thread on
  690. * which it was created.
  691. */
  692. STDAPI
  693. HrThisThreadAdviseSink( LPMAPIADVISESINK lpAdviseSink,
  694. LPMAPIADVISESINK FAR *lppAdviseSink);
  695. /*
  696. * Structure and functions for maintaining a list of advise sinks,
  697. * together with the keys used to release them.
  698. */
  699. typedef struct
  700. {
  701. LPMAPIADVISESINK lpAdvise;
  702. ULONG ulConnection;
  703. ULONG ulType;
  704. LPUNKNOWN lpParent;
  705. } ADVISEITEM, FAR *LPADVISEITEM;
  706. typedef struct
  707. {
  708. ULONG cItemsMac;
  709. ULONG cItemsMax;
  710. LPMALLOC pmalloc;
  711. #if defined(WIN32) && !defined(MAC)
  712. CRITICAL_SECTION cs;
  713. #endif
  714. ADVISEITEM rgItems[1];
  715. } ADVISELIST, FAR *LPADVISELIST;
  716. #define CbNewADVISELIST(_citems) \
  717. (offsetof(ADVISELIST, rgItems) + (_citems) * sizeof(ADVISEITEM))
  718. #define CbADVISELIST(_plist) \
  719. (offsetof(ADVISELIST, rgItems) + (_plist)->cItemsMax * sizeof(ADVISEITEM))
  720. STDAPI_(SCODE)
  721. ScAddAdviseList( LPMALLOC pmalloc,
  722. LPADVISELIST FAR *lppList,
  723. LPMAPIADVISESINK lpAdvise,
  724. ULONG ulConnection,
  725. ULONG ulType,
  726. LPUNKNOWN lpParent);
  727. STDAPI_(SCODE)
  728. ScDelAdviseList( LPADVISELIST lpList,
  729. ULONG ulConnection);
  730. STDAPI_(SCODE)
  731. ScFindAdviseList( LPADVISELIST lpList,
  732. ULONG ulConnection,
  733. LPADVISEITEM FAR *lppItem);
  734. STDAPI_(void)
  735. DestroyAdviseList( LPADVISELIST FAR *lppList);
  736. /* Service Provider Utilities */
  737. /*
  738. * Structures and utility function for building a display table
  739. * from resources.
  740. */
  741. typedef struct {
  742. ULONG ulCtlType; /* DTCT_LABEL, etc. */
  743. ULONG ulCtlFlags; /* DT_REQUIRED, etc. */
  744. LPBYTE lpbNotif; /* pointer to notification data */
  745. ULONG cbNotif; /* count of bytes of notification data */
  746. LPTSTR lpszFilter; /* character filter for edit/combobox */
  747. ULONG ulItemID; /* to validate parallel dlg template entry */
  748. union { /* ulCtlType discriminates */
  749. LPVOID lpv; /* Initialize this to avoid warnings */
  750. LPDTBLLABEL lplabel;
  751. LPDTBLEDIT lpedit;
  752. LPDTBLLBX lplbx;
  753. LPDTBLCOMBOBOX lpcombobox;
  754. LPDTBLDDLBX lpddlbx;
  755. LPDTBLCHECKBOX lpcheckbox;
  756. LPDTBLGROUPBOX lpgroupbox;
  757. LPDTBLBUTTON lpbutton;
  758. LPDTBLRADIOBUTTON lpradiobutton;
  759. LPDTBLINKEDIT lpinkedit;
  760. LPDTBLMVLISTBOX lpmvlbx;
  761. LPDTBLMVDDLBX lpmvddlbx;
  762. LPDTBLPAGE lppage;
  763. } ctl;
  764. } DTCTL, FAR *LPDTCTL;
  765. typedef struct {
  766. ULONG cctl;
  767. LPTSTR lpszResourceName; /* as usual, may be an integer ID */
  768. union { /* as usual, may be an integer ID */
  769. LPTSTR lpszComponent;
  770. ULONG ulItemID;
  771. };
  772. LPDTCTL lpctl;
  773. } DTPAGE, FAR *LPDTPAGE;
  774. STDAPI
  775. BuildDisplayTable( LPALLOCATEBUFFER lpAllocateBuffer,
  776. LPALLOCATEMORE lpAllocateMore,
  777. LPFREEBUFFER lpFreeBuffer,
  778. LPMALLOC lpMalloc,
  779. HINSTANCE hInstance,
  780. UINT cPages,
  781. LPDTPAGE lpPage,
  782. ULONG ulFlags,
  783. LPMAPITABLE * lppTable,
  784. LPTABLEDATA * lppTblData );
  785. /*
  786. * Function that initializes a progress indicator object. If an
  787. * original indicator object is suppiiied, it is wrapped and the
  788. * new object forwards update calls to the original.
  789. */
  790. STDAPI
  791. WrapProgress( LPMAPIPROGRESS lpProgressOrig,
  792. ULONG ulMin,
  793. ULONG ulMax,
  794. ULONG ulFlags,
  795. LPMAPIPROGRESS FAR *lppProgress );
  796. /* MAPI structure validation/copy utilities */
  797. /*
  798. * Validate, copy, and adjust pointers in MAPI structures:
  799. * notification
  800. * property value array
  801. * option data
  802. */
  803. STDAPI_(SCODE)
  804. ScCountNotifications(int cntf, LPNOTIFICATION rgntf,
  805. ULONG FAR *pcb);
  806. STDAPI_(SCODE)
  807. ScCopyNotifications(int cntf, LPNOTIFICATION rgntf, LPVOID pvDst,
  808. ULONG FAR *pcb);
  809. STDAPI_(SCODE)
  810. ScRelocNotifications(int cntf, LPNOTIFICATION rgntf,
  811. LPVOID pvBaseOld, LPVOID pvBaseNew, ULONG FAR *pcb);
  812. #ifdef MAPISPI_H
  813. STDAPI_(SCODE)
  814. ScCountOptionData(LPOPTIONDATA lpOption, ULONG FAR *pcb);
  815. STDAPI_(SCODE)
  816. ScCopyOptionData(LPOPTIONDATA lpOption, LPVOID pvDst, ULONG FAR *pcb);
  817. STDAPI_(SCODE)
  818. ScRelocOptionData(LPOPTIONDATA lpOption,
  819. LPVOID pvBaseOld, LPVOID pvBaseNew, ULONG FAR *pcb);
  820. #endif /* MAPISPI_H */
  821. STDAPI_(SCODE)
  822. ScCountProps(int cprop, LPSPropValue rgprop, ULONG FAR *pcb);
  823. STDAPI_(LPSPropValue)
  824. LpValFindProp(ULONG ulPropTag, ULONG cprop, LPSPropValue rgprop);
  825. STDAPI_(SCODE)
  826. ScCopyProps(int cprop, LPSPropValue rgprop, LPVOID pvDst,
  827. ULONG FAR *pcb);
  828. STDAPI_(SCODE)
  829. ScRelocProps(int cprop, LPSPropValue rgprop,
  830. LPVOID pvBaseOld, LPVOID pvBaseNew, ULONG FAR *pcb);
  831. STDAPI_(SCODE)
  832. ScDupPropset(int cprop, LPSPropValue rgprop,
  833. LPALLOCATEBUFFER lpAllocateBuffer, LPSPropValue FAR *prgprop);
  834. /* General utility functions */
  835. /* Related to the OLE Component object model */
  836. STDAPI_(ULONG) UlAddRef(LPVOID punk);
  837. STDAPI_(ULONG) UlRelease(LPVOID punk);
  838. /* Related to the MAPI interface */
  839. STDAPI HrGetOneProp(LPMAPIPROP pmp, ULONG ulPropTag,
  840. LPSPropValue FAR *ppprop);
  841. STDAPI HrSetOneProp(LPMAPIPROP pmp, LPSPropValue pprop);
  842. STDAPI_(BOOL) FPropExists(LPMAPIPROP pobj, ULONG ulPropTag);
  843. STDAPI_(LPSPropValue) PpropFindProp(LPSPropValue rgprop, ULONG cprop, ULONG ulPropTag);
  844. STDAPI_(void) FreePadrlist(LPADRLIST padrlist);
  845. STDAPI_(void) FreeProws(LPSRowSet prows);
  846. STDAPI HrQueryAllRows(LPMAPITABLE ptable,
  847. LPSPropTagArray ptaga, LPSRestriction pres,
  848. LPSSortOrderSet psos, LONG crowsMax,
  849. LPSRowSet FAR *pprows);
  850. /* Create or validate the IPM folder tree in a message store */
  851. #define MAPI_FORCE_CREATE 1
  852. #define MAPI_FULL_IPM_TREE 2
  853. STDAPI HrValidateIPMSubtree(LPMDB pmdb, ULONG ulFlags,
  854. ULONG FAR *pcValues, LPSPropValue FAR *prgprop,
  855. LPMAPIERROR FAR *pperr);
  856. /* Encoding and decoding strings */
  857. STDAPI_(BOOL) FBinFromHex(LPTSTR sz, LPBYTE pb);
  858. STDAPI_(SCODE) ScBinFromHexBounded(LPTSTR sz, LPBYTE pb, ULONG cb);
  859. STDAPI_(void) HexFromBin(LPBYTE pb, int cb, LPTSTR sz);
  860. STDAPI_(ULONG) UlFromSzHex(LPCTSTR sz);
  861. STDAPI_(void) EncodeID(LPBYTE, ULONG, LPTSTR);
  862. STDAPI_(BOOL) FDecodeID(LPTSTR, LPBYTE, ULONG *);
  863. STDAPI_(ULONG) CchOfEncoding(ULONG);
  864. STDAPI_(ULONG) CbOfEncoded(LPTSTR);
  865. STDAPI_(int) CchEncodedLine(int);
  866. /* Encoding and decoding entry IDs */
  867. STDAPI HrEntryIDFromSz(LPTSTR sz, ULONG FAR *pcb,
  868. LPENTRYID FAR *ppentry);
  869. STDAPI HrSzFromEntryID(ULONG cb, LPENTRYID pentry,
  870. LPTSTR FAR *psz);
  871. STDAPI HrComposeEID(LPMAPISESSION psession,
  872. ULONG cbStoreSearchKey, LPBYTE pStoreSearchKey,
  873. ULONG cbMsgEID, LPENTRYID pMsgEID,
  874. ULONG FAR *pcbEID, LPENTRYID FAR *ppEID);
  875. STDAPI HrDecomposeEID(LPMAPISESSION psession,
  876. ULONG cbEID, LPENTRYID pEID,
  877. ULONG FAR *pcbStoreEID, LPENTRYID FAR *ppStoreEID,
  878. ULONG FAR *pcbMsgEID, LPENTRYID FAR *ppMsgEID);
  879. STDAPI HrComposeMsgID(LPMAPISESSION psession,
  880. ULONG cbStoreSearchKey, LPBYTE pStoreSearchKey,
  881. ULONG cbMsgEID, LPENTRYID pMsgEID,
  882. LPTSTR FAR *pszMsgID);
  883. STDAPI HrDecomposeMsgID(LPMAPISESSION psession,
  884. LPTSTR szMsgID,
  885. ULONG FAR *pcbStoreEID, LPENTRYID FAR *ppStoreEID,
  886. ULONG FAR *pcbMsgEID, LPENTRYID FAR *ppMsgEID);
  887. /* C runtime substitutes */
  888. typedef int (__cdecl FNSGNCMP)(const void FAR *pv1, const void FAR *pv2);
  889. typedef FNSGNCMP FAR *PFNSGNCMP;
  890. STDAPI_(LPTSTR) SzFindCh(LPCTSTR sz, USHORT ch); /* strchr */
  891. STDAPI_(LPTSTR) SzFindLastCh(LPCTSTR sz, USHORT ch); /* strrchr */
  892. STDAPI_(LPTSTR) SzFindSz(LPCTSTR sz, LPCTSTR szKey);
  893. STDAPI_(unsigned int) UFromSz(LPCTSTR sz); /* atoi */
  894. STDAPI_(void) ShellSort(LPVOID pv, UINT cv, /* qsort */
  895. LPVOID pvT, UINT cb, PFNSGNCMP fpCmp);
  896. FNSGNCMP SgnCmpPadrentryByType;
  897. STDAPI_(SCODE) ScUNCFromLocalPath(LPSTR szLocal, LPSTR szUNC,
  898. UINT cchUNC);
  899. STDAPI_(SCODE) ScLocalPathFromUNC(LPSTR szUNC, LPSTR szLocal,
  900. UINT cchLocal);
  901. /* 64-bit arithmetic with times */
  902. STDAPI_(FILETIME) FtAddFt(FILETIME Addend1, FILETIME Addend2);
  903. STDAPI_(FILETIME) FtMulDwDw(DWORD Multiplicand, DWORD Multiplier);
  904. STDAPI_(FILETIME) FtMulDw(DWORD Multiplier, FILETIME Multiplicand);
  905. STDAPI_(FILETIME) FtSubFt(FILETIME Minuend, FILETIME Subtrahend);
  906. STDAPI_(FILETIME) FtNegFt(FILETIME ft);
  907. STDAPI WrapStoreEntryID (ULONG ulFlags, LPTSTR szDLLName, ULONG cbOrigEntry,
  908. LPENTRYID lpOrigEntry, ULONG *lpcbWrappedEntry, LPENTRYID *lppWrappedEntry);
  909. /* RTF Sync Utilities */
  910. #define RTF_SYNC_RTF_CHANGED ((ULONG) 0x00000001)
  911. #define RTF_SYNC_BODY_CHANGED ((ULONG) 0x00000002)
  912. STDAPI_(HRESULT)
  913. RTFSync (LPMESSAGE lpMessage, ULONG ulFlags, BOOL FAR * lpfMessageUpdated);
  914. STDAPI_(HRESULT)
  915. WrapCompressedRTFStream (LPSTREAM lpCompressedRTFStream,
  916. ULONG ulFlags, LPSTREAM FAR * lpUncompressedRTFStream);
  917. /* Storage on Stream */
  918. #if defined(WIN32) || defined(WIN16)
  919. STDAPI_(HRESULT)
  920. HrIStorageFromStream (LPUNKNOWN lpUnkIn,
  921. LPCIID lpInterface, ULONG ulFlags, LPSTORAGE FAR * lppStorageOut);
  922. #endif
  923. #ifdef __cplusplus
  924. }
  925. #endif
  926. #endif /* _MAPIUTIL_H_ */