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.

152 lines
4.4 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name :
  4. igateway.hxx
  5. Abstract:
  6. This module declares functions and objects for Internet services
  7. related gateway calls.
  8. Author:
  9. Murali R. Krishnan ( MuraliK ) Jan-25-1995
  10. Environment:
  11. User mode -- Win32
  12. Project:
  13. Internet Services Common DLL
  14. Revision History:
  15. --*/
  16. # ifndef _IGATEWAY_HXX_
  17. # define _IGATEWAY_HXX_
  18. /************************************************************
  19. * Include Headers
  20. ************************************************************/
  21. # include "buffer.hxx"
  22. # include "string.hxx"
  23. /************************************************************
  24. * Type Definitions
  25. ************************************************************/
  26. /*++
  27. The gateway callback function is called whenever data is read from the
  28. gateway process. The function includes supplied context information and
  29. error code for any errors.
  30. The error code is NO_ERROR if there is valid data read.
  31. The data buffer ( pDataBuffer) is the data buffer supplied as
  32. pbDataFromGateway in the IGATEWAY_REQUEST to TsProcessGatewayRequest().
  33. If there is a premature failure in data transfer from gateway process,
  34. this function will get ERROR_BROKEN_PIPE. This is usually the error code
  35. that is sent at the end after gateway process has finished sending all
  36. o/p and closes the output handle.
  37. If there are any other internal error, it will also be returned.
  38. Generally the call-back function should be responsible for cleanup action
  39. or destroying the context information itself at the end when it
  40. gets an error code other than NO_ERROR.
  41. The IO thread will cease to exist after the callback.
  42. If there are any errors in the processing stage of callback,
  43. then the callback function can perform the cleanup of client context
  44. and notify the io thread by returning FALSE. In which case the thread
  45. performs its own cleanup and winds up. Also the error code can
  46. be recived using GetLastError();
  47. --*/
  48. typedef BOOL
  49. ( * PFN_IGATEWAY_READ_CALLBACK)
  50. ( IN PVOID pClientContext, // context provided by gateway invoker
  51. IN DWORD dwError, // error code for any errors
  52. IN PBYTE pDataBuffer, // data read from gateway
  53. IN DWORD cbData); // count of bytes read
  54. typedef struct _IGATEWAY_REQUEST {
  55. HANDLE hUserToken;
  56. LPCSTR pszCmdLine;
  57. LPCSTR pszWorkingDir;
  58. LPVOID lpvEnvironment;
  59. LPBYTE pbDataToGateway; // user supplied data to be sent
  60. DWORD cbDataToGateway; // number of bytes to be sent
  61. } IGATEWAY_REQUEST, * PIGATEWAY_REQUEST;
  62. /*++
  63. TsProcessGatewayRequest()
  64. Description:
  65. This function creates a gateway processor object responsible for processing
  66. gateway requests. It extracts the parameters required from input request
  67. package ( IGATEWAY_REQUEST structure). It creates a separate process for
  68. gateway request and a separate thread for handling I/O for the
  69. gateway request. The thread uses buffers supplied for i/o in pigRequest.
  70. On a completion of read, the thread calls the callback function for
  71. processing the data retrieved. If the call back function returns any error
  72. further procecssing in the thread is halted and the thread dies.
  73. The process also will eventually die, since the pipes are broken.
  74. Arguments:
  75. pClientContext context information supplied by client
  76. pigRequest pointer to IGATEWAY_REQUEST object.
  77. pfnReadCallBack pointer to callback function for read completions.
  78. Returns:
  79. TRUE on success and FALSE if there is any failure.
  80. Use GetLastError() to retrieve Win32 error code.
  81. --*/
  82. dllexp BOOL
  83. TsProcessGatewayRequest(
  84. IN LPVOID pClientContext,
  85. IN PIGATEWAY_REQUEST pIGatewayRequest,
  86. PFN_IGATEWAY_READ_CALLBACK pfnReadCallBack);
  87. #if DBG
  88. dllexp VOID
  89. PrintIGatewayRequest( IN const IGATEWAY_REQUEST * pigRequest);
  90. #else
  91. dllexp VOID
  92. PrintIGatewayRequest( IN const IGATEWAY_REQUEST * pigRequest)
  93. { ; }
  94. #endif // !DBG
  95. # endif // _IGATEWAY_HXX_
  96. /************************ End of File ***********************/
  97.