ZMODEM.H 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Z M O D E M . H Manifest constants for ZMODEM
  3. * application to application file transfer protocol
  4. * 5-16-86 Chuck Forsberg Omen Technology Inc
  5. */
  6. #define ZPAD '*' /* 052 Padding character begins frames */
  7. #define ZDLE 030 /* Ctrl-X Zmodem escape - `ala BISYNC DLE */
  8. #define ZDLEE (ZDLE^0100) /* Escaped ZDLE as transmitted */
  9. #define ZBIN 'A' /* Binary frame indicator */
  10. #define ZHEX 'B' /* HEX frame indicator */
  11. /* Frame types (see array "frametypes" in zm.c) */
  12. #define ZRQINIT 0 /* Request receive init */
  13. #define ZRINIT 1 /* Receive init */
  14. #define ZSINIT 2 /* Send init sequence (optional) */
  15. #define ZACK 3 /* ACK to above */
  16. #define ZFILE 4 /* File name from sender */
  17. #define ZSKIP 5 /* To sender: skip this file */
  18. #define ZNAK 6 /* Last packet was garbled */
  19. #define ZABORT 7 /* Abort batch transfers */
  20. #define ZFIN 8 /* Finish session */
  21. #define ZRPOS 9 /* Resume data trans at this position */
  22. #define ZDATA 10 /* Data packet(s) follow */
  23. #define ZEOF 11 /* End of file */
  24. #define ZFERR 12 /* Fatal Read or Write error Detected */
  25. #define ZCRC 13 /* Request for file CRC and response */
  26. #define ZCHALLENGE 14 /* Receiver's Challenge */
  27. #define ZCOMPL 15 /* Request is complete */
  28. #define ZCAN 16 /* Other end canned session with CAN-CAN */
  29. #define ZFREECNT 17 /* Request for free bytes on filesystem */
  30. #define ZCOMMAND 18 /* Command from sending program */
  31. /* ZDLE sequences */
  32. #define ZCRCE 'h' /* CRC next, frame ends, header packet follows */
  33. #define ZCRCG 'i' /* CRC next, frame continues nonstop */
  34. #define ZCRCQ 'j' /* CRC next, frame continues, ZACK expected */
  35. #define ZCRCW 'k' /* CRC next, ZACK expected, end of frame */
  36. #define ZRUB0 'l' /* Translate to rubout 0177 */
  37. #define ZRUB1 'm' /* Translate to rubout 0377 */
  38. /* zdlread return values (internal) */
  39. /* -1 is general error, -2 is timeout */
  40. #define GOTOR 0400
  41. #define GOTCRCE (ZCRCE|GOTOR) /* ZDLE-ZCRCE received */
  42. #define GOTCRCG (ZCRCG|GOTOR) /* ZDLE-ZCRCG received */
  43. #define GOTCRCQ (ZCRCQ|GOTOR) /* ZDLE-ZCRCQ received */
  44. #define GOTCRCW (ZCRCW|GOTOR) /* ZDLE-ZCRCW received */
  45. #define GOTCAN (GOTOR|030) /* CAN-CAN seen */
  46. /* Byte positions within header array */
  47. #define ZF0 3 /* First flags byte */
  48. #define ZF1 2
  49. #define ZF2 1
  50. #define ZF3 0
  51. #define ZP0 0 /* Low order 8 bits of position */
  52. #define ZP1 1
  53. #define ZP2 2
  54. #define ZP3 3 /* High order 8 bits of file position */
  55. /* Bit Masks for ZRINIT flags byte ZF0 */
  56. #define CANFDX 01 /* Rx can send and receive true FDX */
  57. #define CANOVIO 02 /* Rx can receive data during disk I/O */
  58. #define CANBRK 04 /* Rx can send a break signal */
  59. #define CANCRY 010 /* Receiver can decrypt */
  60. #define CANLZW 020 /* Receiver can uncompress */
  61. /* Parameters for ZSINIT frame */
  62. #define ZATTNLEN 32 /* Max length of attention string */
  63. /* Parameters for ZFILE frame */
  64. /* Conversion options one of these in ZF0 */
  65. #define ZCBIN 1 /* Binary transfer - inhibit conversion */
  66. #define ZCNL 2 /* Convert NL to local end of line convention */
  67. #define ZCRESUM 3 /* Resume interrupted file transfer */
  68. /* Management options, one of these in ZF1 */
  69. #define ZMNEW 1 /* Transfer if source newer or different length */
  70. #define ZMCRC 2 /* Transfer if different file CRC or length */
  71. #define ZMAPND 3 /* Append contents to existing file (if any) */
  72. #define ZMCLOB 4 /* Replace existing file */
  73. #define ZMSPARS 5 /* Encoding for sparse file */
  74. /* Transport options, one of these in ZF2 */
  75. #define ZTLZW 1 /* Lempel-Ziv compression */
  76. #define ZTCRYPT 2 /* Encryption */
  77. #define ZTRLE 3 /* Run Length encoding */
  78. /* Parameters for ZCOMMAND frame ZF0 (otherwise 0) */
  79. #define ZCACK1 1 /* Acknowledge, then do command */
  80. long int rclhdr(char *hdr);
  81. /* Globals used by ZMODEM functions */
  82. int Rxframeind; /* ZBIN or ZHEX indicates type of frame received */
  83. int Rxtype; /* Type of header received */
  84. int Rxcount; /* Count of data bytes received */
  85. extern int Rxtimeout; /* Tenths of seconds to wait for something */
  86. char Rxhdr[4]; /* Received header */
  87. char Txhdr[4]; /* Transmitted header */
  88. long Rxpos; /* Received file position */
  89. long Txpos; /* Transmitted file position */
  90. char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */
  91. extern rt_device_t _console_device;
  92. extern struct finsh_shell* shell;
  93. #define zwrite(x1) rt_device_write(_console_device, 0, &x1, 1)
  94. #define zread(x1,x2,x3,x4) rt_device_read (x1,x2,x3,x4)
  95. extern void vfile(const char *fmt,...);