FileHC.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:24k
源码类别:

模拟服务器

开发平台:

C/C++

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