home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / gkermit.h < prev    next >
C/C++ Source or Header  |  2020-01-01  |  7KB  |  244 lines

  1. /* G K E R M I T . H  --  GNU Kermit header  */
  2. /*
  3.   Author:
  4.     Frank da Cruz
  5.     The Kermit Project
  6.     Columbia University
  7.     612 West 115th Street
  8.     New York NY 10025-7799  USA
  9.     http://www.columbia.edu/kermit/
  10.     kermit@columbia.edu
  11.  
  12.   Copyright (C) 1999,
  13.   The Trustees of Columbia University in the City of New York.
  14.  
  15.   This program is free software; you can redistribute it and/or modify
  16.   it under the terms of the GNU General Public License as published by
  17.   the Free Software Foundation; either version 2 of the License, or
  18.   (at your option) any later version.
  19.  
  20.   This program is distributed in the hope that it will be useful,
  21.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  22.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23.   GNU General Public License for more details.
  24.  
  25.   You should have received a copy of the GNU General Public License
  26.   along with this program; if not, write to the Free Software
  27.   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  28. */
  29.  
  30. #ifndef _GKERMIT_H
  31. #define _GKERMIT_H
  32.  
  33. #include <stdio.h>
  34.  
  35. /* Kermit protocol definitions */
  36.  
  37. #define MAXTRY 10            /* Packet retry limit */
  38.  
  39. #ifndef SMALL                /* Define small systems here */
  40. #ifdef pdp11                /* PDP-11 (64K address space) */
  41. #define SMALL
  42. #endif /* pdp11 */
  43. #endif /* SMALL */
  44.  
  45. #ifdef SMALL                /* Buffer sizes for small systems */
  46.  
  47. #define MAXSP 4000
  48. #define MAXRP 4000
  49. #define DEFRP 1000
  50. #define MAXPATHLEN 255
  51. #define DEVNAMLEN 64
  52. #define MAXRECORD 255
  53.  
  54. #else  /* 32-bit and 64-bit platforms... */
  55.  
  56. #ifndef MAXSP
  57. #define MAXSP 9000            /* Maximum send packet size */
  58. #endif /* MAXSP */
  59.  
  60. #ifndef MAXRP                /* Maximum receive packet size */
  61. #define MAXRP 9000
  62. #endif /* MAXRP */
  63.  
  64. #ifndef DEFRP                /* Default receive packet size */
  65. #define DEFRP 4000
  66. #endif /* DEFRP */
  67.  
  68. #endif /* SMALL */
  69.  
  70. #define CTTNAM  "/dev/tty"        /* Default terminal name */
  71.  
  72. /* Sizes for file/device-name and file i/o buffers */
  73.  
  74. #ifndef MAXPATHLEN            /* Maximum file specification length */
  75. #define MAXPATHLEN 1024
  76. #endif /* MAXPATHLEN */
  77.  
  78. #ifndef MAXNAMLEN            /* Maximum file name length */
  79. #define MAXNAMLEN 256
  80. #endif /* MAXNAMLEN */
  81.  
  82. #ifndef DEVNAMLEN            /* Maximum device name length */
  83. #define DEVNAMLEN 1024
  84. #endif /* DEVNAMLEN */
  85.  
  86. #ifndef MAXRECORD            /* Text file input buffer length */
  87. #define MAXRECORD 4080
  88. #endif /* MAXRECORD */
  89.  
  90. #ifdef __STDC__
  91. #define VOID void
  92. #else
  93. #define VOID int
  94. #endif /* __STDC__ */
  95.  
  96. /* SVORPOSIX = System V or POSIX */
  97.  
  98. #ifndef SVORPOSIX
  99. #ifdef POSIX
  100. #define SVORPOSIX
  101. #else
  102. #ifdef SYSV
  103. #define SVORPOSIX
  104. #endif /* SYSV */
  105. #endif /* POSIX */
  106. #endif /* SVORPOSIX */
  107.  
  108. /* Signal type */
  109.  
  110. #ifndef SIG_V
  111. #ifndef SIG_I
  112. #ifdef SVORPOSIX
  113. #define SIG_V
  114. #else
  115. #define SIG_I
  116. #endif /* SVORPOSIX */
  117. #endif /* SIG_I */
  118. #endif /* SIG_V */
  119.  
  120. #ifdef SIG_I
  121. #define SIGRETURN return(0)
  122. #ifndef SIGTYP
  123. #define SIGTYP int
  124. #endif /* SIGTYP */
  125. #else
  126. #ifdef SIG_V
  127. #define SIGRETURN return
  128. #ifndef SIGTYP
  129. #define SIGTYP void
  130. #endif /* SIGTYP */
  131. #endif /* SIG_V */
  132. #endif /* SIG_I */
  133.  
  134. /* WHATAMI bit definitions */
  135.  
  136. #define WMI_FMODE   2            /* File transfer mode */
  137. #define WMI_FNAME   4            /* File name conversion */
  138. #define WMI_STREAM  8            /* I have a reliable transport */
  139. #define WMI_CLEAR  16            /* I have a clear channel */
  140. #define WMI_FLAG   32            /* Flag that WHATAMI field is valid */
  141. #define WMI2_XMODE  1            /* Transfer mode auto(0)/manual(1) */
  142. #define WMI2_RECU   2            /* Transfer is recursive */
  143. #define WMI2_FLAG  32            /* Flag that WHATAMI2 field is valid */
  144.  
  145. /* Data types */
  146.  
  147. #ifndef CHAR
  148. #define CHAR unsigned char
  149. #endif /* CHAR */
  150.  
  151. #ifndef ULONG
  152. #define ULONG unsigned long
  153. #endif /* ULONG */
  154.  
  155. /* Pointer and character constants */
  156.  
  157. #ifndef NULL
  158. #define NULL 0                /* NULL pointer */
  159. #endif /* NULL */
  160.  
  161. #define NUL '\000'            /* ASCII NUL character */
  162. #define LF  '\012'            /* ASCII Linefeed */
  163. #define CR  '\015'            /* ASCII Carriage Return */
  164. #define SP  '\040'            /* ASCII space character */
  165. #define DEL 127                /* ASCII DEL */
  166.  
  167. /* Macros */
  168.  
  169. #define tochar(ch)  ((ch) + SP )    /* Number to character */
  170. #define xunchar(ch) ((ch) - SP )    /* Character to number */
  171. #define ctl(ch)     ((ch) ^ 64 )    /* Controllify/Uncontrollify */
  172. #define zgetc(a) (((--zincnt)>=0) ? ((int)(*zinptr++) & 0xff) : zfillbuf(a))
  173.  
  174. /* Function prototype macro works for both ANSI and K&R C */
  175.  
  176. #ifdef __STDC__
  177. #define _MYPROTOTYPE( func, parms ) func parms
  178. #else
  179. #define _MYPROTOTYPE( func, parms ) func()
  180. #endif /* __STDC__ */
  181.  
  182. /* Function prototypes */
  183.  
  184. _MYPROTOTYPE( SIGTYP doexit, (int) );
  185. _MYPROTOTYPE( VOID sysinit, (void) );
  186. _MYPROTOTYPE( char dopar, (char) );
  187. _MYPROTOTYPE( VOID tmsg, (char *) );
  188. _MYPROTOTYPE( VOID tmsgl, (char *) );
  189. _MYPROTOTYPE( int ttopen, (char *) );
  190. _MYPROTOTYPE( int ttpkt, (int) );
  191. _MYPROTOTYPE( int ttres, (void) );
  192. _MYPROTOTYPE( int ttinl, (char *, int, int, char, char, int) );
  193. _MYPROTOTYPE( int ttol, (char *, int) );
  194. _MYPROTOTYPE( int ttchk, (void) );
  195. _MYPROTOTYPE( int ttflui, (void) );
  196. _MYPROTOTYPE( long zchki, (char *) );
  197. _MYPROTOTYPE( int zchko, (char *) );
  198. _MYPROTOTYPE( int zopeni, (char *) );
  199. _MYPROTOTYPE( int zopeno, (char *) );
  200. _MYPROTOTYPE( int zclosi, (void) );
  201. _MYPROTOTYPE( int zcloso, (int) );
  202. _MYPROTOTYPE( int zfillbuf, (int) );
  203. _MYPROTOTYPE( VOID zltor, (char *, char *, int) );
  204. _MYPROTOTYPE( int zrtol, (char *, char *, int, int) );
  205. _MYPROTOTYPE( int zbackup, (char *) );
  206.  
  207. _MYPROTOTYPE( int input, (void) );    /* Input to state machine (like lex) */
  208. _MYPROTOTYPE( VOID nxtpkt, (void) );    /* Increment packet number */
  209. _MYPROTOTYPE( int ack, (void) );    /* Send empty Acknowledgment */
  210. _MYPROTOTYPE( int ack1, (char *) );    /* Send data-bearing Acknowledgment */
  211. _MYPROTOTYPE( int nak, (void) );    /* Send Negative acknowledgement */
  212. _MYPROTOTYPE( VOID tinit, (void) );    /* Transaction initialization */
  213. _MYPROTOTYPE( VOID errpkt, (char *) );    /* Send error packet */
  214. _MYPROTOTYPE( int sinit, (char) );    /* Send S packet */
  215. _MYPROTOTYPE( int sfile, (void) );    /* Send File header packet */
  216. _MYPROTOTYPE( int sdata, (void) );    /* Send Data packet */
  217. _MYPROTOTYPE( int seof, (char *) );    /* Send EOF packet */
  218. _MYPROTOTYPE( int seot, (void) );    /* Send EOT packet */
  219. _MYPROTOTYPE( int resend, (void) );    /* Resend a packet */
  220. _MYPROTOTYPE( int decode, (int) );    /* Decode packet data field */
  221. _MYPROTOTYPE( int encstr, (char *) );    /* Encode a memory string */
  222. _MYPROTOTYPE( int gattr, (char *) );    /* Get incoming file attributes */
  223. _MYPROTOTYPE( int sattr, (void) );    /* Send file attributes */
  224. _MYPROTOTYPE( VOID ginit, (void) );    /* Transaction initialization */
  225. _MYPROTOTYPE( int scmd, (char, char *) ); /* Send command to Kermit server */
  226. _MYPROTOTYPE( VOID rinit, (void) );    /* Receive initialization */
  227. _MYPROTOTYPE( int gnfile, (void) );    /* Get next filename */
  228. _MYPROTOTYPE( int rcvfil, (void) );    /* Receive incoming file */
  229. _MYPROTOTYPE( VOID spar, (char *) );    /* Set parameters from other Kermit */
  230. _MYPROTOTYPE( char *rpar, (void) );    /* Tell parameters to other Kermit */
  231. _MYPROTOTYPE( VOID usage, (void) );    /* Give usage message */
  232. _MYPROTOTYPE( int gwart, (void) );    /* State table switcher */
  233.  
  234. /* Externs */
  235.  
  236. extern int errno;
  237. #ifndef _GKERMIT_C
  238. extern int debug;
  239. #endif /* _GKERMIT_C */
  240.  
  241. #endif /* _GKERMIT_H */
  242.  
  243. /* End gkermit.h */
  244.