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.

206 lines
4.9 KiB

  1. /* File: C:\WACKER\xfer\mdmx.hh (Created: 17-Jan-1994)
  2. * created from HAWIN source file
  3. * mdmx.hh -- Internal definitions for xmodem file transfer routines
  4. *
  5. * Copyright 1989,1994 by Hilgraeve Inc. -- Monroe, MI
  6. * All rights reserved
  7. *
  8. * $Revision: 2 $
  9. * $Date: 4/12/02 5:00p $
  10. */
  11. /* Various constants */
  12. #define SMALL_PACKET 128
  13. #define LARGE_PACKET 1024
  14. #define SMALL_WAIT 50
  15. #define MEDIUM_WAIT 200
  16. #define LARGE_WAIT 400
  17. /* Block results */
  18. #define UNDEFINED 0
  19. #define GOOD_PCKT 1
  20. #define ALT_PCKT 2
  21. #define NOBATCH_PCKT 3
  22. #define END_PCKT 4
  23. #define REPEAT_PCKT 5
  24. #define WRONG_PCKT 6
  25. #define SHORT_PCKT 7
  26. #define BAD_FORMAT 8
  27. #define BAD_CHECK 9
  28. #define NO_PCKT 10
  29. #define BLK_ABORTED 11
  30. #define CARRIER_LOST 12
  31. #define CANNED 13
  32. /* Responses include any character plus the following: */
  33. #define NO_RESPONSE -1
  34. #define ABORTED -2 /* also used as BlockReceive status */
  35. #define CARR_LOST -3
  36. /* transfer status codes */
  37. #define XS_OK 0
  38. #define XS_ABORTED 1
  39. #define XS_CANCELLED 2
  40. #define XS_NO_RESPONSE 3
  41. #define XS_COMMERR 4
  42. #define XS_FILEERR 5
  43. #define XS_SYNCHERR 6
  44. #define XS_NOSPACE 7
  45. #define XS_CANTOPEN 8
  46. #define XS_COMPLETE 9
  47. #define XS_SHORTFILE 10
  48. #define XS_BATCH_EXPECTED 11
  49. /* Status codes for mdmx_progress */
  50. #define FILE_DONE 1
  51. #define TRANSFER_DONE 2
  52. /* Control structure, allocated during transfers to hold control variables */
  53. typedef struct s_mdmx_cntrl ST_MDMX;
  54. struct s_mdmx_cntrl
  55. {
  56. HSESSION hSession;
  57. HCOM hCom; /* derived from the above */
  58. int nProto; /* The current protocol */
  59. long file_bytes;
  60. long total_bytes;
  61. void *flagkey;
  62. ST_IOBUF *fh;
  63. long basesize;
  64. long xfertimer;
  65. long xfertime;
  66. unsigned nfiles;
  67. unsigned filen;
  68. long filesize;
  69. long nbytes;
  70. long mdmx_byte_cnt; /* count of bytes transferred */
  71. long displayed_time; /* = -1L; */
  72. struct s_mdmx_pckt *next_pckt;
  73. unsigned this_pckt;
  74. int check_type;
  75. int batch;
  76. int streaming;
  77. const unsigned short *p_crc_tbl; /* pointer to the CRC-16 table */
  78. int mdmx_chkt;
  79. int mdmx_tries;
  80. int mdmx_chartime;
  81. int mdmx_pckttime;
  82. stFB stP; /* Used in ComSend functions */
  83. int (*p_getc)(ST_MDMX *);
  84. int (*p_putc)(ST_MDMX *, int);
  85. };
  86. // typedef struct s_mdmx_cntrl ST_MDMX;
  87. /* Global control variables */
  88. // extern struct s_mdmx_cntrl *xc;
  89. // extern metachar (NEAR *p_getc)(VOID); // for snd
  90. // extern metachar (NEAR *p_putc)(metachar); // for rcv
  91. /* Packet structure: allocated during transfers to hold packet contents */
  92. struct s_mdmx_pckt
  93. {
  94. int result;
  95. int expected;
  96. int pcktsize;
  97. long byte_count;
  98. BYTE start_char;
  99. BYTE pcktnum;
  100. BYTE npcktnum;
  101. BYTE bdata[1];
  102. };
  103. /* function prototypes : */
  104. extern void mdmx_progress(ST_MDMX *pX, int status);
  105. // extern unsigned calc_crc(unsigned startval, BYTE *pntr, int count);
  106. extern unsigned short calc_crc(ST_MDMX *pX,
  107. unsigned short startval,
  108. LPSTR pntr,
  109. int cnt);
  110. int load_pckt(ST_MDMX *pX,
  111. struct s_mdmx_pckt *p,
  112. unsigned pcktnum,
  113. int kpckt,
  114. int chktype);
  115. int xm_getc(ST_MDMX *pX);
  116. int xs_unload(ST_MDMX *pX, BYTE *cp, int size);
  117. int xm_putc(ST_MDMX *pX, int c);
  118. /*
  119. * the following were added for HA5G
  120. */
  121. #define ComSendInit(h,p) fooComSendClear(h,p)
  122. #define ComSendWait(h,p) fooComSendPush(h,p)
  123. #define ComSendPush(h,p) fooComSendPush(h,p)
  124. #define ComSendChar(h,p,c) fooComSendChar(h,p,c)
  125. #define ComSendCharNow(h,p,c) fooComSendCharNow(h,p,c)
  126. // #define RemoteGet(h) mComRcvChar(mGetComHdl(h))
  127. // #define RemoteClear(h) mComRcvBufrClear(mGetComHdl(h))
  128. #define SOH 1
  129. #define STX 2
  130. #define EOT 4
  131. #define ACK 6
  132. #define CAN 0x18
  133. #define NAK 025
  134. #define ESC 0x1B
  135. #define CPMEOF 032
  136. extern void mdmxXferInit(ST_MDMX *pX, int method);
  137. /*
  138. * The following are display functions, some of which might be removed and
  139. * replaced with MACROS.
  140. */
  141. extern void mdmxdspFilecnt(ST_MDMX *pX, int cnt);
  142. extern void mdmxdspErrorcnt(ST_MDMX *pX, int cnt);
  143. extern void mdmxdspPacketErrorcnt(ST_MDMX *pX, int cnt);
  144. extern void mdmxdspTotalsize(ST_MDMX *pX, long bytes);
  145. extern void mdmxdspFilesize(ST_MDMX *pX, long fsize);
  146. extern void mdmxdspNewfile(ST_MDMX *pX,
  147. int filen,
  148. LPSTR theirname,
  149. LPTSTR ourname);
  150. extern void mdmxdspProgress(ST_MDMX *pX,
  151. long stime,
  152. long ttime,
  153. long cps,
  154. long file_so_far,
  155. long total_so_far);
  156. extern void mdmxdspChecktype(ST_MDMX *pX, int ctype);
  157. extern void mdmxdspPacketnumber(ST_MDMX *pX, long number);
  158. extern void mdmxdspLastError(ST_MDMX *pX, int errcode);
  159. extern void mdmxdspCloseDisplay(ST_MDMX *pX);
  160. /* end of mdmx.hh */