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.

150 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. hutil.cxx
  5. Abstract:
  6. contains outdated c-c++ interface functions
  7. Author:
  8. Madan Appiah (madana) 16-Nov-1994
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. Sophia Chung (sophiac) 14-Feb-1995 (added FTP and Archie class impl.)
  13. (code adopted from madana)
  14. --*/
  15. #include <wininetp.h>
  16. DWORD
  17. RIsHandleLocal(
  18. HINTERNET Handle,
  19. BOOL * IsLocalHandle, // dead
  20. BOOL * IsAsyncHandle,
  21. HINTERNET_HANDLE_TYPE ExpectedHandleType
  22. )
  23. {
  24. INTERNET_HANDLE_OBJECT* HandleObj = (INTERNET_HANDLE_OBJECT*) Handle;
  25. DWORD Error = HandleObj->IsValid(ExpectedHandleType);
  26. if (Error != ERROR_SUCCESS)
  27. return Error;
  28. *IsAsyncHandle = HandleObj->IsAsyncHandle();
  29. return ERROR_SUCCESS;
  30. }
  31. DWORD
  32. RGetHandleType(
  33. HINTERNET Handle,
  34. LPHINTERNET_HANDLE_TYPE HandleType
  35. )
  36. {
  37. HANDLE_OBJECT *HandleObj = (HANDLE_OBJECT *)Handle;
  38. DWORD error;
  39. //
  40. // validate handle before we use it.
  41. //
  42. error = HandleObj->IsValid(TypeWildHandle);
  43. if (error == ERROR_SUCCESS) {
  44. //
  45. // find the handle type.
  46. //
  47. *HandleType = HandleObj->GetHandleType();
  48. }
  49. return error;
  50. }
  51. DWORD
  52. RGetContext(
  53. HINTERNET hInternet,
  54. DWORD_PTR *lpdwContext
  55. )
  56. {
  57. DWORD error;
  58. //
  59. // ensure the handle is valid
  60. //
  61. error = ((HANDLE_OBJECT*)hInternet)->IsValid(TypeWildHandle);
  62. if (error == ERROR_SUCCESS) {
  63. *lpdwContext = ((INTERNET_HANDLE_OBJECT*)hInternet)->GetContext();
  64. }
  65. return error;
  66. }
  67. DWORD
  68. RSetContext(
  69. HINTERNET hInternet,
  70. DWORD_PTR dwContext
  71. )
  72. {
  73. DWORD error;
  74. //
  75. // ensure the handle is valid
  76. //
  77. error = ((HANDLE_OBJECT*)hInternet)->IsValid(TypeWildHandle);
  78. if (error == ERROR_SUCCESS) {
  79. ((INTERNET_HANDLE_OBJECT*)hInternet)->SetContext(dwContext);
  80. }
  81. return error;
  82. }
  83. DWORD
  84. RGetStatusCallback(
  85. IN HINTERNET Handle,
  86. OUT LPWINHTTP_STATUS_CALLBACK lpStatusCallback
  87. )
  88. {
  89. //
  90. // NULL handle should have been caught before we got here
  91. // (its in WINHTTPQueryOption())
  92. //
  93. INET_ASSERT(Handle != NULL);
  94. *lpStatusCallback = ((INTERNET_HANDLE_OBJECT *)Handle)->GetStatusCallback();
  95. return ERROR_SUCCESS;
  96. }
  97. DWORD
  98. RExchangeStatusCallback(
  99. IN HINTERNET Handle,
  100. IN OUT LPWINHTTP_STATUS_CALLBACK lpStatusCallback,
  101. IN BOOL fType,
  102. IN DWORD dwFlags)
  103. {
  104. DWORD error;
  105. //
  106. // NULL handle value should have been caught already
  107. // (in WINHTTPSetStatusCallback())
  108. //
  109. INET_ASSERT(Handle != NULL);
  110. error = ((HANDLE_OBJECT *)Handle)->IsValid(TypeWildHandle);
  111. if (error == ERROR_SUCCESS) {
  112. error = ((INTERNET_HANDLE_OBJECT *)Handle)->
  113. ExchangeStatusCallback(lpStatusCallback, fType, dwFlags);
  114. }
  115. return error;
  116. }