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.

266 lines
6.3 KiB

  1. /* File: C:\WACKER\xfer\krm.hh (Created: 28-Jan-1994)
  2. * created from HAWIN source file
  3. * krm.hh -- Internal definitions for KERMIT file transfer
  4. * protocol routines.
  5. *
  6. * Copyright 1989,1994 by Hilgraeve Inc. -- Monroe, MI
  7. * All rights reserved
  8. *
  9. * $Revision: 2 $
  10. * $Date: 4/24/02 3:36p $
  11. */
  12. #define Dbg(a,b)
  13. #define DbgW(a,b,c)
  14. #define DbgWW(a,b,c,d)
  15. #define DbgWWW(a,b,c,d,e)
  16. #define DbgL(a,b,c)
  17. #if defined(ERROR)
  18. #undef ERROR
  19. #endif
  20. #define ERROR (-1)
  21. #if !defined(MAXLINE)
  22. #define MAXLINE 130
  23. #endif
  24. #if !defined(DEL)
  25. #define DEL 0177
  26. #endif
  27. #define MAXPCKT 100 /* maximum length for packet data */
  28. #define K_QCTL '#'
  29. #define K_QBIN '&'
  30. #define K_REPT '~'
  31. #define K_CHK1 1
  32. #define K_CHK2 2
  33. #define K_CHK3 3
  34. #define CAPMASK_ATTR 0x08
  35. #define tochar(ch) ((ch) + ' ')
  36. #define unchar(ch) ((ch) - ' ')
  37. #define ctl(ch) ((ch) ^ 0x40)
  38. /* valid packet types include 'Y', 'N', 'S, 'I', 'F', 'A', 'D', 'Z',
  39. * 'B', 'E', 'R', 'C', 'K', 'T', 'G'
  40. * plus special types returned by rec_packet():
  41. */
  42. #define BAD_PACKET '\030'
  43. /* Kermit receive states */
  44. #define KREC_INIT 0
  45. #define KREC_FILE 1
  46. #define KREC_DATA 2
  47. #define KREC_COMPLETE 3
  48. #define KREC_ABORT 4
  49. /* Kermit packet error codes */
  50. #define KE_NOERROR 0
  51. #define KE_TIMEOUT 1
  52. #define KE_NAK 2
  53. #define KE_BAD_PACKET 3
  54. #define KE_RMTERR 4
  55. #define KE_WRONG 5
  56. #define KE_REPEAT 6
  57. #define KE_SEQUENCE 7
  58. #define KE_FATAL 8
  59. /* Kermit abort codes */
  60. #define KA_OK 0
  61. #define KA_LABORT1 1
  62. #define KA_RABORT1 2
  63. #define KA_LABORTALL 3
  64. #define KA_RABORTALL 4
  65. #define KA_IMMEDIATE 5
  66. #define KA_RMTERR 6
  67. #define KA_LOST_CARRIER 7
  68. #define KA_ERRLIMIT 8
  69. #define KA_OUT_OF_SEQ 9
  70. #define KA_BAD_FORMAT 10
  71. #define KA_TOO_MANY 11
  72. #define KA_CANT_OPEN 12
  73. #define KA_DISK_FULL 13
  74. #define KA_DISK_ERROR 14
  75. #define KA_OLDER_FILE 15
  76. #define KA_NO_FILETIME 16
  77. #define KA_WONT_CANCEL 17
  78. #define KA_VIRUS_DETECT 18
  79. #define KA_USER_REFUSED 19
  80. /* progress display codes */
  81. #define FILE_DONE 1
  82. #define TRANSFER_DONE 2
  83. #define KPCKT struct _kpckt
  84. KPCKT
  85. {
  86. unsigned char pmark;
  87. unsigned char plen;
  88. unsigned char pseq;
  89. unsigned char ptype;
  90. unsigned char pdata[MAXPCKT];
  91. int datalen;
  92. };
  93. struct s_krm_rcv_control
  94. {
  95. int files_received;
  96. int files_aborted;
  97. int oldtries;
  98. int dsptries;
  99. int total_tries;
  100. long bytes_expected;
  101. int size_known;
  102. int lasterr;
  103. unsigned char uabort_code;
  104. int data_packet_rcvd;
  105. int store_later;
  106. // struct s_filetime compare_time;
  107. unsigned long ul_compare_time;
  108. // struct s_filetime filetime;
  109. unsigned long ul_filetime;
  110. int next_rtype;
  111. int next_plen;
  112. int next_rseq;
  113. unsigned char next_packet[MAXPCKT];
  114. KPCKT resp_pckt;
  115. };
  116. typedef struct s_krm_rcv_control ST_R_KRM;
  117. typedef struct s_krm_control ST_KRM;
  118. struct s_krm_control
  119. {
  120. HSESSION hSession;
  121. HCOM hCom;
  122. ST_IOBUF *fhdl;
  123. long basesize;
  124. int ksequence;
  125. int packetnum;
  126. int tries;
  127. int abort_code;
  128. void * flagkey_hdl;
  129. long xfertime;
  130. char xtra_err[MAXLINE];
  131. char their_fname[MAXPCKT];
  132. TCHAR our_fname[FNAME_LEN];
  133. long total_dsp;
  134. long total_thru;
  135. long nbytes;
  136. int file_cnt;
  137. int files_done;
  138. int its_maxl;
  139. int its_timeout;
  140. int its_npad;
  141. unsigned char its_padc;
  142. unsigned char its_eol;
  143. unsigned char its_chkt;
  144. unsigned char its_qctl;
  145. unsigned char its_qbin;
  146. unsigned char its_rept;
  147. int its_capat;
  148. int fname_width;
  149. /* These used to be globals */
  150. int k_useattr; /* send 'normalized' file names ? */
  151. int k_maxl; /* maximum packet length we'll take */
  152. int k_timeout; /* time they should wait for us */
  153. unsigned char k_chkt; /* check type we want to use */
  154. int k_retries; /* no. of retries */
  155. unsigned char k_markchar; /* first char of each packet */
  156. unsigned char k_eol; /* end of line character for packets */
  157. int k_npad; /* no. of pad chars. to send us */
  158. unsigned char k_padc; /* pad char. we want */
  159. unsigned total_retries;
  160. long displayed_time;
  161. ST_R_KRM kr; /* receive control structure */
  162. /* variables for sending and receiving */
  163. KPCKT *this_kpckt;
  164. KPCKT *next_kpckt;
  165. long kbytes_sent;
  166. int (*p_kputc)(ST_KRM *p, int c);
  167. long kbytes_received;
  168. int (*p_kgetc)(ST_KRM *p);
  169. void (*KrmProgress)(ST_KRM *p, int n);
  170. };
  171. // extern int krm_dbg; /* used for real-time debugging using dbg.c */
  172. // extern struct s_krm_control FAR *kc;
  173. // extern void (NEARF *KrmProgress)(HSESSION, bits);
  174. // variables for receiving
  175. // extern struct s_krm_rcv_control FAR *krc;
  176. // extern metachar (NEAR *p_kputc)(metachar);
  177. // extern long kbytes_received;
  178. // variables for sending
  179. // extern metachar (NEAR *p_kgetc)(void);
  180. // extern long kbytes_sent;
  181. extern unsigned ke_msg[]; /* packet error messages */
  182. extern int kresult_code[]; /* result codes */
  183. /* function prototypes: */
  184. extern void krm_box(int p_toprow,
  185. int p_leftcol,
  186. int p_botmrow,
  187. int p_rightcol);
  188. extern void krm_box_remove(void);
  189. extern void krmGetParameters(ST_KRM *kc);
  190. extern void ksend_packet(ST_KRM *hK,
  191. unsigned char type,
  192. unsigned dlength,
  193. int seq,
  194. KPCKT FAR *pckt);
  195. extern int krec_packet(ST_KRM *hK,
  196. int *len,
  197. int *seq,
  198. unsigned char *data);
  199. extern int buildparams(ST_KRM *hK,
  200. int initiating,
  201. unsigned char *bufr);
  202. extern void getparams(ST_KRM *hK,
  203. int initiating,
  204. unsigned char *bufr);
  205. extern void ks_progress(ST_KRM *hK, int status);
  206. extern int krec_init(ST_KRM *hK);
  207. extern int krec_file(ST_KRM *hK);
  208. extern int krec_data(ST_KRM *hK);
  209. extern void kr_progress(ST_KRM *hK, int status);
  210. extern int kunload_packet(ST_KRM *hK,
  211. int len,
  212. unsigned char *bufr);
  213. extern int kr_putc(ST_KRM *kc, int c);
  214. extern void krm_rcheck(ST_KRM *hK, int before);
  215. extern void krm_check_input(int suspend);
  216. extern void kunload_attributes(ST_KRM *hK,
  217. unsigned char *data,
  218. KPCKT FAR *rsp_pckt);
  219. extern void krm_settime(unsigned char *data, unsigned long *pl);
  220. extern int kload_packet(ST_KRM *hK,
  221. unsigned char *bufr);
  222. extern int ks_getc(ST_KRM *kc);
  223. /************************** end of krm.hh *****************************/