home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / xmodem 3.10 / xmodem.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-10  |  3.8 KB  |  104 lines  |  [TEXT/MPS ]

  1. #include <ctype.h>
  2. #include <stdio.h>
  3. #include <sys/types.h>
  4. #include <sys/stat.h>
  5. #include <sys/time.h>
  6. #include <sgtty.h>
  7. #include <signal.h>
  8.  
  9. /* define macros to print messages in log file */
  10. #define  logit(string) if(LOGFLAG)fprintf(LOGFP,string)
  11. #define  logitarg(string,argument) if(LOGFLAG)fprintf(LOGFP,string,argument)
  12. #define  tlogit(string) if(TIPFLAG)fprintf(stderr,string)
  13. #define  tlogitarg(string,argument) if(TIPFLAG)fprintf(stderr,string,argument)
  14.  
  15. #define      FALSE      0
  16. #define      TRUE       1
  17.  
  18.  
  19. /*  ASCII Constants  */
  20. #define      SOH      001 
  21. #define         STX    002
  22. #define         ETX    003
  23. #define      EOT    004
  24. #define         ENQ    005
  25. #define      ACK      006
  26. #define         LF        012   /* Unix LF/NL */
  27. #define         CR        015  
  28. #define      NAK      025
  29. #define         SYN    026
  30. #define         CAN    030
  31. #define         ESC    033
  32.  
  33. /*  XMODEM Constants  */
  34. #define      TIMEOUT      -1
  35. #define      ERRORMAX      10    /* maximum errors tolerated while transferring a packet */
  36. #define      WAITFIRST  1     /* seconds between startup characters in read */
  37. #define      PACKWAIT   5     /* seconds to wait for start of packet */
  38. #define      STERRORMAX    60    /* maximum "errors" tolerated in read startup */
  39. #define      CRCSWMAX    30    /* maximum time to try CRC mode before switching */
  40. #define      NAKMAX    120   /* maximum times to wait for initial NAK when sending */
  41. #define      RETRYMAX      5     /* maximum retries to be made certain handshaking routines */
  42. #define      KSWMAX    5     /* maximum errors before switching to 128 byte packets */
  43. #define      EOTMAX    10    /* maximum times sender will send an EOT to end transfer */
  44. #define      SLEEPNUM    100   /* target number of characters to collect during sleepy time */
  45. #define         BBUFSIZ    1024  /* buffer size */
  46. #define      NAMSIZ    11    /* length of a CP/M file name string */
  47. #define         CTRLZ    032   /* CP/M EOF for text (usually!) */
  48. #define      CRCCHR    'C'   /* CRC request character */
  49. #define      KCHR    'K'   /* 1K block request character */
  50. #define      GCHR    'G'   /* Ymodem-G request character */
  51. #define      BAD_NAME    'u'   /* Bad filename indicator */
  52. #define      TIPDELAY    15    /* seconds to delay handshake startup when -w */
  53.  
  54. #define      CREATMODE    0644  /* mode for created files */
  55.  
  56. /* GLOBAL VARIABLES */
  57.  
  58. int ttyspeed;        /* tty speed (bits per second) */
  59. unsigned char buff[BBUFSIZ];    /* buffer for data */
  60. int nbchr;        /* number of chars read so far for buffered read */
  61. long filelength;    /* length specified in YMODEM header */
  62. long fileread;        /* characters actually read so far in file */
  63. char filename[256];    /* place to construct filenames */
  64. int yfilesleft;        /* # of files left for YMODEM header */
  65. long ytotleft;        /* # of bytes left for YMODEM header */
  66.  
  67. FILE *LOGFP;        /* descriptor for LOG file */
  68.  
  69. /* option flags and state variables */
  70. char    XMITTYPE;    /* text or binary? */
  71. int    DEBUG;        /* keep debugging info in log? */
  72. int    MOREDEBUG;    /* keep even more debugging info in log? */
  73. int    RECVFLAG;    /* receive? */
  74. int    SENDFLAG;    /* send? */
  75. int    BATCH;        /* batch? (Now used as a state variable) */
  76. int    CRCMODE;    /* CRC or checksums? */
  77. int    DELFLAG;    /* don't delete old log file? */
  78. int    LOGFLAG;    /* keep log? */
  79. int    LONGPACK;     /* do not use long packets on transmit? */
  80. int    MDM7BAT;    /* MODEM7 batch protocol */
  81. int    YMDMBAT;    /* YMODEM batch protocol */
  82. int    TOOBUSY;    /* turn off sleeping in packet read routine */
  83. int    TIPFLAG;    /* for tip ~C command */
  84. int    DELAYFLAG;    /* for startup delay */
  85. int    NOEOT;        /* suppress EOT verification */
  86. int    CANCAN;        /* allow CAN-CAN aborts anytime */
  87. int    YMODEMG;    /* YMODEM-G variant of YMODEM */
  88.  
  89. int    CHECKLENGTH;    /* Are we truncating a file to a YMODEM length? */
  90.  
  91.  
  92. /*   CRC-16 constants.  From Usenet contribution by Mark G. Mendel, 
  93.      Network Systems Corp.  (ihnp4!umn-cs!hyper!mark)
  94. */
  95.  
  96.     /* the CRC polynomial. */
  97. #define    P    0x1021
  98.  
  99.     /* number of bits in CRC */
  100. #define W    16
  101.  
  102.     /* the number of bits per char */
  103. #define B    8
  104.