Source code of Windows XP (NT5)
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.

369 lines
5.2 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows NT **/
  3. /** Copyright(c) Microsoft Corp., 1993 **/
  4. /**********************************************************************/
  5. /*
  6. proc.hxx
  7. This file contains the global procedure definitions for the
  8. FTPD Service.
  9. FILE HISTORY:
  10. KeithMo 07-Mar-1993 Created.
  11. MuraliK April-1995 Modified/deleted functions for New FTP service
  12. */
  13. #ifndef _PROC_HXX_
  14. #define _PROC_HXX_
  15. //
  16. // Global variable initialization & termination function.
  17. //
  18. APIERR
  19. InitializeGlobals(
  20. VOID
  21. );
  22. VOID
  23. TerminateGlobals(
  24. VOID
  25. );
  26. VOID
  27. ClearStatistics(
  28. VOID
  29. );
  30. #define LockGlobals() EnterCriticalSection( &g_GlobalLock );
  31. #define UnlockGlobals() LeaveCriticalSection( &g_GlobalLock );
  32. //
  33. // Socket utilities.
  34. //
  35. APIERR
  36. InitializeSockets(
  37. VOID
  38. );
  39. VOID
  40. TerminateSockets(
  41. VOID
  42. );
  43. SOCKERR
  44. CreateDataSocket(
  45. SOCKET * psock,
  46. ULONG addrLocal,
  47. PORT portLocal,
  48. ULONG addrRemote,
  49. PORT portRemote
  50. );
  51. SOCKERR
  52. CreateFtpdSocket(
  53. SOCKET * psock,
  54. ULONG addrLocal,
  55. PORT portLocal,
  56. FTP_SERVER_INSTANCE *pInstance
  57. );
  58. SOCKERR
  59. CloseSocket(
  60. SOCKET sock
  61. );
  62. SOCKERR
  63. ResetSocket(
  64. SOCKET sock
  65. );
  66. SOCKERR
  67. AcceptSocket(
  68. SOCKET sockListen,
  69. SOCKET * psockNew,
  70. LPSOCKADDR_IN paddr,
  71. BOOL fEnforceTimeout,
  72. FTP_SERVER_INSTANCE *pInstance
  73. );
  74. DWORD
  75. ClientThread(
  76. LPVOID Param
  77. );
  78. SOCKERR
  79. SockSend(
  80. LPUSER_DATA pUserData,
  81. SOCKET sock,
  82. LPVOID pBuffer,
  83. DWORD cbBuffer
  84. );
  85. SOCKERR
  86. SockRecv(
  87. LPUSER_DATA pUserData,
  88. SOCKET sock,
  89. LPVOID pBuffer,
  90. DWORD cbBuffer,
  91. LPDWORD pbReceived
  92. );
  93. SOCKERR
  94. __cdecl
  95. SockPrintf2(
  96. LPUSER_DATA pUserData,
  97. SOCKET sock,
  98. LPCSTR pszFormat,
  99. ...
  100. );
  101. SOCKERR
  102. __cdecl
  103. ReplyToUser(
  104. IN LPUSER_DATA pUserData,
  105. IN UINT ReplyCode,
  106. IN LPCSTR pszFormat,
  107. ...
  108. );
  109. SOCKERR
  110. __cdecl
  111. SockReplyFirst2(
  112. LPUSER_DATA pUserData,
  113. SOCKET sock,
  114. UINT ReplyCode,
  115. LPCSTR pszFormat,
  116. ...
  117. );
  118. //
  119. // User database functions.
  120. //
  121. VOID
  122. UserDereference(
  123. LPUSER_DATA pUserData
  124. );
  125. BOOL
  126. DisconnectUser(
  127. DWORD UserId,
  128. FTP_SERVER_INSTANCE *pInstance
  129. );
  130. VOID
  131. DisconnectUsersWithNoAccess(
  132. VOID
  133. );
  134. BOOL
  135. EnumerateUsers(
  136. PCHAR pBuffer,
  137. PDWORD pcbBuffer,
  138. PDWORD nRead,
  139. FTP_SERVER_INSTANCE *pInstance
  140. );
  141. //
  142. // IPC functions.
  143. //
  144. APIERR
  145. InitializeIPC(
  146. VOID
  147. );
  148. VOID
  149. TerminateIPC(
  150. VOID
  151. );
  152. //
  153. // Service control functions.
  154. //
  155. VOID
  156. ServiceEntry(
  157. DWORD cArgs,
  158. LPWSTR pArgs[]
  159. );
  160. //
  161. // Virtual file i/o functions.
  162. //
  163. APIERR
  164. VirtualCreateFile(
  165. LPUSER_DATA pUserData,
  166. LPHANDLE phFile,
  167. LPSTR pszFile,
  168. BOOL fAppend
  169. );
  170. APIERR
  171. VirtualCreateUniqueFile(
  172. LPUSER_DATA pUserData,
  173. LPHANDLE phFile,
  174. LPSTR pszTmpFile
  175. );
  176. FILE *
  177. Virtual_fopen(
  178. LPUSER_DATA pUserData,
  179. LPSTR pszFile,
  180. LPSTR pszMode
  181. );
  182. APIERR
  183. VirtualDeleteFile(
  184. LPUSER_DATA pUserData,
  185. LPSTR pszFile
  186. );
  187. APIERR
  188. VirtualRenameFile(
  189. LPUSER_DATA pUserData,
  190. LPSTR pszExisting,
  191. LPSTR pszNew
  192. );
  193. APIERR
  194. VirtualChDir(
  195. LPUSER_DATA pUserData,
  196. LPSTR pszDir
  197. );
  198. APIERR
  199. VirtualRmDir(
  200. LPUSER_DATA pUserData,
  201. LPSTR pszDir
  202. );
  203. APIERR
  204. VirtualMkDir(
  205. LPUSER_DATA pUserData,
  206. LPSTR pszDir
  207. );
  208. //
  209. // Command parser functions.
  210. //
  211. VOID
  212. ParseCommand(
  213. LPUSER_DATA pUserData,
  214. LPSTR pszCommandText
  215. );
  216. //
  217. // General utility functions.
  218. //
  219. LPSTR
  220. TransferType(
  221. XFER_TYPE type
  222. );
  223. LPSTR
  224. TransferMode(
  225. XFER_MODE mode
  226. );
  227. LPSTR
  228. DisplayBool(
  229. BOOL fFlag
  230. );
  231. BOOL
  232. IsDecimalNumber(
  233. LPSTR psz
  234. );
  235. LPSTR
  236. AllocErrorText(
  237. APIERR err
  238. );
  239. VOID
  240. FreeErrorText(
  241. LPSTR pszText
  242. );
  243. DWORD
  244. OpenPathForAccess(
  245. LPHANDLE phFile,
  246. LPSTR pszPath,
  247. ULONG DesiredAccess,
  248. ULONG ShareAccess,
  249. HANDLE hImpersonation
  250. );
  251. LPSTR
  252. FlipSlashes(
  253. LPSTR pszPath
  254. );
  255. PSTR
  256. P_strncpy(
  257. PSTR dst,
  258. PCSTR src,
  259. DWORD cnt);
  260. //
  261. // LS simulator functions.
  262. //
  263. APIERR
  264. SimulateLs(
  265. IN LPUSER_DATA pUserData,
  266. IN LPSTR pszArg,
  267. IN BOOL fUseDataSocket, // TRUE ==>DataSocket, FALSE==>ControlSocket
  268. IN BOOL fDefaultLong = FALSE // TRUE ==> generate long listing
  269. );
  270. APIERR
  271. SpecialLs(
  272. IN LPUSER_DATA pUserData,
  273. IN LPSTR pszSearchPath,
  274. IN BOOL fUseDataSocket // TRUE ==>DataSocket, FALSE==>ControlSocket
  275. );
  276. //
  277. // Some handy macros.
  278. //
  279. #define IS_PATH_SEP(x) (((x) == '\\') || ((x) == '/'))
  280. VOID
  281. VirtualpSanitizePath(
  282. CHAR * pszPath
  283. );
  284. DWORD
  285. FtpFormatResponseMessage( IN UINT uiReplyCode,
  286. IN LPCTSTR pszReplyMsg,
  287. OUT LPTSTR pszReplyBuffer,
  288. IN DWORD cchReplyBuffer);
  289. #endif // _PROC_HXX_