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.

891 lines
24 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name:
  4. FILEHC.H
  5. Abstract:
  6. This file defines the public interfaces for issuing async
  7. Reads/Writes to a file using the fcache wrapper library.
  8. --*/
  9. #ifndef _FILEHC_H_
  10. #define _FILEHC_H_
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. typedef VOID
  15. (*PFN_IO_COMPLETION)(
  16. IN struct FIO_CONTEXT* pContext,
  17. IN struct FH_OVERLAPPED* lpo,
  18. IN DWORD cb,
  19. IN DWORD dwCompletionStatus
  20. );
  21. struct FH_OVERLAPPED {
  22. /*++
  23. This structure defines the extended OVERLAPPED structure
  24. used by the File IO layer implemented in this module.
  25. The first 5 elements of this structure are identical to
  26. NT's OVERLAPPED structure and have the exact same semantics.
  27. The final additional parameter is a pointer to a
  28. function that will be called to complete the IO.
  29. --*/
  30. UINT_PTR Internal ;
  31. UINT_PTR InternalHigh ;
  32. DWORD Offset ;
  33. DWORD OffsetHigh ;
  34. HANDLE hEvent ;
  35. PFN_IO_COMPLETION pfnCompletion ;
  36. UINT_PTR Reserved1 ;
  37. UINT_PTR Reserved2 ;
  38. UINT_PTR Reserved3 ;
  39. UINT_PTR Reserved4 ;
  40. } ;
  41. typedef struct FH_OVERLAPPED* PFH_OVERLAPPED ;
  42. struct FIO_CONTEXT {
  43. /*++
  44. This structure defines the context object
  45. that is used to represent file handles.
  46. --*/
  47. //
  48. // Temporary hack - mailmsg object assumes it can put a NULL in us !
  49. //
  50. DWORD m_dwTempHack ;
  51. //
  52. // The context signature !
  53. //
  54. DWORD m_dwSignature ;
  55. //
  56. // The users file handle !
  57. //
  58. HANDLE m_hFile ;
  59. //
  60. // The offset to back fill Lines header - nntp aware only
  61. //
  62. DWORD m_dwLinesOffset;
  63. //
  64. // Header length - nntp aware only
  65. //
  66. DWORD m_dwHeaderLength;
  67. } ;
  68. typedef FIO_CONTEXT* PFIO_CONTEXT ;
  69. #ifdef _FILEHC_IMPLEMENTATION_
  70. #define FILEHC_EXPORT __declspec( dllexport )
  71. #else
  72. #define FILEHC_EXPORT __declspec( dllimport )
  73. #endif
  74. //
  75. // Initialize the DLL for Async IO -
  76. // This is a counting initialize - for each call to FIOInitialize()
  77. // there should be a matching call to FIOTerminate
  78. //
  79. FILEHC_EXPORT
  80. BOOL __stdcall
  81. FIOInitialize(
  82. IN DWORD dwFlags
  83. );
  84. //
  85. // Terminate the DLL's support for Async IO !
  86. //
  87. FILEHC_EXPORT
  88. BOOL __stdcall
  89. FIOTerminate(
  90. VOID
  91. );
  92. //
  93. // Do an async read against the File !
  94. //
  95. FILEHC_EXPORT
  96. BOOL __stdcall
  97. FIOReadFile(
  98. IN PFIO_CONTEXT pContext,
  99. IN LPVOID lpBuffer,
  100. IN DWORD BytesToRead,
  101. IN FH_OVERLAPPED * lpo
  102. );
  103. //
  104. // Do an async read against the file - pass extra args
  105. // so that if the FIO_CONTEXT is doing dot stuffing for the user
  106. // it can do so efficiently !
  107. //
  108. FILEHC_EXPORT
  109. BOOL __stdcall
  110. FIOReadFileEx(
  111. IN PFIO_CONTEXT pContext,
  112. IN LPVOID lpBuffer,
  113. IN DWORD BytesToRead,
  114. IN DWORD BytesAvailable, // must be >= BytesToWrite - number of bytes I can mess with.
  115. IN FH_OVERLAPPED * lpo,
  116. IN BOOL fFinalWrite, // Is this the final write ?
  117. IN BOOL fIncludeTerminator // if TRUE contains CRLF.CRLF terminator which shouldn't be stuffed
  118. );
  119. //
  120. // Do an async write against the file !
  121. //
  122. FILEHC_EXPORT
  123. BOOL __stdcall
  124. FIOWriteFile(
  125. IN PFIO_CONTEXT pContext,
  126. IN LPCVOID lpBuffer,
  127. IN DWORD BytesToWrite,
  128. IN FH_OVERLAPPED * lpo
  129. );
  130. //
  131. // Do an async write against the file - pass extra args
  132. // so that if the FIO_CONTEXT is doing dot stuffing for the user
  133. // it can do so efficiently !
  134. //
  135. FILEHC_EXPORT
  136. BOOL __stdcall
  137. FIOWriteFileEx(
  138. IN PFIO_CONTEXT pContext,
  139. IN LPVOID lpBuffer,
  140. IN DWORD BytesToWrite,
  141. IN DWORD BytesAvailable, // must be >= BytesToWrite - number of bytes I can mess with.
  142. IN FH_OVERLAPPED* lpo,
  143. IN BOOL fFinalWrite, // Is this the final write ?
  144. IN BOOL fIncludeTerminator // if TRUE contains CRLF.CRLF terminator which shouldn't be stuffed
  145. ) ;
  146. //
  147. // Callback functions which create things in the cache !
  148. //
  149. // NOTE: this is equivalent to FCACHE_RICHCREATE_CALLBACK where
  150. //
  151. // pfDidWeScanIt - returns FALSE
  152. // pfIsStuffed - return FALSE
  153. // pfStoredWithDots - return FALSE
  154. //
  155. typedef
  156. HANDLE
  157. (__stdcall *FCACHE_CREATE_CALLBACK) (
  158. IN LPSTR lpstrName,
  159. IN LPVOID lpvData,
  160. OUT DWORD* cbFileSize,
  161. OUT DWORD* cbFileSizeHigh
  162. ) ;
  163. //
  164. // Callback functions which create things in the cache !
  165. //
  166. // This function will be called by CacheRichCreateFile().
  167. //
  168. // lpstrName - the name of the file
  169. // lpvData - User provided data, provided to CacheRichCreateFile
  170. // cbFileSize - The function should return the size of the file through this
  171. // cbFileSizeHigh - place to return the High DWORD of the file size
  172. // pfDidWeScanIt - if THIS is true then at some point the created file has been
  173. // scanned for DOTs appearing at the beginning of lines
  174. // pfIsStuffed - This is only meaningfull if pfDidWeScanIt==TRUE, in which case
  175. // if this is TRUE this indicates that there are DOTs at the beginning of lines
  176. // pfStoredWithDots - If this is TRUE then it indicates that any DOTs that appear
  177. // at the beginning of lines are stored with an extra dot as required in NNTP,
  178. // SMTP and POP3 protocols. if this is FALSE then the message is stored without
  179. // DOT stuffing.
  180. //
  181. typedef
  182. HANDLE
  183. (__stdcall *FCACHE_RICHCREATE_CALLBACK) (
  184. IN LPSTR lpstrName,
  185. IN LPVOID lpvData,
  186. OUT DWORD* cbFileSize,
  187. OUT DWORD* cbFileSizeHigh,
  188. OUT BOOL* pfDidWeScanIt,
  189. OUT BOOL* pfIsStuffed,
  190. OUT BOOL* pfStoredWithDots,
  191. OUT BOOL* pfStoredWithTerminatingDot
  192. ) ;
  193. //
  194. // Initialize the File Handle Cache -
  195. //
  196. // NOTE : this will automatically initialize the DLL for async
  197. // IO as well !
  198. //
  199. FILEHC_EXPORT
  200. BOOL __stdcall
  201. InitializeCache() ;
  202. //
  203. // Terminate the cache !
  204. //
  205. // NOTE : this will terminate the DLL for async IO as well !
  206. //
  207. FILEHC_EXPORT
  208. BOOL __stdcall
  209. TerminateCache() ;
  210. //
  211. // Associate a file with an async context !
  212. //
  213. FILEHC_EXPORT
  214. PFIO_CONTEXT __stdcall
  215. AssociateFile( HANDLE hFile ) ;
  216. //
  217. // This allows the user to specify whether file stores content with extra DOTS
  218. // added for RFC 822 protocols (i.e. NNTP and SMTP DATA commands).
  219. //
  220. // NOTE: AssociateFile() is the same as AssociateFileEx( hFile, FALSE ) ;
  221. //
  222. // hFile - The file that contains message content, or in which we will write message content
  223. // fStoreWithDots - if TRUE then each period or DOT in the file which starts a line
  224. // but is NOT part of the terminating CRLF.CRLF will be stored with an extra dot
  225. // adjacent to it. This is the on the wire format for NNTP for instance.
  226. //
  227. FILEHC_EXPORT
  228. PFIO_CONTEXT __stdcall
  229. AssociateFileEx( HANDLE hFile,
  230. BOOL fStoreWithDots,
  231. BOOL fStoredWithTerminatingDot
  232. ) ;
  233. //
  234. // Add a reference to a context -
  235. //
  236. // Each call to AddRefContext() must be matched by a corresponding
  237. // call to ReleaseContext(). Both AssociateFile and CacheCreateFile()
  238. // also add a single reference which must be matched by a call to ReleaseContext().
  239. //
  240. FILEHC_EXPORT
  241. void __stdcall
  242. AddRefContext( PFIO_CONTEXT ) ;
  243. //
  244. // Release a Context !
  245. //
  246. // FIO_CONTEXT's are reference counted - the user must call
  247. // this for each successfull call to CacheCreateFile(), and
  248. // each call to InsertFile() where fKeepReference is TRUE
  249. //
  250. FILEHC_EXPORT
  251. void __stdcall
  252. ReleaseContext( PFIO_CONTEXT ) ;
  253. //
  254. // Close a handle associated with a non-cached FIO_CONTEXT
  255. //
  256. // This is used to Close the file handle within a context.
  257. // This only succeeds if the FIO_CONTEXT is not cached !
  258. //
  259. FILEHC_EXPORT
  260. BOOL __stdcall
  261. CloseNonCachedFile( PFIO_CONTEXT ) ;
  262. //
  263. // Create a file in the cache, or find an existing one !
  264. //
  265. // If the file is not in the cache, the cache will call
  266. // pfnCallBack with lpv to do the actual work of calling
  267. // CreateFile().
  268. //
  269. FILEHC_EXPORT
  270. FIO_CONTEXT* __stdcall
  271. CacheCreateFile( IN LPSTR lpstrName,
  272. IN FCACHE_CREATE_CALLBACK pfnCallBack,
  273. IN LPVOID lpv,
  274. IN BOOL fAsyncContext
  275. ) ;
  276. //
  277. // Create a file in the cache or find an existing one,
  278. // if we create the file we can add properties onto it in
  279. // the cache !
  280. //
  281. FILEHC_EXPORT
  282. FIO_CONTEXT* __stdcall
  283. CacheRichCreateFile( IN LPSTR lpstrName,
  284. IN FCACHE_RICHCREATE_CALLBACK pfnCallBack,
  285. IN LPVOID lpv,
  286. IN BOOL fAsyncContext
  287. ) ;
  288. //
  289. // This function allows a user to remove all files with the specified
  290. // Name from the cache. if fAllPrefixes is TRUE, we will remove all files
  291. // where the Name matches the beginning of the path !
  292. // If fAllPrefixes is FALSE then we will remove only the one file which
  293. // exactly matches lpstrName !
  294. //
  295. FILEHC_EXPORT
  296. void __stdcall
  297. CacheRemoveFiles( IN LPSTR lpstrName,
  298. IN BOOL fAllPrefixes
  299. ) ;
  300. //
  301. // Insert the file into the cache !
  302. //
  303. // This function will add the file handle in the FIO_CONTEXT
  304. // to the cache. All searches by lpstrName will find this
  305. // item untill it expires from the cache.
  306. //
  307. // If fKeepReference is TRUE then the user must make a call to
  308. // ReleaseContext() for the inserted FIO_CONTEXT !
  309. //
  310. FILEHC_EXPORT
  311. BOOL __stdcall
  312. InsertFile( IN LPSTR lpstrName,
  313. IN FIO_CONTEXT* pContext,
  314. IN BOOL fKeepReference
  315. ) ;
  316. //
  317. // Report the file size that we've cached with the handle
  318. //
  319. FILEHC_EXPORT
  320. DWORD __stdcall
  321. GetFileSizeFromContext( IN FIO_CONTEXT* pContext,
  322. OUT DWORD* pcbFileSizeHigh
  323. ) ;
  324. //----------------------------------------------------------------------
  325. // NAME CACHE NAME CACHE NAME CACHE -
  326. //
  327. // Name Cache API's
  328. //
  329. //
  330. //
  331. // This is the function pointer provided by clients to compare
  332. // keys. This must be provided on all calls.
  333. //
  334. // The function has memcmp() semantics, i.e. it must order the keys
  335. // consistently, and return <0 if key1 is smaller then key2, ==0 if the
  336. // keys match and >0 if key1 is greater then key2.
  337. //
  338. typedef
  339. int
  340. (__stdcall *CACHE_KEY_COMPARE)( IN DWORD cbKey1,
  341. IN LPBYTE lpbKey1,
  342. IN DWORD cbKey2,
  343. IN LPBYTE lpbKey2
  344. ) ;
  345. //
  346. // This is the function provided by clients to compute a hash
  347. // value on Keys - NOTE: The Cache will provide a hash function
  348. // IF the user does not, however the internally provided hash
  349. // function is best only for things that appear to be regular strings.
  350. //
  351. typedef
  352. DWORD
  353. (__stdcall *CACHE_KEY_HASH)( IN LPBYTE lpbKey,
  354. IN DWORD cbKey
  355. ) ;
  356. //
  357. // This is the generic callback function that is provided to the
  358. // cache to help examine items within the cache.
  359. // The BOOL return value is meaningfull to the Cache API's only
  360. // on the following calls :
  361. //
  362. //
  363. typedef
  364. BOOL
  365. (__stdcall *CACHE_READ_CALLBACK)( IN DWORD cb,
  366. IN LPBYTE lpb,
  367. IN LPVOID lpvContext
  368. ) ;
  369. //
  370. // This is a callback that is called whenever we destroy an entry in
  371. // the name cache - this is called once for both key and data components,
  372. // and gives the client a chance to track any relationships
  373. //
  374. // NOTE : if the client does not associate
  375. // data with the name, the function will only be called for the Key data.
  376. //
  377. typedef
  378. void
  379. (__stdcall *CACHE_DESTROY_CALLBACK)( IN DWORD cb,
  380. IN LPBYTE lpb
  381. ) ;
  382. //
  383. // This is a callback this is called whenever we evaluate a security descriptor.
  384. // If it is not provided we will call the standard NT AccessCheck() call !
  385. //
  386. // The function has the same signature as AccessCheck, however there are arguments
  387. // we don't use - PrivilegeSet will always be NULL and PrivilegeSetLength will always be 0 !
  388. //
  389. typedef
  390. BOOL
  391. (WINAPI *CACHE_ACCESS_CHECK)( IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  392. IN HANDLE hClientToken,
  393. IN DWORD dwDesiredAccess,
  394. IN PGENERIC_MAPPING GenericMapping,
  395. IN PRIVILEGE_SET* PrivilegeSet,
  396. IN LPDWORD PrivilegeSetLength,
  397. IN LPDWORD GrantedAccess,
  398. IN LPBOOL AccessStatus
  399. ) ;
  400. //
  401. // This is the externally exposed structure representing a Name Cache -
  402. // it doesn't contain any fields usefull for a client, but must be passed
  403. // back into all of the name cache API's
  404. //
  405. struct NAME_CACHE_CONTEXT {
  406. //
  407. // Signature DWORD ! - user must not touch this !
  408. //
  409. DWORD m_dwSignature ;
  410. } ;
  411. typedef struct NAME_CACHE_CONTEXT* PNAME_CACHE_CONTEXT ;
  412. //
  413. // API's for creating/manging NAME CACHE's
  414. // NOTE : Name Cache's are reference counted, and if this
  415. // function is called twice with the same name we will
  416. // Add a reference to an existing Name Cache.
  417. //
  418. FILEHC_EXPORT
  419. PNAME_CACHE_CONTEXT __stdcall
  420. FindOrCreateNameCache(
  421. //
  422. // Must not be NULL ! - this is CASE SENSITVE !
  423. //
  424. LPSTR lpstrName,
  425. //
  426. // Must not be NULL !
  427. //
  428. CACHE_KEY_COMPARE pfnKeyCompare,
  429. //
  430. // This may be NULL, in which case the cache will provide one !
  431. //
  432. CACHE_KEY_HASH pfnKeyHash,
  433. //
  434. // The following two function pointers may be NULL !
  435. //
  436. CACHE_DESTROY_CALLBACK pfnKeyDestroy,
  437. CACHE_DESTROY_CALLBACK pfnDataDestroy
  438. ) ;
  439. //
  440. // API's for releasing the NAME CACHE !
  441. //
  442. // The caller must guarantee the thread safety of this call - This function must not
  443. // be called if any other thread is simultanesouly executing within
  444. // CacheFindContectFromName(), AssociateContextWithName(), AssociateDataWithName(), or InvalidateName()
  445. //
  446. FILEHC_EXPORT
  447. long __stdcall
  448. ReleaseNameCache(
  449. //
  450. // Must not be NULL !
  451. //
  452. PNAME_CACHE_CONTEXT pNameCache
  453. ) ;
  454. //
  455. // API's for setting options on the name cache - this can be used to change
  456. // how Security is evaluated !
  457. //
  458. FILEHC_EXPORT
  459. BOOL __stdcall
  460. SetNameCacheSecurityFunction(
  461. //
  462. // Must not be NULL !
  463. //
  464. PNAME_CACHE_CONTEXT pNameCache,
  465. //
  466. // This is the function pointer that will be used to evaluate security -
  467. // this may be NULL - if it is we will use the Win32 Access Check !
  468. //
  469. CACHE_ACCESS_CHECK pfnAccessCheck
  470. ) ;
  471. //
  472. // Find the FIO_CONTEXT that is associated with some user name.
  473. //
  474. // The function returns TRUE if the Name was found in the cache.
  475. // FALSE if the name was not found in the cache.
  476. //
  477. // If the function returns FALSE then the pfnCallback function will not be
  478. // called.
  479. //
  480. // If the function returns TRUE, ppFIOContext may return a NULL pointer,
  481. // if the user passed a NULL FIO_CONTEXT to AssociateContextWithName() !
  482. //
  483. //
  484. FILEHC_EXPORT
  485. BOOL __stdcall
  486. FindContextFromName(
  487. //
  488. // The name cache the client wishes to use !
  489. //
  490. PNAME_CACHE_CONTEXT pNameCache,
  491. //
  492. // User provides arbitrary bytes for Key to the cache item - pfnKeyCompare() used
  493. // to compare keys !
  494. //
  495. IN LPBYTE lpbName,
  496. IN DWORD cbName,
  497. //
  498. // User provides function which is called with the key once the key comparison
  499. // matches the key. This lets the user do some extra checking that they're getting
  500. // what they want.
  501. //
  502. IN CACHE_READ_CALLBACK pfnCallback,
  503. IN LPVOID lpvClientContext,
  504. //
  505. // Ask the cache to evaluate the embedded security descriptor
  506. // if hToken is 0 then we ignore and security descriptor data
  507. //
  508. IN HANDLE hToken,
  509. IN ACCESS_MASK accessMask,
  510. //
  511. // We have a separate mechanism for returning the FIO_CONTEXT
  512. // from the cache.
  513. //
  514. OUT FIO_CONTEXT** ppContext
  515. ) ;
  516. //
  517. // Find the FIO_CONTEXT that is associated with some user name.
  518. //
  519. // The function returns TRUE if the Name was found in the cache.
  520. // FALSE if the name was not found in the cache.
  521. //
  522. // If the function returns FALSE then the pfnCallback function will not be
  523. // called.
  524. //
  525. // If the function returns TRUE, ppFIOContext may return a NULL pointer,
  526. // if the user passed a NULL FIO_CONTEXT to AssociateContextWithName() !
  527. //
  528. //
  529. FILEHC_EXPORT
  530. BOOL __stdcall
  531. FindSyncContextFromName(
  532. //
  533. // The name cache the client wishes to use !
  534. //
  535. PNAME_CACHE_CONTEXT pNameCache,
  536. //
  537. // User provides arbitrary bytes for Key to the cache item - pfnKeyCompare() used
  538. // to compare keys !
  539. //
  540. IN LPBYTE lpbName,
  541. IN DWORD cbName,
  542. //
  543. // User provides function which is called with the key once the key comparison
  544. // matches the key. This lets the user do some extra checking that they're getting
  545. // what they want.
  546. //
  547. IN CACHE_READ_CALLBACK pfnCallback,
  548. IN LPVOID lpvClientContext,
  549. //
  550. // Ask the cache to evaluate the embedded security descriptor
  551. // if hToken is 0 then we ignore and security descriptor data
  552. //
  553. IN HANDLE hToken,
  554. IN ACCESS_MASK accessMask,
  555. //
  556. // We have a separate mechanism for returning the FIO_CONTEXT
  557. // from the cache.
  558. //
  559. OUT FIO_CONTEXT** ppContext
  560. ) ;
  561. //
  562. // Cache Associate context with name !
  563. // This insert a Name into the Name cache, that will find the specified FIO_CONTEXT !
  564. //
  565. // If the name is already present in the cache, this will fail with GetLastError()==ERROR_DUP_NAME !
  566. //
  567. FILEHC_EXPORT
  568. BOOL __stdcall
  569. AssociateContextWithName(
  570. //
  571. // The name cache the client wishes to use !
  572. //
  573. PNAME_CACHE_CONTEXT pNameCache,
  574. //
  575. // User provides arbitrary bytes for the Name of the cache item.
  576. //
  577. IN LPBYTE lpbName,
  578. IN DWORD cbName,
  579. //
  580. // User may provide some arbitrary data to assoicate with the name !
  581. //
  582. IN LPBYTE lpbData,
  583. IN DWORD cbData,
  584. //
  585. // User may provide a self relative security descriptor to
  586. // be associated with the name !
  587. //
  588. IN PGENERIC_MAPPING pGenericMapping,
  589. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  590. //
  591. // User provides the FIO_CONTEXT that the name should reference
  592. //
  593. FIO_CONTEXT* pContext,
  594. //
  595. // User specifies whether they wish to keep their reference on the FIO_CONTEXT
  596. //
  597. BOOL fKeepReference
  598. ) ;
  599. //
  600. // This function allows the user to remove a single name and all associated data
  601. // from the name cache.
  602. //
  603. FILEHC_EXPORT
  604. BOOL
  605. InvalidateName(
  606. //
  607. // The name cache the client wishes to use !
  608. //
  609. PNAME_CACHE_CONTEXT pNameCache,
  610. //
  611. // User provides arbitrary bytes for the Name of the cache item.
  612. //
  613. IN LPBYTE lpbName,
  614. IN DWORD cbName
  615. ) ;
  616. //
  617. // End of Name Cache API's
  618. //----------------------------------------------------------------------------------
  619. //----------------------------------------------------------------------------------
  620. // DOT STUFFING API's
  621. //
  622. //
  623. // This function gets an FIO_CONTEXT with the requested state.
  624. // We may or may not create a new FIO_CONTEXT, if we do create one we'll stick
  625. // it into the cache so it can be used again !
  626. // NOTE: if we have to do work, the user has the only reference to the resulting
  627. // FIO_CONTEXT which will go away when they call ReleaseContext() !
  628. //
  629. // pContext - the original FIO_CONTEXT
  630. // lpstrName - the file name associated with pContext
  631. // fWantItDotStuffed - if TRUE the resulting FIO_CONTEXT should be dot stuffed !
  632. // fTerminatorIncluded - if this is TRUE the source FIO_CONTEXT contains a terminating
  633. // dot that we should be carefull not to stuff !
  634. //
  635. // NOTE: We may return the same FIO_CONTEXT as the caller provided - in which case
  636. // an extra reference has been added that needs to be dropped with ReleaseContext() !
  637. //
  638. //
  639. FILEHC_EXPORT
  640. FIO_CONTEXT* __stdcall
  641. ProduceDotStuffedContext( IN FIO_CONTEXT* pContext,
  642. IN LPSTR lpstrName,
  643. IN BOOL fWantItDotStuffed // if TRUE add dots, if FALSE remove dots
  644. ) ;
  645. //
  646. // This function takes a source FIO_CONTEXT (pContextSource) and copies
  647. // the content into pContextDestination.
  648. //
  649. // The user specifies whether the Destination FIO_CONTEXT should be dot stuffed
  650. // with fWantItDotStuffed, and whether the source FIO_CONTEXT includes the
  651. // terminating CRLF.CRLF
  652. //
  653. // The out parameter pfModified is TRUE if there were modifications when
  654. // Source was copied to Destination !
  655. //
  656. // The function returns TRUE if successfull, FALSE otherwise !
  657. //
  658. FILEHC_EXPORT
  659. BOOL __stdcall
  660. ProduceDotStuffedContextInContext(
  661. IN FIO_CONTEXT* pContextSource,
  662. IN FIO_CONTEXT* pContextDestination,
  663. IN BOOL fWantItDotStuffed,
  664. OUT BOOL* pfModified
  665. ) ;
  666. //
  667. // Find out whether the file has a terminating 'CRLF.CRLF' sequence !
  668. //
  669. FILEHC_EXPORT
  670. BOOL __stdcall
  671. GetIsFileDotTerminated( IN FIO_CONTEXT* pContext ) ;
  672. //
  673. // Set whether the file has a terminating 'CRLF.CRLF' sequence !
  674. //
  675. FILEHC_EXPORT
  676. void __stdcall
  677. SetIsFileDotTerminated( IN FIO_CONTEXT* pContext,
  678. IN BOOL fIsDotTerminated
  679. ) ;
  680. //
  681. // Enable dot stuffing properties on the write path of the file
  682. // handle cache of this message !
  683. //
  684. // if fEnable is FALSE then all dot stuffing behaviour is turned
  685. // off.
  686. //
  687. // if fStripDots is TRUE the File Handle Cache will convert
  688. // occurrences of "\r\n." to "\r\n" within your message.
  689. //
  690. // if fStripDots is FALSE the FileHandle Cache will convert occurrences
  691. // of "\r\n.." to "\r\n" within your message.
  692. //
  693. //
  694. FILEHC_EXPORT
  695. BOOL __stdcall
  696. SetDotStuffingOnWrites( IN FIO_CONTEXT* pContext,
  697. //
  698. // fEnable == FALSE means ignore fStripDots, and writes are unmodified
  699. //
  700. IN BOOL fEnable,
  701. //
  702. // fStripDots == TRUE means we remove dots that are dot stuffed,
  703. // fStripDots == FALSE means that we add dots to make the message dot stuffed
  704. //
  705. IN BOOL fStripDots
  706. ) ;
  707. #if 0
  708. //
  709. // This function temporarily disabled !
  710. //
  711. FILEHC_EXPORT
  712. BOOL __stdcall
  713. SetDotStuffingOnReads( IN FIO_CONTEXT* pContext,
  714. IN BOOL fEnable,
  715. IN BOOL fStripDots
  716. ) ;
  717. #endif
  718. //
  719. // Enable dot scanning properties on the write path
  720. // of the file handle cache for this file !
  721. //
  722. // if fEnable is TRUE the we will examine each write
  723. // that goes through us to determine whether the
  724. // message has any occurrences of "\r\n.".
  725. //
  726. FILEHC_EXPORT
  727. BOOL __stdcall
  728. SetDotScanningOnWrites( IN FIO_CONTEXT* pContext,
  729. IN BOOL fEnable
  730. ) ;
  731. //
  732. //
  733. // This function should be called when we have finished doing all writes to an FIO_CONTEXT
  734. // This function should be paired with SetDotStuffingOnWrites() and the fStripDots
  735. // parameter should be the same as when SetDotStuffingOnWrites() was called.
  736. //
  737. // We will update the Dot Stuffing State of the FIO_CONTEXT and discard
  738. // all dot stuffing memory and stuff that may have been required !
  739. //
  740. // If this function call is paired with a call to SetDotScanningOnWrites() fStripDots should be TRUE !
  741. //
  742. FILEHC_EXPORT
  743. void __stdcall
  744. CompleteDotStuffingOnWrites( IN FIO_CONTEXT* pContext,
  745. IN BOOL fStripDots
  746. ) ;
  747. //
  748. // This will cause us to examine each read for occurrences of
  749. // "\r\n."
  750. //
  751. // NOTE : the user must use ASYNC Reads for this to work - we will assert
  752. // if the user tries to pend any synchronous reads while we are in this state !
  753. //
  754. FILEHC_EXPORT
  755. BOOL __stdcall
  756. SetDotScanningOnReads( IN FIO_CONTEXT* pContext,
  757. IN BOOL fEnable
  758. ) ;
  759. //
  760. // If any of the dot stuffing mechanism our turned on,
  761. // this will get a count of the number of occurrences/modifications
  762. // have occurred.
  763. //
  764. // if fReads is TRUE we get the count for occurrences on Read's
  765. // if fReads is FALSE we get the count for occurrences on Write's
  766. //
  767. // if dot stuffing was turned off or not enabled somehow then
  768. // GetDotStuffState() will return FALSE.
  769. //
  770. // NOTE: A NULL pfStuffed is not allowed !
  771. //
  772. FILEHC_EXPORT
  773. BOOL __stdcall
  774. GetDotStuffState( IN FIO_CONTEXT* pContext,
  775. IN BOOL fReads,
  776. OUT BOOL* pfStuffed,
  777. OUT BOOL* pfStoredWithDots
  778. ) ;
  779. //
  780. // In this case we always assume that the FIO_CONTEXT is not going to be dot stuffed.
  781. // fRequiresStuffing == TRUE indicates that it SHOULD BE stuffed.
  782. // fRequiresStuffing == FALSE indicates that the message does not need dot stuffing.
  783. //
  784. FILEHC_EXPORT
  785. void __stdcall
  786. SetDotStuffState( IN FIO_CONTEXT* pContext,
  787. //
  788. // fIsStuffed is only relevant when fKnown == TRUE
  789. //
  790. IN BOOL fKnown, // We do know the dot stuff state
  791. //
  792. // if fKnown is TRUE then fIsStuffed is meaningfull, when thats the case
  793. // if fIsStuffed is TRUE then the message
  794. //
  795. IN BOOL fRequiresStuffing// if fKnown is TRUE this arg is meaningfull
  796. ) ;
  797. #ifdef __cplusplus
  798. }
  799. #endif
  800. #endif // _FILEHC_H_