home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / prog1 / zmnp11.lzh / ZMNP.H < prev    next >
C/C++ Source or Header  |  1990-02-08  |  8KB  |  182 lines

  1. /****************************************************************************
  2. *    Author        :    G Todd                                                    *
  3. *    Language     :    Turbo C 2.0                                                *
  4. *    Logfile        :    zmnp.h                                                    *
  5. *    Project        :    Comms library.                                            *
  6. *    Date         :    17 Jan 90                                                *
  7. *    Revision     :    1.1        GT    Originate.                                    *
  8. *****************************************************************************
  9. *    Purpose        :    Public definitions for comms library.                    *
  10. *                :    Copyright 1990 Giles Todd.                                *
  11. ****************************************************************************/
  12.  
  13. #ifndef ZMNP_H
  14. #define    ZMNP_H
  15.  
  16. /****************************************************************************
  17. *    Structure definitions.                                                    *
  18. ****************************************************************************/
  19.  
  20. /* MNP link status block */
  21.  
  22. struct link_stat_blk
  23.     {
  24.     unsigned int p_status;                    /* physical connection status    */
  25.     unsigned int l_status;                    /* MNP link status                */
  26.     unsigned int s_count;                    /* Tx buf bytes free            */
  27.     unsigned int r_count;                    /* Rx buf bytes ready            */
  28.     unsigned int all_sent;                    /* all sent flag                */
  29.     };
  30.  
  31.  
  32. /****************************************************************************
  33. *    Basic async comms functions.                                            *
  34. ****************************************************************************/
  35.  
  36. /****************************************************************************
  37. *    connect                                                                    *
  38. *    Initialise 8250 and interrupt vectors.                                    *
  39. ****************************************************************************/
  40.  
  41. int connect (int rate, int data, int parity, int stop, int port, int handshake);
  42.  
  43. /****************************************************************************
  44. *    hang_up                                                                    *
  45. *    Drops DTR for half a second.                                            *
  46. ****************************************************************************/
  47.  
  48. void hangup (void);
  49.  
  50. /****************************************************************************
  51. *    disconnect                                                                *
  52. *    Hang up, restore 8250 settings and remove isr.                            *
  53. ****************************************************************************/
  54.  
  55. void disconnect (void);
  56.  
  57. /****************************************************************************
  58. *    send                                                                    *
  59. *    Insert up to <buflen> bytes from <sndbuf> into the Tx buffer.  Return    *
  60. *    number of bytes inserted.                                                *
  61. ****************************************************************************/
  62.  
  63. int send (unsigned char *sndbuf, unsigned int buflen);
  64.  
  65. /****************************************************************************
  66. *    receive                                                                    *
  67. *    Copy up to <buflen> bytes from <rxbuf> into <rcvbuf>.  Return number of    *
  68. *    bytes copied.                                                            *
  69. ****************************************************************************/
  70.  
  71. int receive (unsigned char *rcvbuf, unsigned int buflen);
  72.  
  73. /****************************************************************************
  74. *    bufstat                                                                    *
  75. *    Returns number of bytes free in Tx buffer and number of bytes ready in    *
  76. *    Rx buffer.                                                                *
  77. ****************************************************************************/
  78.  
  79. void bufstat (unsigned short *s_free, unsigned short *r_ready);
  80.  
  81. /****************************************************************************
  82. *    linestat                                                                *
  83. *    Returns the latest copy of the 8250 line status register.                *
  84. ****************************************************************************/
  85.  
  86. unsigned char linestat (void);
  87.  
  88. /****************************************************************************
  89. *    modemstat                                                                *
  90. *    Returns the latest copy of the 8250 modem status register.                *
  91. ****************************************************************************/
  92.  
  93. unsigned char modemstat (void);
  94.  
  95.  
  96. /****************************************************************************
  97. *    MNP 2 function prototypes.                                                *
  98. ****************************************************************************/
  99.  
  100. /****************************************************************************
  101. *    mnpconnect - establish an MNP link-connection.                            *
  102. *    synopsis:    retcode = mnpconnect (mode);                                *
  103. *    input:    unsigned int mode;        0 = originator/1 = answerer                *
  104. *    output:    int retcode;            establishment result                    *
  105. ****************************************************************************/
  106.  
  107. int mnpconnect (unsigned int mode);
  108.     
  109. /****************************************************************************
  110. *    mnpdisconnect - terminate an MNP link-connection.                        *
  111. *    synopsis:    mnpdisconnect ();                                            *
  112. *    input:    none                                                            *
  113. *    output:    none                                                            *
  114. ****************************************************************************/
  115.  
  116. void mnpdisconnect (void);
  117.  
  118. /****************************************************************************
  119. *    mnpreceive - receive data on an MNP link-connection.                    *
  120. *    synopsis:    retcode = mnpreceive (&buffer, buflen);                        *
  121. *    input:    unsigned char *buffer;    pointer to user buffer                    *
  122. *            int buflen;                length of user buffer                    *
  123. *    output:    int retcode;    if positive, the number of data bytes            *
  124. *                            copied into the user data buffer;                *
  125. *                            if negative, link error code                    *
  126. ****************************************************************************/
  127.  
  128. int mnpreceive (unsigned char *bufptr, unsigned int buflen);
  129.     
  130. /****************************************************************************
  131. *    mnpsend - send data on an MNP link-connection.                            *
  132. *    synopsis:    retcode = mnpsend (&buffer, buflen);                        *
  133. *    input:    unsigned char *buffer;     pointer to user data buffer                *
  134. *            int buflen;                length of user data buffer                *
  135. *    output: int retcode - if positive, the number of data bytes                *
  136. *                          copied from the user data buffer;                 *
  137. *                          if negative, link error code                        *
  138. ****************************************************************************/
  139.     
  140. int mnpsend (unsigned char *bufptr, unsigned int buflen);
  141.     
  142. /****************************************************************************
  143. *    mnpstatus - get link-connection status information.                        *
  144. *    synopsis:    mnpstatus (&lstat_blk);                                        *
  145. *    input:    struct link_stat_blk *lstat_blk;    pointer to status block        *
  146. *    output:    none                                                            *
  147. ****************************************************************************/
  148.     
  149. void mnpstatus (struct link_stat_blk *lsb);
  150.     
  151. /****************************************************************************
  152. *    mnpbreak - send a break signal (using MNP attention).                    *
  153. *    synopsis:    retcode = mnpbreak ();                                        *
  154. *    input:    none                                                            *
  155. *    output:    int retcode;    link error code                                    *
  156. ****************************************************************************/
  157.     
  158. int mnpbreak (void);
  159.  
  160.  
  161. /****************************************************************************
  162. *    ZMODEM function prototypes.                                                *
  163. ****************************************************************************/
  164.  
  165. /****************************************************************************
  166. *    sendfile.                                                                *
  167. *    Send file(s).  Returns 0 if successful.                                    *
  168. ****************************************************************************/
  169.  
  170. int sendfile (char protocol, char *options, char *filenames[],
  171.               void (*reporter) (int type, void *data));
  172.  
  173. /****************************************************************************
  174. *    getfile                                                                    *
  175. *    Receives file(s).  Returns 0 if successful.                                *
  176. ****************************************************************************/
  177.  
  178. int getfile (char protocol, char *options, char *filename,
  179.              void (*reporter) (int type, void *data));
  180.  
  181. #endif
  182.