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.

529 lines
12 KiB

  1. /* File: D:\WACKER\xfer\x_params.c (Created: 16-Dec-1993)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 2 $
  7. * $Date: 7/12/02 8:12a $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include <tdll\stdtyp.h>
  12. #include <tdll\mc.h>
  13. #include <tdll\assert.h>
  14. #include <tdll\session.h>
  15. #include <tdll\tdll.h>
  16. #include <tdll\globals.h>
  17. #include <tdll\mc.h>
  18. #include "xfer.h"
  19. #include "xfer.hh"
  20. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. * FUNCTION:
  22. * xfrInitializeParams
  23. *
  24. * DESCRIPTION:
  25. * This function is called to initialize a transfer parameter block. It
  26. * calls the specific function that is for the specific protocol.
  27. *
  28. * ARGUEMENTS:
  29. * hSession -- the session handle
  30. * nProtocol -- indicates which protocol
  31. * ppData -- a pointer to a pointer for the return of the block
  32. *
  33. * RETURNS:
  34. * ZERO if everything is OK, otherwise an error code.
  35. */
  36. int xfrInitializeParams(const HSESSION hSession,
  37. const int nProtocol,
  38. VOID **ppData)
  39. {
  40. int nRet;
  41. switch (nProtocol)
  42. {
  43. case XF_ZMODEM:
  44. case XF_ZMODEM_CR:
  45. nRet = xfrInitializeZmodem(hSession, nProtocol, ppData);
  46. break;
  47. case XF_XMODEM:
  48. case XF_XMODEM_1K:
  49. case XF_YMODEM:
  50. case XF_YMODEM_G:
  51. nRet = xfrInitializeXandYmodem(hSession, ppData);
  52. break;
  53. #if FALSE
  54. case XF_HYPERP:
  55. nRet = xfrInitializeHyperProtocol(hSession, ppData);
  56. break;
  57. #endif
  58. case XF_KERMIT:
  59. nRet = xfrInitializeKermit(hSession, ppData);
  60. break;
  61. case XF_CSB:
  62. default:
  63. nRet = XFR_BAD_PROTOCOL;
  64. break;
  65. }
  66. return nRet;
  67. }
  68. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  69. * FUNCTION:
  70. * xfrInitializeHyperProtocol
  71. *
  72. * DESCRIPTION:
  73. * This function is called to initialize a HyperProtocol parameter block. It
  74. * will allocate a block if necessary, initialize the block and return.
  75. *
  76. * ARGUEMENTS:
  77. * hSession -- the session handle
  78. * ppData -- a pointer to a pointer for the return of the block
  79. *
  80. * RETURNS:
  81. * ZERO if everything is OK, otherwise an error code.
  82. */
  83. #if FALSE
  84. int xfrInitializeHyperProtocol(const HSESSION hSession, VOID **ppData)
  85. {
  86. int nRet;
  87. XFR_HP_PARAMS *pH;
  88. nRet = 0;
  89. pH = (XFR_HP_PARAMS *)*ppData; /* Get the current parameters */
  90. if (pH == NULL)
  91. {
  92. /* Allocate a new structure */
  93. pH = (XFR_HP_PARAMS *)malloc(sizeof(XFR_HP_PARAMS));
  94. if (pH == (XFR_HP_PARAMS *)0)
  95. nRet = XFR_NO_MEMORY;
  96. }
  97. if (nRet == 0)
  98. {
  99. /* Remember to set the size */
  100. pH->nSize = sizeof(XFR_HP_PARAMS);
  101. pH->nCheckType = HP_CT_CHECKSUM;
  102. pH->nBlockSize = 2048;
  103. pH->nResyncTimeout = 10;
  104. *ppData = (VOID FAR *)pH;
  105. }
  106. return nRet;
  107. }
  108. #endif
  109. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  110. * FUNCTION:
  111. * xfrInitializeZmodem
  112. *
  113. * DESCRIPTION:
  114. * This function is called to initialize a ZMODEM parameter block. It will
  115. * allocate a block if necessary, initialize the block and return.
  116. *
  117. * ARGUEMENTS:
  118. * hSession -- the session handle
  119. * nProtocol -- Zmodem or Zmodem with crash recovery
  120. * ppData -- a pointer to a pointer for the return of the block
  121. *
  122. * RETURNS:
  123. * ZERO if everything is OK, otherwise an error code.
  124. */
  125. int xfrInitializeZmodem(const HSESSION hSession,
  126. int nProtocol,
  127. VOID **ppData)
  128. {
  129. int nRet;
  130. XFR_Z_PARAMS *pZ;
  131. nRet = 0;
  132. pZ = (XFR_Z_PARAMS *)*ppData; /* Get the current parameters */
  133. if (pZ == NULL)
  134. {
  135. /* Allocate a new structure */
  136. pZ = (XFR_Z_PARAMS *)malloc(sizeof(XFR_Z_PARAMS));
  137. if (pZ == (XFR_Z_PARAMS *)0)
  138. {
  139. nRet = XFR_NO_MEMORY;
  140. }
  141. }
  142. if (nRet == 0)
  143. {
  144. /* Remember to set the size */
  145. pZ->nSize = sizeof(XFR_Z_PARAMS);
  146. pZ->nAutostartOK = TRUE;
  147. pZ->nFileExists = ZP_FE_DLG;
  148. if (nProtocol == XF_ZMODEM_CR)
  149. {
  150. pZ->nCrashRecRecv = ZP_CRR_ALWAYS;
  151. }
  152. else
  153. {
  154. pZ->nCrashRecRecv = ZP_CRR_NEVER;
  155. }
  156. pZ->nOverwriteOpt = ZP_OO_NONE;
  157. if (nProtocol == XF_ZMODEM_CR)
  158. {
  159. pZ->nCrashRecSend = ZP_CRS_ALWAYS;
  160. }
  161. else
  162. {
  163. pZ->nCrashRecSend = ZP_CRS_NEG;
  164. }
  165. pZ->nXferMthd = ZP_XM_STREAM;
  166. pZ->nWinSize = 15; /* Set in KB */
  167. #if defined(UPPER_FEATURES)
  168. pZ->nBlkSize = 6; /* A wierd shift value */
  169. #endif // defined(UPPER_FEATURES)
  170. pZ->nCrcType = ZP_CRC_16;
  171. pZ->nRetryWait = 20;
  172. pZ->nEolConvert = FALSE;
  173. pZ->nEscCtrlCodes = FALSE;
  174. *ppData = (VOID FAR *)pZ;
  175. }
  176. return nRet;
  177. }
  178. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  179. * FUNCTION:
  180. * xfrInitializeXandYmodem
  181. *
  182. * DESCRIPTION:
  183. * This function is called to initialize a XMODEM parameter block. It will
  184. * allocate a block if necessary, initialize the block and return.
  185. *
  186. * ARGUEMENTS:
  187. * hSession -- the session handle
  188. * ppData -- a pointer to a pointer for the return of the block
  189. *
  190. * RETURNS:
  191. * ZERO if everything is OK, otherwise an error code.
  192. */
  193. int xfrInitializeXandYmodem(const HSESSION hSession,
  194. VOID **ppData)
  195. {
  196. int nRet;
  197. XFR_XY_PARAMS *pX;
  198. nRet = 0;
  199. pX = (XFR_XY_PARAMS *)*ppData; /* Get the current parameters */
  200. if (pX == NULL)
  201. {
  202. /* Allocate a new structure */
  203. pX = (XFR_XY_PARAMS *)malloc(sizeof(XFR_XY_PARAMS));
  204. if (pX == (XFR_XY_PARAMS *)0)
  205. nRet = XFR_NO_MEMORY;
  206. }
  207. if (nRet == 0)
  208. {
  209. /* Remember to set the size */
  210. pX->nSize = sizeof(XFR_XY_PARAMS);
  211. pX->nErrCheckType = XP_ECP_AUTOMATIC;
  212. pX->nPacketWait = 20;
  213. pX->nByteWait = 5;
  214. pX->nNumRetries = 10;
  215. *ppData = (VOID FAR *)pX;
  216. }
  217. return nRet;
  218. }
  219. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  220. * FUNCTION:
  221. * xfrModifyParams
  222. *
  223. * DESCRIPTION:
  224. * This function is called to bring up a dialog box allowing the user to
  225. * change any of the options for a specified protocol.
  226. *
  227. * ARGUEMENTS:
  228. * hSession -- a session handle
  229. * nProtocol -- speciofies the protocol
  230. * hwnd -- window to be parent window
  231. * pData -- pointer to the parameters data block
  232. *
  233. * RETURNS:
  234. * ZERO if everything is OK, otherwise an error code.
  235. */
  236. int xfrModifyParams(const HSESSION hSession,
  237. const int nProtocol,
  238. const HWND hwnd,
  239. VOID *pData)
  240. {
  241. int nRet;
  242. if (pData == (VOID *)0)
  243. return XFR_BAD_POINTER;
  244. switch (nProtocol)
  245. {
  246. #if defined(UPPER_FEATURES)
  247. case XF_ZMODEM:
  248. nRet = xfrModifyZmodem(hSession, hwnd, pData);
  249. break;
  250. case XF_XMODEM:
  251. case XF_XMODEM_1K:
  252. nRet = xfrModifyXmodem(hSession, hwnd, pData);
  253. break;
  254. case XF_YMODEM:
  255. case XF_YMODEM_G:
  256. nRet = xfrModifyYmodem(hSession, hwnd, pData);
  257. break;
  258. case XF_HYPERP:
  259. nRet = xfrModifyHyperProtocol(hSession, hwnd, pData);
  260. break;
  261. case XF_KERMIT:
  262. nRet = xfrModifyKermit(hSession, hwnd, pData);
  263. break;
  264. case XF_CSB:
  265. #endif
  266. default:
  267. nRet = XFR_BAD_PROTOCOL;
  268. break;
  269. }
  270. return nRet;
  271. }
  272. #if defined(UPPER_FEATURES)
  273. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  274. * FUNCTION:
  275. * xfrModifyXandYmodem
  276. *
  277. * DESCRIPTION:
  278. * This function brings up the dialog box that allows the user to change
  279. * the XMODEM protocol parameters.
  280. *
  281. * ARGUEMENTS:
  282. * hSession -- the session handle
  283. * hwnd -- the window to be the parent
  284. * pData -- pointer to the parameter data block
  285. *
  286. * RETURNS:
  287. */
  288. int xfrModifyXmodem(const HSESSION hSession,
  289. const HWND hwnd,
  290. VOID *pData)
  291. {
  292. int nRet = 0;
  293. XFR_XY_PARAMS *pX;
  294. pX = (XFR_XY_PARAMS *)pData;
  295. DoDialog(glblQueryDllHinst(),
  296. "XmodemParameters",
  297. hwnd, /* parent window */
  298. XandYmodemParamsDlg,
  299. (LPARAM)pX);
  300. return nRet;
  301. }
  302. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  303. * FUNCTION:
  304. * xfrModifyYmodem
  305. *
  306. * DESCRIPTION:
  307. * This function brings up the dialog box that allows the user to change
  308. * the YMODEM protocol parameters.
  309. *
  310. * ARGUEMENTS:
  311. * hSession -- the session handle
  312. * hwnd -- the window to be the parent
  313. * pData -- pointer to the parameter data block
  314. *
  315. * RETURNS:
  316. */
  317. int xfrModifyYmodem(const HSESSION hSession,
  318. const HWND hwnd,
  319. VOID *pData)
  320. {
  321. int nRet = 0;
  322. XFR_XY_PARAMS *pY;
  323. pY = (XFR_XY_PARAMS *)pData;
  324. DoDialog(glblQueryDllHinst(),
  325. "YmodemParameters",
  326. hwnd, /* parent window */
  327. XandYmodemParamsDlg,
  328. (LPARAM)pY);
  329. return nRet;
  330. }
  331. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  332. * FUNCTION:
  333. * xfrModifyZmodem
  334. *
  335. * DESCRIPTION:
  336. * This function brings up the dialog box that allows the user to change
  337. * the ZMODEM protocol parameters.
  338. *
  339. * ARGUEMENTS:
  340. * hSession -- the session handle
  341. * hwnd -- the window to be the parent
  342. * pData -- pointer to the parameter data block
  343. *
  344. * RETURNS:
  345. */
  346. int xfrModifyZmodem(const HSESSION hSession,
  347. const HWND hwnd,
  348. VOID *pData)
  349. {
  350. int nRet = 0;
  351. XFR_Z_PARAMS *pZ;
  352. pZ = (XFR_Z_PARAMS *)pData;
  353. DoDialog(glblQueryDllHinst(),
  354. "ZmodemParameters",
  355. hwnd, /* parent window */
  356. ZmodemParamsDlg,
  357. (LPARAM)pZ);
  358. return nRet;
  359. }
  360. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  361. * FUNCTION:
  362. * xfrModifyHyperProtocol
  363. *
  364. * DESCRIPTION:
  365. * This function brings up the dialog box that allows the user to change
  366. * the HyperProtocol parameters.
  367. *
  368. * ARGUEMENTS:
  369. * hSession -- the session handle
  370. * hwnd -- the window to be the parent
  371. * pData -- pointer to the parameter data block
  372. *
  373. * RETURNS:
  374. */
  375. #if FALSE
  376. int xfrModifyHyperProtocol(const HSESSION hSession,
  377. const HWND hwnd,
  378. VOID *pData)
  379. {
  380. int nRet = 0;
  381. XFR_HP_PARAMS *pH;
  382. pH = (XFR_HP_PARAMS *)pData;
  383. DoDialog(glblQueryDllHinst(),
  384. "HyperParameters",
  385. hwnd, /* parent window */
  386. HyperProtocolParamsDlg,
  387. (LPARAM)pH);
  388. return nRet;
  389. }
  390. #endif
  391. #endif
  392. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  393. * FUNCTION:
  394. * xfrInitializeKermit
  395. *
  396. * DESCRIPTION:
  397. * This function is called to initialize a HyperProtocol parameter block. It
  398. * will allocate a block if necessary, initialize the block and return.
  399. *
  400. * ARGUEMENTS:
  401. * hSession -- the session handle
  402. * ppData -- a pointer to a pointer for the return of the block
  403. *
  404. * RETURNS:
  405. * ZERO if everything is OK, otherwise an error code.
  406. */
  407. int xfrInitializeKermit(const HSESSION hSession, VOID **ppData)
  408. {
  409. int nRet;
  410. XFR_KR_PARAMS *pK;
  411. nRet = 0;
  412. pK = (XFR_KR_PARAMS *)*ppData; /* Get the current parameters */
  413. if (pK == NULL)
  414. {
  415. /* Allocate a new structure */
  416. pK = (XFR_KR_PARAMS *)malloc(sizeof(XFR_KR_PARAMS));
  417. if (pK == (XFR_KR_PARAMS *)0)
  418. nRet = XFR_NO_MEMORY;
  419. }
  420. if (nRet == 0)
  421. {
  422. /* Remember to set the size */
  423. pK->nSize = sizeof(XFR_KR_PARAMS);
  424. pK->nBytesPerPacket = 94;
  425. pK->nSecondsWaitPacket = 5;
  426. pK->nErrorCheckSize = 1;
  427. pK->nRetryCount = 5;
  428. pK->nPacketStartChar = 1;
  429. pK->nPacketEndChar = 13;
  430. pK->nNumberPadChars = 0;
  431. pK->nPadChar = 0;
  432. *ppData = (VOID FAR *)pK;
  433. }
  434. return nRet;
  435. }
  436. #if defined(UPPER_FEATURES)
  437. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  438. * FUNCTION:
  439. *
  440. * DESCRIPTION:
  441. *
  442. * ARGUEMENTS:
  443. *
  444. * RETURNS:
  445. */
  446. int xfrModifyKermit(const HSESSION hSession,
  447. const HWND hwnd,
  448. VOID *pData)
  449. {
  450. int nRet = 0;
  451. XFR_KR_PARAMS *pKR;
  452. pKR = (XFR_KR_PARAMS *)pData;
  453. DoDialog(glblQueryDllHinst(),
  454. "KermitParameters",
  455. hwnd, /* parent window */
  456. KermitParamsDlg,
  457. (LPARAM)pKR);
  458. return nRet;
  459. }
  460. #endif