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.

203 lines
6.5 KiB

  1. //============================================================================
  2. // Copyright (c) 1996, Microsoft Corporation
  3. //
  4. // File: scriptp.h
  5. //
  6. // History:
  7. // Abolade-Gbadegesin 04-01-96 Created.
  8. //
  9. // Contains private declarations for dial-up scripting.
  10. //
  11. // Most of the code for script-processing is Win9x code.
  12. // The port consisted of wiring the Win9x code to NT entry-points,
  13. // in order to allow scripts to work without a terminal window.
  14. // This DLL thus exports a function which can be called to run a script
  15. // to completion (RasScriptExecute), as well as a set of functions
  16. // which together provide a way for the caller to start script-processing
  17. // and receive notification when data is received or when certain events
  18. // occur during script execution. The notification may be event-based
  19. // or message-based (i.e. via SetEvent or via SendNotifyMessage).
  20. //
  21. // The code is rewired at the upper level, by providing the functions
  22. // defined in RASSCRPT.H as the interface to scripting, as well as
  23. // at the lower level, by replacing Win9x's Win32 COMM calls with calls
  24. // to RASMAN to send and receive data. The changes to the Win9x code
  25. // can be found by searching for the string "WINNT_RAS" which is used
  26. // in #ifdef statements to demarcate modifications.
  27. // Generally, the upper-level functions have names like Rs*
  28. // and the lower-level functions have names like Rx*.
  29. //
  30. // The Win9x code is heavily dependent on there being an HWND
  31. // for messages to be sent to. This is not always the case on NT,
  32. // and so code which uses an HWND on Win9x has been modified on NT
  33. // to expect instead a pointer to a SCRIPTDATA structure; this structure
  34. // contains enough information for the code to achieve whatever is needed.
  35. //
  36. // Script initialization produces a HANDLE which is actually a pointer
  37. // to a SCRIPTCB. The SCRIPTCB contains all information needed to manage
  38. // an interactive session over a connected RAS link, including the RASMAN port
  39. // and the RASMAN buffers. If the connected link is associated with
  40. // a phonebook entry, then the pdata field of the SCRIPTCB structure
  41. // will be initialized with a SCRIPTDATA, which contains all information
  42. // needed to execute the entry's script during the interactive session.
  43. //
  44. // This SCRIPTDATA contains the Win9x script-processing structures
  45. // (scanner, parsed module, and abstract syntax tree; see NTHDR2.H).
  46. // It also contains fields needed for the Win9x circular-buffer management,
  47. // which is implemented to allow searching for strings across read-boundaries
  48. // (see ReadIntoBuffer() in TERMINAL.C).
  49. //
  50. // Initialization also creates a thread which handles the script-processing.
  51. // This thread runs until the script completes or halts, or until
  52. // RasScriptTerm is called with the HANDLE supplied during initialization.
  53. // (This allows a script to be cancelled while running.)
  54. //
  55. // The Win9x code is completely ANSI based. Rather than edit its code
  56. // to use generic-text (TCHAR), this port uses ANSI as well.
  57. // In certain places, this requires conversions from Unicode,
  58. // which is used by the rest of the RAS UI.
  59. // To find all instances of such conversions, search for UNICODEUI
  60. // in the source code.
  61. //============================================================================
  62. #ifndef _SCRIPTP_H_
  63. #define _SCRIPTP_H_
  64. #include "proj.h"
  65. #ifdef UNICODEUI
  66. #define UNICODE
  67. #undef LPTSTR
  68. #define LPTSTR WCHAR*
  69. #undef TCHAR
  70. #define TCHAR WCHAR
  71. #include <debug.h>
  72. #include <nouiutil.h>
  73. #include <pbk.h>
  74. #undef TCHAR
  75. #define TCHAR CHAR
  76. #undef LPTSTR
  77. #define LPTSTR CHAR*
  78. #undef UNICODE
  79. #endif // UNICODEUI
  80. #include <rasscrpt.h>
  81. //
  82. // flags used in internally in the "dwFlags" field
  83. // of the SCRIPTCB structure; these are in addition to the public flags,
  84. // and start from the high-end of the flags DWORD
  85. //
  86. #define RASSCRIPT_ThreadCreated 0x80000000
  87. #define RASSCRIPT_PbuserLoaded 0x40000000
  88. #define RASSCRIPT_PbfileLoaded 0x20000000
  89. //----------------------------------------------------------------------------
  90. // struct: SCRIPTCB
  91. //
  92. // control block containing data and state for a script.
  93. //----------------------------------------------------------------------------
  94. #define SCRIPTCB struct tagSCRIPTCB
  95. SCRIPTCB {
  96. //
  97. // connection handle, flags for script processing,
  98. // notification handle (event or HWND, depending on flags)
  99. //
  100. HRASCONN hrasconn;
  101. DWORD dwFlags;
  102. HANDLE hNotifier;
  103. //
  104. // phonebook entry information
  105. //
  106. PBENTRY* pEntry;
  107. CHAR* pszIpAddress;
  108. //
  109. // port input/output variables:
  110. // RASMAN port handle for data I/O
  111. // RASMAN send buffer
  112. // RASMAN receive buffer
  113. // size of current contents of receive buffer
  114. // size of contents read so far by script-interpreter
  115. //
  116. HPORT hport;
  117. BYTE* pSendBuffer;
  118. BYTE* pRecvBuffer;
  119. DWORD dwRecvSize;
  120. DWORD dwRecvRead;
  121. //
  122. // thread control variables:
  123. // event signalled by RASMAN when data is received
  124. // event signalled by RasScriptReceive when data has been read
  125. // event signalled to stop the thread
  126. // event signalled to tell that the ip address changed bug #75226
  127. // event code to be read using RasScriptGetEventCode
  128. //
  129. HANDLE hRecvRequest;
  130. HANDLE hRecvComplete;
  131. HANDLE hStopRequest;
  132. HANDLE hStopComplete;
  133. DWORD dwEventCode;
  134. //
  135. // script processing variables; the following will be NULL
  136. // if the entry has no associated script:
  137. // Win9x-compatible script-processing structure;
  138. // Win9x-compatible connection information
  139. //
  140. SCRIPTDATA* pdata;
  141. SESS_CONFIGURATION_INFO sci;
  142. };
  143. DWORD
  144. RsDestroyData(
  145. IN SCRIPTCB* pscript
  146. );
  147. DWORD
  148. RsInitData(
  149. IN SCRIPTCB* pscript,
  150. IN LPCSTR pszScriptPath
  151. );
  152. DWORD
  153. RsThread(
  154. IN PVOID pParam
  155. );
  156. DWORD
  157. RsThreadProcess(
  158. IN SCRIPTCB* pscript
  159. );
  160. #ifdef UNICODEUI
  161. #define lstrlenUI lstrlenW
  162. #define lstrcmpiUI lstrcmpiW
  163. #define StrCpyAFromUI WCSTOMBS
  164. #define StrDupUIFromA StrDupWFromA
  165. #define GetFileAttributesUI GetFileAttributesW
  166. #else
  167. #define lstrlenUI lstrlenA
  168. #define lstrcmpiUI lstrcmpiA
  169. #define StrCpyAFromUI lstrcpyA
  170. #define StrDupUIFromA StrDup
  171. #define GetFileAttributesUI GetFileAttributesA
  172. #endif
  173. #endif // _SCRIPTP_H_