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.

352 lines
5.3 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. //
  31. // Socket utilities.
  32. //
  33. SOCKERR
  34. CreateDataSocket(
  35. SOCKET * psock,
  36. ULONG addrLocal,
  37. PORT portLocal,
  38. ULONG addrRemote,
  39. PORT portRemote
  40. );
  41. SOCKERR
  42. CreateFtpdSocket(
  43. SOCKET * psock,
  44. ULONG addrLocal,
  45. FTP_SERVER_INSTANCE *pInstance
  46. );
  47. SOCKERR
  48. CloseSocket(
  49. SOCKET sock
  50. );
  51. SOCKERR
  52. ResetSocket(
  53. SOCKET sock
  54. );
  55. SOCKERR
  56. AcceptSocket(
  57. SOCKET sockListen,
  58. SOCKET * psockNew,
  59. LPSOCKADDR_IN paddr,
  60. BOOL fEnforceTimeout,
  61. FTP_SERVER_INSTANCE *pInstance
  62. );
  63. DWORD
  64. ClientThread(
  65. LPVOID Param
  66. );
  67. SOCKERR
  68. SockSend(
  69. LPUSER_DATA pUserData,
  70. SOCKET sock,
  71. LPVOID pBuffer,
  72. DWORD cbBuffer
  73. );
  74. SOCKERR
  75. __cdecl
  76. SockPrintf2(
  77. LPUSER_DATA pUserData,
  78. SOCKET sock,
  79. LPCSTR pszFormat,
  80. ...
  81. );
  82. SOCKERR
  83. __cdecl
  84. ReplyToUser(
  85. IN LPUSER_DATA pUserData,
  86. IN UINT ReplyCode,
  87. IN LPCSTR pszFormat,
  88. ...
  89. );
  90. SOCKERR
  91. __cdecl
  92. SockReplyFirst2(
  93. LPUSER_DATA pUserData,
  94. SOCKET sock,
  95. UINT ReplyCode,
  96. LPCSTR pszFormat,
  97. ...
  98. );
  99. //
  100. // User database functions.
  101. //
  102. VOID
  103. UserDereference(
  104. LPUSER_DATA pUserData
  105. );
  106. BOOL
  107. DisconnectUser(
  108. DWORD UserId,
  109. FTP_SERVER_INSTANCE *pInstance
  110. );
  111. VOID
  112. DisconnectUsersWithNoAccess(
  113. VOID
  114. );
  115. BOOL
  116. EnumerateUsers(
  117. PCHAR pBuffer,
  118. PDWORD pcbBuffer,
  119. PDWORD nRead,
  120. FTP_SERVER_INSTANCE *pInstance
  121. );
  122. //
  123. // IPC functions.
  124. //
  125. APIERR
  126. InitializeIPC(
  127. VOID
  128. );
  129. VOID
  130. TerminateIPC(
  131. VOID
  132. );
  133. //
  134. // Service control functions.
  135. //
  136. VOID
  137. ServiceEntry(
  138. DWORD cArgs,
  139. LPWSTR pArgs[]
  140. );
  141. //
  142. // Virtual file i/o functions.
  143. //
  144. APIERR
  145. VirtualCreateFile(
  146. LPUSER_DATA pUserData,
  147. LPHANDLE phFile,
  148. LPSTR pszFile,
  149. BOOL fAppend
  150. );
  151. APIERR
  152. VirtualCreateUniqueFile(
  153. LPUSER_DATA pUserData,
  154. LPHANDLE phFile,
  155. LPSTR pszTmpFile
  156. );
  157. FILE *
  158. Virtual_fopen(
  159. LPUSER_DATA pUserData,
  160. LPSTR pszFile,
  161. LPSTR pszMode
  162. );
  163. APIERR
  164. VirtualDeleteFile(
  165. LPUSER_DATA pUserData,
  166. LPSTR pszFile
  167. );
  168. APIERR
  169. VirtualRenameFile(
  170. LPUSER_DATA pUserData,
  171. LPSTR pszExisting,
  172. LPSTR pszNew
  173. );
  174. APIERR
  175. VirtualChDir(
  176. LPUSER_DATA pUserData,
  177. LPSTR pszDir
  178. );
  179. APIERR
  180. VirtualRmDir(
  181. LPUSER_DATA pUserData,
  182. LPSTR pszDir
  183. );
  184. APIERR
  185. VirtualMkDir(
  186. LPUSER_DATA pUserData,
  187. LPSTR pszDir
  188. );
  189. //
  190. // Command parser functions.
  191. //
  192. VOID
  193. ParseCommand(
  194. LPUSER_DATA pUserData,
  195. LPSTR pszCommandText
  196. );
  197. //
  198. // General utility functions.
  199. //
  200. LPSTR
  201. TransferType(
  202. XFER_TYPE type
  203. );
  204. LPSTR
  205. TransferMode(
  206. XFER_MODE mode
  207. );
  208. LPSTR
  209. DisplayBool(
  210. BOOL fFlag
  211. );
  212. BOOL
  213. IsDecimalNumber(
  214. LPSTR psz
  215. );
  216. LPSTR
  217. AllocErrorText(
  218. APIERR err
  219. );
  220. VOID
  221. FreeErrorText(
  222. LPSTR pszText
  223. );
  224. DWORD
  225. OpenPathForAccess(
  226. LPHANDLE phFile,
  227. LPSTR pszPath,
  228. ULONG DesiredAccess,
  229. ULONG ShareAccess,
  230. HANDLE hImpersonation
  231. );
  232. #define FLIP_SLASHES_TO_UNIX 0
  233. #define FLIP_SLASHES_TO_DOS 1
  234. LPSTR
  235. FlipSlashes(
  236. LPSTR pszPath,
  237. BOOL fDirection
  238. );
  239. BOOL
  240. ParseUserName(
  241. IN PSTR pszDomainAndUser,
  242. IN OUT PSTR *ppszUser,
  243. IN OUT PSTR *ppszDomain,
  244. IN PCSTR pszLocalHostName,
  245. OUT PBOOL pfIsLocalHost
  246. );
  247. //
  248. // LS simulator functions.
  249. //
  250. APIERR
  251. SimulateLs(
  252. IN LPUSER_DATA pUserData,
  253. IN LPSTR pszArg,
  254. IN BOOL fUseDataSocket, // TRUE ==>DataSocket, FALSE==>ControlSocket
  255. IN BOOL fDefaultLong = FALSE // TRUE ==> generate long listing
  256. );
  257. APIERR
  258. SpecialLs(
  259. IN LPUSER_DATA pUserData,
  260. IN LPSTR pszSearchPath,
  261. IN BOOL fUseDataSocket // TRUE ==>DataSocket, FALSE==>ControlSocket
  262. );
  263. //
  264. // Some handy macros.
  265. //
  266. #define IS_PATH_SEP(x) (((x) == '\\') || ((x) == '/'))
  267. VOID
  268. VirtualpSanitizePath(
  269. CHAR * pszPath
  270. );
  271. DWORD
  272. FtpFormatResponseMessage( IN UINT uiReplyCode,
  273. IN LPCTSTR pszReplyMsg,
  274. OUT LPTSTR pszReplyBuffer,
  275. IN INT cchReplyBuffer);
  276. #endif // _PROC_HXX_