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.

336 lines
8.2 KiB

  1. /* File: D:\WACKER\xfer\x_entry.c (Created: 14-Dec-1993)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 7 $
  7. * $Date: 7/11/02 11:13a $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include <term\res.h>
  12. #include <tdll\stdtyp.h>
  13. #include <tdll\mc.h>
  14. #include <tdll\assert.h>
  15. #include <tdll\globals.h>
  16. #include <tdll\session.h>
  17. #include <tdll\xfer_msc.h>
  18. #include <tdll\htchar.h>
  19. #include <xfer\xfr_dsp.h>
  20. #include "hpr.h"
  21. #include "krm.h"
  22. #include "mdmx.h"
  23. #include "zmodem.h"
  24. #include "xfer.h"
  25. #include "xfer.hh"
  26. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  27. *
  28. * This module contains all of the entry points into this DLL. It also
  29. * contains a detailed description (as much as necessary) about the service
  30. * that the entry point offers.
  31. *
  32. *=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  33. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  34. * FUNCTION:
  35. * xfrGetProtocols
  36. *
  37. * DESCRIPTION:
  38. * This function builds and returns a list of the available transfer
  39. * protocols. In this version, it just uses internal protocols. Later
  40. * versions may check for additional DLLs by name and query them for
  41. * details.
  42. *
  43. * The list that gets returned is a pointer to an array of structures of
  44. * type XFR_PROTOCOL. The end of the list is indicated by a 0 for the
  45. * protocol and a 0 length name string.
  46. *
  47. * ARGUMENTS:
  48. * hSession -- the session handle
  49. * ppList -- pointer to the list pointer (for returning data)
  50. *
  51. * RETURNS:
  52. * 0 if everything is OK, otherwise an error code.
  53. *
  54. */
  55. #define NUM_PROTOCOLS 9
  56. int WINAPI xfrGetProtocols(const HSESSION hSession,
  57. const XFR_PROTOCOL **ppList)
  58. {
  59. int nIdx;
  60. XFR_PROTOCOL *pS;
  61. /*
  62. * For the time being, we only return a single protocol.
  63. */
  64. pS = (XFR_PROTOCOL *)malloc(NUM_PROTOCOLS * sizeof(XFR_PROTOCOL));
  65. if (pS == (XFR_PROTOCOL *)0)
  66. return XFR_NO_MEMORY;
  67. nIdx = 0;
  68. #if FALSE
  69. pS[nIdx].nProtocol = XF_HYPERP;
  70. StrCharCopyN(pS[nIdx].acName, TEXT("HyperProtocol"), PROTOCOL_NAME_LENGTH);
  71. nIdx += 1;
  72. #endif
  73. pS[nIdx].nProtocol = XF_XMODEM_1K;
  74. LoadString(glblQueryDllHinst(),
  75. IDS_XD_PROTO_X_1,
  76. pS[nIdx].acName,
  77. sizeof(pS[nIdx].acName) / sizeof(TCHAR));
  78. nIdx += 1;
  79. pS[nIdx].nProtocol = XF_XMODEM;
  80. LoadString(glblQueryDllHinst(),
  81. IDS_XD_PROTO_X,
  82. pS[nIdx].acName,
  83. sizeof(pS[nIdx].acName) / sizeof(TCHAR));
  84. nIdx += 1;
  85. pS[nIdx].nProtocol = XF_YMODEM;
  86. LoadString(glblQueryDllHinst(),
  87. IDS_XD_PROTO_Y,
  88. pS[nIdx].acName,
  89. sizeof(pS[nIdx].acName) / sizeof(TCHAR));
  90. nIdx += 1;
  91. pS[nIdx].nProtocol = XF_YMODEM_G;
  92. LoadString(glblQueryDllHinst(),
  93. IDS_XD_PROTO_Y_G,
  94. pS[nIdx].acName,
  95. sizeof(pS[nIdx].acName) / sizeof(TCHAR));
  96. nIdx += 1;
  97. pS[nIdx].nProtocol = XF_ZMODEM;
  98. LoadString(glblQueryDllHinst(),
  99. IDS_XD_PROTO_Z,
  100. pS[nIdx].acName,
  101. sizeof(pS[nIdx].acName) / sizeof(TCHAR));
  102. nIdx += 1;
  103. #if defined(INCL_ZMODEM_CRASH_RECOVERY)
  104. pS[nIdx].nProtocol = XF_ZMODEM_CR;
  105. LoadString(glblQueryDllHinst(),
  106. IDS_XD_PROTO_Z_CR,
  107. pS[nIdx].acName,
  108. sizeof(pS[nIdx].acName) / sizeof(TCHAR));
  109. nIdx += 1;
  110. #endif // defined(INCL_ZMODEM_CRASH_RECOVERY)
  111. pS[nIdx].nProtocol = XF_KERMIT;
  112. LoadString(glblQueryDllHinst(),
  113. IDS_XD_PROTO_K,
  114. pS[nIdx].acName,
  115. sizeof(pS[nIdx].acName) / sizeof(TCHAR));
  116. nIdx += 1;
  117. pS[nIdx].nProtocol = 0; /* Indicates end of list */
  118. pS[nIdx].acName[0] = TEXT('\0');
  119. *ppList = pS; /* Return the list */
  120. return (0);
  121. }
  122. #if defined(DEADWOOD)
  123. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  124. * FUNCTION:
  125. * xfrGetParameters
  126. *
  127. * DESCRIPTION:
  128. * This function pops up a dialog to get specific transfer protocol
  129. * parameters. You get a different dialog and different parameters for
  130. * each protocol.
  131. *
  132. * ARGUMENTS:
  133. * hSession -- the session handle
  134. * nProtocol -- the protocol id, returned from xfrGetProtocols
  135. * hwnd -- the parent window handle
  136. * ppData -- pointer to the data pointer (for returning data)
  137. *
  138. * NOTES:
  139. * The ppData parameter is set up so that if there is a previous block
  140. * of data for this protocol, it can be passed in. If there is no data
  141. * for this protocol, a NULL pointer is passed in and one is allocated and
  142. * returned. The returned value should always be used instead of the passed
  143. * in value because at some time in the future, a parameter block mey need
  144. * to expand and realloc some memory.
  145. *
  146. * RETURNS:
  147. * 0 if everything is OK, otherwise an error code.
  148. *
  149. */
  150. int WINAPI xfrGetParameters(const HSESSION hSession,
  151. const int nProtocol,
  152. const HWND hwnd,
  153. VOID **ppData)
  154. {
  155. int nRet = 0;
  156. VOID *pD = *ppData;
  157. if (pD == (VOID *)0)
  158. {
  159. /* Caller did not supply an old parameter block, create one */
  160. nRet = xfrInitializeParams(hSession, nProtocol, &pD);
  161. if (nRet != 0)
  162. return nRet;
  163. }
  164. nRet = xfrModifyParams(hSession,
  165. nProtocol,
  166. hwnd,
  167. pD);
  168. if (nRet != 0)
  169. {
  170. /* Clean up on an error */
  171. free(pD);
  172. pD = (VOID *)0;
  173. }
  174. *ppData = pD;
  175. return (nRet);
  176. }
  177. #endif //defined(DEADWOOD)
  178. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  179. * FUNCTION:
  180. * xfrReceive
  181. *
  182. * DESCRIPTION:
  183. * This function starts a receive operation for a specific protocol.
  184. * Any more details are only related to the sepcific protocol.
  185. *
  186. * ARGUMENTS:
  187. * hSession -- the session handle
  188. * pXferRec -- pointer to the receive data block (build by RECEIVE dlg)
  189. *
  190. * RETURNS:
  191. * 0 if everything is OK, otherwise an error code.
  192. *
  193. */
  194. int WINAPI xfrReceive(const HSESSION hSession,
  195. const XFR_RECEIVE *pXferRec)
  196. {
  197. if (pXferRec == NULL)
  198. {
  199. assert(FALSE);
  200. return -1;
  201. }
  202. switch (pXferRec->nProtocol)
  203. {
  204. #if FALSE
  205. case XF_HYPERP:
  206. return hpr_rcv(hSession,
  207. TRUE,
  208. FALSE); /* TODO: Get single_file flag !!!! */
  209. #endif
  210. case XF_ZMODEM:
  211. case XF_ZMODEM_CR:
  212. return zmdm_rcv(hSession,
  213. pXferRec->nProtocol,
  214. TRUE,
  215. FALSE); /* TODO: Get single_file flag !!!! */
  216. case XF_XMODEM:
  217. case XF_XMODEM_1K:
  218. return mdmx_rcv(hSession,
  219. TRUE,
  220. pXferRec->nProtocol,
  221. TRUE); /* TODO: Get single_file flag !!!! */
  222. case XF_YMODEM:
  223. case XF_YMODEM_G:
  224. return mdmx_rcv(hSession,
  225. TRUE,
  226. pXferRec->nProtocol,
  227. FALSE); /* TODO: Get single_file flag !!!! */
  228. case XF_KERMIT:
  229. return krm_rcv(hSession,
  230. TRUE,
  231. FALSE); /* TODO: Get single_file flag !!!! */
  232. case XF_CSB:
  233. break;
  234. default:
  235. break;
  236. }
  237. return 0;
  238. }
  239. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  240. * FUNCTION:
  241. * xfrSend
  242. *
  243. * DESCRIPTION:
  244. * This function starts a send operation for a specific protocol.
  245. * Any more details are only related to the specific protocols.
  246. *
  247. * ARGUMENTS:
  248. * hSession -- the session handle
  249. * pXferSend -- pointer to the send data block (built by SEND dialog)
  250. *
  251. * RETURNS:
  252. * 0 if everything is OK, otherwise an error code.
  253. *
  254. */
  255. int WINAPI xfrSend(const HSESSION hSession,
  256. const XFR_SEND *pXferSend)
  257. {
  258. if (pXferSend == NULL)
  259. {
  260. assert(FALSE);
  261. return -1;
  262. }
  263. switch (pXferSend->nProtocol)
  264. {
  265. #if FALSE
  266. case XF_HYPERP:
  267. return hpr_snd(hSession,
  268. TRUE, /* Attended ??? */
  269. pXferSend->nCount,
  270. pXferSend->lSize);
  271. #endif
  272. case XF_ZMODEM:
  273. case XF_ZMODEM_CR:
  274. return zmdm_snd(hSession,
  275. pXferSend->nProtocol,
  276. TRUE, /* Attended ??? */
  277. pXferSend->nCount,
  278. pXferSend->lSize);
  279. case XF_XMODEM:
  280. case XF_XMODEM_1K:
  281. case XF_YMODEM:
  282. case XF_YMODEM_G:
  283. return mdmx_snd(hSession,
  284. TRUE, /* Attended ??? */
  285. pXferSend->nProtocol,
  286. pXferSend->nCount,
  287. pXferSend->lSize);
  288. case XF_KERMIT:
  289. return krm_snd(hSession,
  290. TRUE, /* Attended ??? */
  291. pXferSend->nCount,
  292. pXferSend->lSize);
  293. case XF_CSB:
  294. break;
  295. default:
  296. break;
  297. }
  298. return (0);
  299. }