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.

401 lines
14 KiB

  1. /* File: C:\WACKER\xfer\hpr.hh (Created: 24-Jan-1994)
  2. * created from HAWIN source file:
  3. * hpr.hh -- Header file for HyperProtocol routines.
  4. *
  5. * Copyright 1989,1994 by Hilgraeve Inc. -- Monroe, MI
  6. * All rights reserved
  7. *
  8. * $Revision: 1 $
  9. * $Date: 10/05/98 1:16p $
  10. */
  11. /* The NOTIMEOUTS constant can be defined to prevent HyperProtocol from
  12. * timing out while waiting for the other end of the connection. This is
  13. * useful while debugging when events may be drawn out by debugging activities
  14. */
  15. /* #define NOTIMEOUTS */
  16. /* Constants for HyperProtocol */
  17. #define H_MSGCHAR 0x01
  18. #define MAXRETRIES 5
  19. #define MAX_START_TRIES 25
  20. #define RESYNCH_TIME 50
  21. #define RESYNCH_INC 50
  22. // #define RESYNCH_TIME 300
  23. // #define RESYNCH_INC 300
  24. #define FINAL_ACK_WAIT 1800L
  25. #define BURSTSIZE 5
  26. #define TIMEOUT_LIMIT 3
  27. #define H_START_WAIT 100 /* no. of seconds to wait for startup */
  28. #define H_MINBLOCK 128
  29. #define H_MINDEADMAN 10
  30. #define H_CHARTIME 100L
  31. #define tochar(c) ((BYTE)((c) + 0x20))
  32. #define unchar(c) ((BYTE)((c) - 0x20))
  33. #define h_crc_calc(x, cc)\
  34. {\
  35. unsigned q;\
  36. q = (x->h_crc ^ (cc)) & 0x0F;\
  37. x->h_crc = (x->h_crc >> 4) ^ (q * 0x1081);\
  38. q = (x->h_crc ^ ((cc) >> 4)) & 0x0F;\
  39. x->h_crc = (x->h_crc >> 4) ^ (q * 0x1081);\
  40. }
  41. /* * * * * * * * * * * * * * * * * * * * * * *
  42. * This section pertains to the sender only *
  43. * * * * * * * * * * * * * * * * * * * * * * */
  44. /* status display codes passed to hsdsp_status() */
  45. #define HSS_WAITSTART 0
  46. #define HSS_SENDING 1
  47. #define HSS_WAITACK 2
  48. #define HSS_WAITRESUME 3
  49. #define HSS_CANCELLED 4
  50. #define HSS_COMPLETE 5
  51. #define HSS_MAX 6
  52. /* event display codes passed to hsdsp_event() */
  53. #define HSE_GOTSTART 0
  54. #define HSE_GOTRETRY 1
  55. #define HSE_GOTRESUME 2
  56. #define HSE_GOTACK 3
  57. #define HSE_USRABORT 4
  58. #define HSE_RMTABORT 5
  59. #define HSE_USRCANCEL 6
  60. #define HSE_RMTCANCEL 7
  61. #define HSE_FILEERR 8
  62. #define HSE_NORESP 9
  63. #define HSE_FULL 10
  64. #define HSE_DONE 11
  65. #define HSE_ILLEGAL 12
  66. #define HSE_ERRLIMIT 13
  67. #define HSE_MAX 14
  68. /* structure for the file status table. This table holds details about files
  69. * during and after the time they are sent until they are acknowledged by
  70. * the receiver.
  71. */
  72. struct s_ftbl
  73. {
  74. int filen; /* file number (1st file sent is 1, etc. */
  75. int cntrl; /* control bits FTC_CONFIRMED and FTC_COMPRESSED */
  76. int status; /* transfer status, normal, aborted, error, etc. */
  77. long flength; /* length of this file in bytes */
  78. long dsp_bytes; /* length of all files prior to this file */
  79. long thru_bytes; /* amt. of data actually sent prior to this file */
  80. TCHAR fname[FNAME_LEN]; /* file name */
  81. };
  82. /* file table control bits */
  83. #define FTC_CONFIRMED 0x01
  84. #define FTC_COMPRESSED 0x02
  85. #define FTC_DONT_CMPRS 0x04
  86. /* file table status values */
  87. #define FTS_NORMAL 0
  88. #define FTS_USRABORT 1
  89. #define FTS_RMTABORT 2
  90. #define FTS_FILEERR 3
  91. #define FTS_COMMERR 4
  92. /* control structure used by hyperprotocol sender */
  93. struct s_hsc
  94. {
  95. int ft_current; /* index to current file in file table */
  96. int ft_open; /* index to currently opened file */
  97. int ft_top; /* index of highest used entry in file table */
  98. int ft_limit; /* number of entries available in file table */
  99. jmp_buf jb_bailout; /* jump buffer used to bail out of xfer */
  100. jmp_buf jb_restart; /* jump buffer used during restarts */
  101. int rmt_compress; /* TRUE if remote has indicated it is able to
  102. handle compression */
  103. int nfiles; /* no. of files to be transferred */
  104. long nbytes; /* no. of bytes to be transferred */
  105. long bytes_sent; /* no. of bytes actually passed to xmitter */
  106. int rmtchkt; /* Type of error checking requested by remote
  107. session. H_CRC by default. */
  108. long last_response; /* time last message received */
  109. int lastmsgn; /* last message number */
  110. int rmtcancel; /* TRUE if remote has cancelled xfer */
  111. int started; /* TRUE after 1st restart message is received
  112. from remote */
  113. int lasterr_filenum; /* file number of last restart request */
  114. long lasterr_offset; /* file offset of last restart request */
  115. int sameplace; /* no. of consecutive restarts to same spot*/
  116. int receiver_timedout; /* true if receiver sent time out msg */
  117. struct s_ftbl *hs_ftbl; /* pointer to dynamically allocated file
  118. progress table */
  119. int (*hs_ptrgetc)(void *); /* pointer to function to get
  120. characters to send */
  121. };
  122. /* globals used by sender */
  123. // extern struct s_hsc FAR *hsc; /* contains transfer control variables */
  124. // extern struct s_ftbl FAR *hs_ftbl; /* pointer to dynamically allocated file
  125. // progress table */
  126. // extern metachar (NEAR *hs_ptrgetc)(void);/* pointer to function to get
  127. // characters to send */
  128. /* macros used to send characters using the double buffering scheme */
  129. #define HSXB_SIZE 1024
  130. #define HSXB_CYCLE 75
  131. #define hs_xmit_(p,c) (--p->hsxb.cnt > 0 ? (*p->hsxb.bptr++ = (c)) : hs_xmit_switch(p,c))
  132. #define HS_XMIT(p,c) {if ((c) == H_MSGCHAR) hs_xmit_(p,c); hs_xmit_(p,c);}
  133. struct s_hsxb
  134. {
  135. char *curbufr; /* buffer being filled */
  136. char *altbufr; /* other buffer, possibly being transmitted */
  137. char *bptr; /* place to put next character to be sent */
  138. unsigned bufrsize; /* size of each buffer in bytes */
  139. unsigned total; /* number of bytes still free in the current buffer
  140. not counting those in the current fill cycle */
  141. unsigned cnt; /* number of bytes left to load in this fill cycle */
  142. };
  143. // extern unsigned hse_text[];
  144. // extern unsigned hss_text[];
  145. // extern struct s_hsxb hsxb; /* control structure for double buffered
  146. // transmission scheme */
  147. #define HS_XMIT_CLEAR hs_xbclear
  148. #define HS_XMIT_FLUSH hs_xbswitch
  149. struct s_hprsd
  150. {
  151. int k_received;
  152. unsigned int hld_options;
  153. };
  154. // extern struct s_hprsd FAR *hsd;
  155. /* * * * * * * * * * * * * * * * * * * * * * * *
  156. * This section pertains to the receiver only *
  157. * * * * * * * * * * * * * * * * * * * * * * * */
  158. /* Result codes for overall transfer */
  159. #define H_OK 0
  160. #define H_ERRLIMIT 1
  161. #define H_BADMSGFMT 2
  162. #define H_FILEERR 3
  163. #define H_NORESYNCH 4
  164. #define H_USERABORT 5
  165. #define H_TIMEOUT 6
  166. #define H_COMPLETE 7
  167. #define H_NOSTART 8
  168. #define H_RMTABORT 9
  169. /* Result codes for data collection routines */
  170. #define HR_UNDECIDED 0
  171. #define HR_COMPLETE 1
  172. #define HR_TIMEOUT 2
  173. #define HR_MESSAGE 3
  174. #define HR_KBDINT 4
  175. #define HR_FILEERR 5
  176. #define HR_NOCARRIER 6
  177. #define HR_BADCHECK 7
  178. #define HR_BADMSG 8
  179. #define HR_LOSTDATA 9
  180. #define HR_DCMPERR 10
  181. #define HR_LOST_CARR 11
  182. #define HR_VIRUS_FOUND 12
  183. /* Hyper receive status codes for hrdsp_status() */
  184. #define HRS_REQSTART 0
  185. #define HRS_REQRESYNCH 1
  186. #define HRS_REC 2
  187. #define HRS_CANCELLED 3
  188. #define HRS_COMPLETE 4
  189. #define HRS_MAX 5
  190. /* event codes for hrdsp_event() */
  191. #define HRE_NONE 0
  192. #define HRE_DATAERR 1
  193. #define HRE_LOSTDATA 2
  194. #define HRE_NORESP 3
  195. #define HRE_RETRYERR 4
  196. #define HRE_ILLEGAL 5
  197. #define HRE_ERRFIXED 6
  198. #define HRE_RMTABORT 7
  199. #define HRE_USRCANCEL 8
  200. #define HRE_TIMEOUT 9
  201. #define HRE_DCMPERR 10
  202. #define HRE_LOST_CARR 11
  203. #define HRE_TOO_MANY 12
  204. #define HRE_DISK_FULL 13
  205. #define HRE_CANT_OPEN 14
  206. #define HRE_DISK_ERR 15
  207. #define HRE_OLDER_FILE 16
  208. #define HRE_NO_FILETIME 17
  209. #define HRE_VIRUS_DET 18
  210. #define HRE_USER_SKIP 19
  211. #define HRE_USER_REFUSED 20
  212. #define HRE_MAX 21
  213. /* Structure containing control variables for the receiver */
  214. struct s_hrc
  215. {
  216. long bytes_expected; /* total number of bytes expected for xfer */
  217. long checkpoint; /* number of bytes known to be good */
  218. long basesize; /* original size of file being appended to */
  219. int expected_msg; /* number of next expected message */
  220. /* a timestamp of 0 means unused */
  221. unsigned long ul_lstw; /* timestamp of file being received, if any */
  222. unsigned long ul_cmp; /* time to compare to if /N option used */
  223. /* a timestamp of -1 means rejected by time */
  224. long filesize; /* size of file being received */
  225. int files_expected; /* number of files to be rcvd. during xfer */
  226. BYTE rmtfname[FNAME_LEN]; /* name remote system used for file */
  227. TCHAR ourfname[FNAME_LEN]; /* name we will use for file */
  228. int cancel_reason; /* event code associated with cancellation */
  229. int using_compression; /* TRUE if we're using compression */
  230. BYTE rmsg_bufr[256]; /* buffer to build outgoing messages */
  231. int single_file; /* TRUE if user named single file as dest */
  232. //SSHDLMCH ssmchVscan; /* handle for virus scanning */
  233. int virus_detected; /* set TRUE upon virus detection */
  234. //FARPROC pfVirusCheck; /* pointer to function for virus check */
  235. int (*hr_ptr_putc)(void *, int);
  236. };
  237. // VOID _export PASCAL hr_virus_detect(VOID FAR *h, USHORT usMatchId);
  238. /* globals for receiver */
  239. // extern struct s_hrc FAR *hrc;/* pointer to receiver's control structure */
  240. // extern metachar (NEAR *hr_ptr_putc)(metachar);
  241. extern int hr_result_codes[]; /* maps HyperProtocol event codes to
  242. transfer status codes */
  243. /******************************************************/
  244. /* control structure used by both sender and receiver */
  245. /******************************************************/
  246. struct s_hc
  247. {
  248. HSESSION hSession;
  249. int blocksize; /* current size of data blocks */
  250. int current_filen; /* current file number */
  251. int datacnt; /* keeps track of data sent or received */
  252. long deadmantime; /* time between dead man notices */
  253. unsigned total_tries; /* number of restarts */
  254. long total_thru; /* total number of bytes transferred */
  255. long total_dsp; /* total number of bytes for vu display */
  256. int ucancel; /* set true if user hits cancel key */
  257. int usecrc; /* set true if CRC is being used */
  258. long xfertimer; /* interval timer value */
  259. long xfertime; /* transfer time */
  260. BYTE omsg_bufr[256]; /* outgoing message buffer */
  261. BYTE *omsg; /* pointer into outgoing message buffer */
  262. int omsgn; /* next outgoing message number */
  263. int omsg_printable; /* true of outgoing message characters
  264. should be confined to printable chrs */
  265. int omsg_embed; /* true if outgoing messages should be embedded
  266. in other outgoing data */
  267. long last_omsg; /* time last outgoing message was sent */
  268. unsigned h_checksum; /* used to calculate data checksum */
  269. unsigned h_crc; /* used to calculate data crcs */
  270. long h_filebytes; /* counts bytes transferred */
  271. /* External parameters set by the user */
  272. int h_useattr; /* use received attributes when available */
  273. int h_trycompress; /* try to use compression when possible */
  274. int h_chkt; /* 1 == checksum, 2 == CRC */
  275. int h_resynctime; /* new resync time value */
  276. int h_suspenddsk; /* old feature, no longer used */
  277. long displayed_time; /* used in display timing */
  278. BYTE *storageptr; /* temporary use */
  279. BYTE msgdata[96]; /* more static storate stuff */
  280. BYTE *dptr;
  281. int rmcnt;
  282. struct s_hrc rc; /* data used for receiving */
  283. struct s_hsc sc; /* data used for sending */
  284. struct s_hsxb hsxb; /* control structure for double buffered */
  285. struct s_hprsd sd; /* display stuff */
  286. ST_IOBUF *fhdl;
  287. };
  288. /* Globals used by sender and receiver.
  289. * These items are defined as globals rather than being placed int one
  290. * of the control structures because they are accessed frequently in
  291. * speed-sensitive portions of the code.
  292. */
  293. // extern struct s_hc FAR *hc; /* pointer to control structure */
  294. // extern unsigned h_checksum; /* used to calculate data checksum */
  295. // extern unsigned h_crc; /* used to calculate data crcs */
  296. // extern long h_filebytes; /* counts bytes transferred */
  297. /*************************/
  298. /* function prototypes : */
  299. /*************************/
  300. /* used by both sender and receiver -- */
  301. extern void omsg_init(struct s_hc *hc, int fPrintable, int fEmbedMsg);
  302. extern void omsg_new(struct s_hc *hc, BYTE type);
  303. extern int omsg_add(struct s_hc *hc, BYTE *newfield);
  304. extern int omsg_setnum(struct s_hc *hc, int n);
  305. extern int omsg_send(struct s_hc *hc,
  306. int burstcnt,
  307. int usecrc,
  308. int backspace);
  309. extern long omsg_last(struct s_hc *hc);
  310. extern int omsg_number(struct s_hc *hc);
  311. // extern void h_crc_calc(uchar);
  312. /* used by receiver -- */
  313. extern int hr_collect_msg(struct s_hc *, int *, BYTE **, long);
  314. extern int hr_storedata(void *, int);
  315. extern void hr_still_alive(struct s_hc *, int, int);
  316. extern void hr_kbdint(struct s_hc *);
  317. extern int hr_decode_msg(struct s_hc *, BYTE *);
  318. extern int hr_reject_file(struct s_hc *, int);
  319. extern int hr_closefile(struct s_hc *, int);
  320. extern int hr_collect_data(struct s_hc *, int *, int, long);
  321. extern int hr_cancel(struct s_hc *, int);
  322. extern int hr_restart(struct s_hc *, int);
  323. extern int hr_resynch(struct s_hc *, int);
  324. extern int hr_putc(void *, int);
  325. extern int hr_putc_vir(void *, int);
  326. extern int hr_toss(void *, int);
  327. extern void hr_suspend_input(VOID *hS, int suspend);
  328. extern void hr_check_input(VOID *hS, int suspend);
  329. /* used by sender -- */
  330. extern int hyper_sendx(struct s_hc *, int);
  331. extern int hs_datasend(struct s_hc *);
  332. extern void hs_dorestart(struct s_hc *, int, long, int, int);
  333. extern int hs_reteof(struct s_hc *);
  334. extern int hs_getc(struct s_hc *);
  335. extern void hs_background(struct s_hc *);
  336. extern void hs_rcvmsg(struct s_hc *);
  337. extern void hs_filebreak(struct s_hc *hc, int nfiles, long nbytes);
  338. extern void hs_waitack(struct s_hc *);
  339. extern void hs_decode_rmsg(struct s_hc *, BYTE *);
  340. extern void hs_fileack(struct s_hc *, int);
  341. extern void hs_logx(struct s_hc *, int);
  342. /******************* end of hpr.hh *************************/