home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / n / n002 / 4.ddi / ECLHEAD.ZIP / YM.H < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-15  |  6.9 KB  |  142 lines

  1. #ifndef YM_H
  2. #define YM_H
  3.   
  4. #define SOH_BUF_LEN            128
  5. #define STX_BUF_LEN            1024
  6. #define MAX_BUF_LEN            1024
  7. #define SOH_FRAME_LEN          133
  8. #define STX_FRAME_LEN          1029
  9. #define SOH_FR_LEN_MINUS_ONE   132
  10. #define STX_FR_LEN_MINUS_ONE   1028
  11. #define MAX_FRAME_LEN          1029
  12.   
  13.   
  14. #define SPACE   0X20
  15. #define BS      0X08
  16.   
  17. /* YMODEM file xfer types */
  18. #define    YM_REC                 0
  19. #define    YM_SEND                1
  20.   
  21. /* MACRO EXPANSION FOR AND ALLOWABLE VALUES OF YM_ABORT_FLAG(port_no) */
  22. #define YM_ABORT_FLAG(port_no)      xmk_abort_flag[port_no]
  23. #define   YM_NO_ABORT    0   /* no Control-Break or Data Carrier Detect enabled */
  24. #define   YM_CB          1   /* Only Control-Break enabled */
  25. #define   YM_DCD         2   /* Only Data Carrier Detect enabled */
  26. #define   YM_CB_AND_DCD  3   /* Control-Break and Data Carrier Detect enabled */
  27.   
  28. /* YMODEM file xfer status values */
  29. #define    YM_COMPL             1
  30. #define    YM_OK                0
  31. #define    YM_SESS             -1
  32. #define    YM_NAK              -2
  33. #define    YM_CANC             -3
  34. #define    YM_ABORT            -4
  35. #define    YM_FIO              -6
  36. #define    YM_SILENCE          -7
  37. #define    YM_NO_DCD           -8
  38. #define    YM_OUT_OF_MEM       -9
  39. #define    YM_INVALID_FRAME    -10
  40.   
  41. /* Times to send out 'C's before sending out NAKs */
  42. #define    YM_C_RETRIES           5
  43.   
  44. /* Times to wait for 'C's or NAKs before canceling session */
  45.  
  46. #define    YM_WAIT_RETRIES        7
  47.   
  48. /* YMODEM file xfer states : allowable values for ym_xfer_state[comm port] */
  49. #define    YM_NOT_IN_PROGRESS     0
  50.                                       /* YMODEM BATCH */
  51. #define    YM_WAIT_C_NAK          1   /* Wait for initial C or NAK to begin batch session */
  52. #define    YM_FORM_FR0            2   /* create frame 0 */
  53. #define    YM_SND_FR0             3   /* send frame 0 */
  54. #define    YM_SET_TIMER           4   /* wait for frame 0 to be sent, then set timer */
  55. #define    YM_WAIT_FR0_ACK        5   /* wait for ACK of frame 0 */
  56. #define    YM_SND_XMK             6   /* send file via XMODEM services */
  57. #define    YM_SEND_C              7   /* send initial C to begin session */
  58. #define    YM_SEND_NAK            8   /* send initial NAK to begin session */
  59. #define    YM_REC_XMK             9   /* receive file via XMODEM services */
  60.                                       /* YMODEM G */
  61. #define    YM_G_WAIT_G           10   /* Wait for initial G to begin batch session */
  62. #define    YM_G_SND_F0           11   /* send frame 0 */
  63. #define    YM_G_SET_TIMER        12   /* wait for frame 0 to be sent, then set timer */
  64. #define    YM_G_WAIT_F0_G        13   /* wait for G response to frame 0 */
  65. #define    YM_G_SND_OPEN_FILE    14   /* open file to xfer */
  66. #define    YM_G_SND_FRAME        15   /* sent one frame of file data */
  67. #define    YM_G_WAIT_FRAME_SENT  16   /* wait for frame to be sent before sending next frame */
  68. #define    YM_G_SND_EOT          17   /* all frames sent, now send EOT */
  69. #define    YM_G_REC_EOT_ACK      18   /* receive ACK of sent EOT */
  70. #define    YM_G_WAIT_NULL_F0_ACK 19   /* wait for ACK of sent null frame 0 */
  71. #define    YM_G_SND_FILE_COMPL   20   /* file send completed */
  72. #define    YM_G_SND_G            21   /* send initial G to begin batch session */
  73. #define    YM_G_WAIT_F0          22   /* wait for frame 0 */
  74. #define    YM_G_SND_F0_G         23   /* send G in response to good frame 0 */
  75. #define    YM_G_REC_OPEN_FILE    24   /* open file to receive */
  76. #define    YM_G_REC_FILE         25   /* receive file */
  77. #define    YM_G_SND_EOT_ACK      26   /* send ACK in reponse to EOT */
  78. #define    YM_G_REC_FILE_COMPL   27   /* receive file completed */
  79.   
  80. /* YMODEM file description structure */
  81.   
  82. typedef struct {
  83.     char filename[13];     /* file to be xfered */
  84.     /* THE FOLLOWING FEILDS ARE OPTIONAL AND CAN BE SET AS A NULL STRING */
  85.     char file_length[10];  /* decimal string. if unknown, =0 or null  */
  86.     unsigned long int i_filelength; /* integer representation of file length */
  87.     char mod_date[40];     /* octal string: # of sec. from 1/1/80 */
  88.                           /* 0 = unknown and current date used   */
  89.     char mode[10];     /* octal string; =0 for non unix systems */
  90.     char ser_no[10];   /* octal string; if unknown, =0 or null */
  91. } YM_FILE_DESC;
  92.   
  93.   
  94. typedef struct {
  95.     int   no_of_files;  /* number of files in array of file info. */
  96.     int   current_file; /* current file number being sent */
  97.     char   file_cnt;     /* count of files sent */
  98.     char   path[64];     /* path of files to xfer */
  99.     char   filespec[77];  /* path + filename */
  100.     unsigned long int   bytes_xfered; /* no. of bytes currently xfered */
  101.     YM_FILE_DESC   *ym_file_info; /* pointer to file information */
  102. } YM_FILE_TABLE;
  103.   
  104.   
  105. /************* MACRO EXPANSIONS FOR ym_file_table_ptr[] ******************/
  106. #define  YM_FILES(comm_port)              ym_file_table_ptr[comm_port]->no_of_files
  107. #define  YM_CUR_FILE(comm_port)           ym_file_table_ptr[comm_port]->current_file
  108. #define  YM_FILE_CNT(comm_port)           ym_file_table_ptr[comm_port]->file_cnt
  109. #define  YM_PATH(comm_port)               ym_file_table_ptr[comm_port]->path
  110. #define  YM_FILESPEC(comm_port)           ym_file_table_ptr[comm_port]->filespec
  111. #define  YM_BYTES_XFERED(comm_port)       (ym_file_table_ptr[comm_port])->bytes_xfered
  112. #define  YM_FILE_DESC_PTR(comm_port)      ym_file_table_ptr[comm_port]->ym_file_info
  113. #define  YM_CUR_FILE_PTR(comm_port)       (YM_FILE_DESC*)(YM_FILE_DESC_PTR(comm_port)+YM_CUR_FILE(comm_port))
  114. #define  YM_CUR_FILE_INFO(comm_port)      (ym_file_table_ptr[comm_port])->ym_file_info[YM_CUR_FILE(comm_port)]
  115. #define  YM_CUR_FILENAME(comm_port)       YM_CUR_FILE_INFO(comm_port).filename
  116. #define  YM_CUR_FILELENGTH(comm_port)     YM_CUR_FILE_INFO(comm_port).file_length
  117. #define  YM_CUR_I_FILELENGTH(comm_port)   YM_CUR_FILE_INFO(comm_port).i_filelength
  118. #define  YM_CUR_FMOD_DATE(comm_port)      YM_CUR_FILE_INFO(comm_port).mod_date
  119. #define  YM_CUR_FILE_MODE(comm_port)      YM_CUR_FILE_INFO(comm_port).mode
  120. #define  YM_CUR_FILE_SN(comm_port)        YM_CUR_FILE_INFO(comm_port).ser_no
  121.   
  122.   
  123. /* MACRO EXPANSIONS USED IN ym_bld_xfer_table() FOR COMPILER PORTABILITY */
  124. #ifdef __TURBOC__
  125. #define YM_FIND_FIRST(path,buf_ptr)     findfirst(path,buf_ptr,0)
  126. #define YM_FIND_NEXT(buf_ptr)           findnext(buf_ptr)
  127. #define YM_FILE_NAME                    fib.ff_name
  128. #define YM_FILE_LENGTH                  fib.ff_fsize
  129. #define YM_FILE_DATE                    fib.ff_fdate
  130. #endif
  131.   
  132. #ifdef M_I86
  133. #define YM_FIND_FIRST(path,buf_ptr)     _dos_findfirst(path,_A_NORMAL,buf_ptr)
  134. #define YM_FIND_NEXT(buf_ptr)           _dos_findnext(buf_ptr)
  135. #define YM_FILE_NAME                    fib.name
  136. #define YM_FILE_LENGTH                  fib.size
  137. #define YM_FILE_DATE                    fib.wr_date
  138. #endif
  139. /********/
  140.   
  141. #endif /* YM_H */
  142.