home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / gkermit68k.tar.gz / gkermit68.tar / gkermit68 / gkermit.h < prev    next >
C/C++ Source or Header  |  2002-03-14  |  7KB  |  256 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 _GKERM_H
  31. #define _GKERM_H
  32.  
  33. /* avoid including stdio twice on CP/M-68K */
  34. #ifndef CPM68K
  35. #include <stdio.h>
  36. #endif
  37.  
  38. /* Kermit protocol definitions */
  39.  
  40. #define MAXTRY 10            /* Packet retry limit */
  41.  
  42. #ifndef SMALL                /* Define small systems here */
  43. #ifdef pdp11                /* PDP-11 (64K address space) */
  44. #define SMALL
  45. #endif /* pdp11 */
  46. #endif /* SMALL */
  47.  
  48. #ifdef SMALL                /* Buffer sizes for small systems */
  49.  
  50. #define MAXSP 4000
  51. #define MAXRP 4000
  52. #define DEFRP 1000
  53. #define MAXPATHLEN 255
  54. #define DEVNAMLEN 64
  55. #define MAXRECORD 255
  56.  
  57. #else  /* 32-bit and 64-bit platforms... */
  58.  
  59. #ifndef MAXSP
  60. #define MAXSP 9000            /* Maximum send packet size */
  61. #endif /* MAXSP */
  62.  
  63. #ifndef MAXRP                /* Maximum receive packet size */
  64. #define MAXRP 9000
  65. #endif /* MAXRP */
  66.  
  67. #ifndef DEFRP                /* Default receive packet size */
  68. #define DEFRP 4000
  69. #endif /* DEFRP */
  70.  
  71. #endif /* SMALL */
  72.  
  73. #define CTTNAM  "/dev/tty"        /* Default terminal name */
  74.  
  75. /* Sizes for file/device-name and file i/o buffers */
  76.  
  77. #ifndef MAXPATHLEN            /* Maximum file specification length */
  78. #define MAXPATHLEN 1024
  79. #endif /* MAXPATHLEN */
  80.  
  81. #ifndef MAXNAMLEN            /* Maximum file name length */
  82. #define MAXNAMLEN 256
  83. #endif /* MAXNAMLEN */
  84.  
  85. #ifndef DEVNAMLEN            /* Maximum device name length */
  86. #define DEVNAMLEN 1024
  87. #endif /* DEVNAMLEN */
  88.  
  89. #ifndef MAXRECORD            /* Text file input buffer length */
  90. #define MAXRECORD 4080
  91. #endif /* MAXRECORD */
  92.  
  93. #ifdef __STDC__
  94. #define VOID void
  95. #else
  96. #ifndef CPM68K        /* CP/M-68K 1.3 has void */
  97. #define VOID int
  98. #endif
  99. #endif /* __STDC__ */
  100.  
  101. /* SVORPOSIX = System V or POSIX */
  102.  
  103. #ifndef SVORPOSIX
  104. #ifdef POSIX
  105. #define SVORPOSIX
  106. #else
  107. #ifdef SYSV
  108. #define SVORPOSIX
  109. #endif /* SYSV */
  110. #endif /* POSIX */
  111. #endif /* SVORPOSIX */
  112.  
  113. /* Signal type */
  114.  
  115. #ifndef SIG_V
  116. #ifndef SIG_I
  117. #ifdef SVORPOSIX
  118. #define SIG_V
  119. #else
  120. #define SIG_I
  121. #endif /* SVORPOSIX */
  122. #endif /* SIG_I */
  123. #endif /* SIG_V */
  124.  
  125. #ifdef SIG_I
  126. #define SIGRETURN return(0)
  127. #ifndef SIGTYP
  128. #define SIGTYP int
  129. #endif /* SIGTYP */
  130. #else
  131. #ifdef SIG_V
  132. #define SIGRETURN return
  133. #ifndef SIGTYP
  134. #define SIGTYP void
  135. #endif /* SIGTYP */
  136. #endif /* SIG_V */
  137. #endif /* SIG_I */
  138.  
  139. /* WHATAMI bit definitions */
  140.  
  141. #define WMI_FMODE   2            /* File transfer mode */
  142. #define WMI_FNAME   4            /* File name conversion */
  143. #define WMI_STREAM  8            /* I have a reliable transport */
  144. #define WMI_CLEAR  16            /* I have a clear channel */
  145. #define WMI_FLAG   32            /* Flag that WHATAMI field is valid */
  146. #define WMI2_XMODE  1            /* Transfer mode auto(0)/manual(1) */
  147. #define WMI2_RECU   2            /* Transfer is recursive */
  148. #define WMI2_FLAG  32            /* Flag that WHATAMI2 field is valid */
  149.  
  150. /* Data types */
  151.  
  152. #ifndef CHAR
  153. #define CHAR unsigned char
  154. #endif /* CHAR */
  155.  
  156. #ifndef ULONG
  157. #define ULONG unsigned long
  158. #endif /* ULONG */
  159.  
  160. /* Pointer and character constants */
  161.  
  162. #ifndef NULL
  163. #define NULL 0                /* NULL pointer */
  164. #endif /* NULL */
  165.  
  166. #define NUL '\000'            /* ASCII NUL character */
  167. #define LF  '\012'            /* ASCII Linefeed */
  168. #define CR  '\015'            /* ASCII Carriage Return */
  169. #define SP  '\040'            /* ASCII space character */
  170. #define DEL 127                /* ASCII DEL */
  171.  
  172. /* Macros */
  173.  
  174. #define tochar(ch)  ((ch) + SP )    /* Number to character */
  175. #define xunchar(ch) ((ch) - SP )    /* Character to number */
  176. #define ctl(ch)     ((ch) ^ 64 )    /* Controllify/Uncontrollify */
  177. #define zgetc(a) (((--zincnt)>=0) ? ((int)(*zinptr++) & 0xff) : zfillbuf(a))
  178.  
  179. /* Function prototype macro works for both ANSI and K&R C */
  180.  
  181. #ifdef __STDC__
  182. #define _MYPROTOTYPE( func, parms ) func parms
  183. #else
  184. #define _MYPROTOTYPE( func, parms ) func()
  185. #endif /* __STDC__ */
  186.  
  187. /* Function prototypes */
  188.  
  189. _MYPROTOTYPE( SIGTYP doexit, (int) );
  190. _MYPROTOTYPE( VOID sysinit, (void) );
  191. _MYPROTOTYPE( char dopar, (char) );
  192. _MYPROTOTYPE( VOID tmsg, (char *) );
  193. _MYPROTOTYPE( VOID tmsgl, (char *) );
  194. _MYPROTOTYPE( int ttopen, (char *) );
  195. _MYPROTOTYPE( int ttpkt, (int) );
  196. _MYPROTOTYPE( int ttres, (void) );
  197. _MYPROTOTYPE( int ttinl, (char *, int, int, char, char, int) );
  198. _MYPROTOTYPE( int ttol, (char *, int) );
  199. _MYPROTOTYPE( int ttchk, (void) );
  200. _MYPROTOTYPE( int ttflui, (void) );
  201. _MYPROTOTYPE( long zchki, (char *) );
  202. _MYPROTOTYPE( int zchko, (char *) );
  203. _MYPROTOTYPE( int zopeni, (char *) );
  204. _MYPROTOTYPE( int zopeno, (char *) );
  205. _MYPROTOTYPE( int zclosi, (void) );
  206. _MYPROTOTYPE( int zcloso, (int) );
  207. _MYPROTOTYPE( int zfillbuf, (int) );
  208. _MYPROTOTYPE( VOID zltor, (char *, char *, int) );
  209. _MYPROTOTYPE( int zrtol, (char *, char *, int, int) );
  210. _MYPROTOTYPE( int zbackup, (char *) );
  211.  
  212. _MYPROTOTYPE( int input, (void) );    /* Input to state machine (like lex) */
  213. _MYPROTOTYPE( VOID nxtpkt, (void) );    /* Increment packet number */
  214. _MYPROTOTYPE( int ack, (void) );    /* Send empty Acknowledgment */
  215. _MYPROTOTYPE( int ack1, (char *) );    /* Send data-bearing Acknowledgment */
  216. _MYPROTOTYPE( int nak, (void) );    /* Send Negative acknowledgement */
  217. _MYPROTOTYPE( VOID tinit, (void) );    /* Transaction initialization */
  218. _MYPROTOTYPE( VOID errpkt, (char *) );    /* Send error packet */
  219. _MYPROTOTYPE( int sinit, (char) );    /* Send S packet */
  220. _MYPROTOTYPE( int sfile, (void) );    /* Send File header packet */
  221. _MYPROTOTYPE( int sdata, (void) );    /* Send Data packet */
  222. _MYPROTOTYPE( int seof, (char *) );    /* Send EOF packet */
  223. _MYPROTOTYPE( int seot, (void) );    /* Send EOT packet */
  224. _MYPROTOTYPE( int resend, (void) );    /* Resend a packet */
  225. _MYPROTOTYPE( int decode, (int) );    /* Decode packet data field */
  226. _MYPROTOTYPE( int encstr, (char *) );    /* Encode a memory string */
  227. _MYPROTOTYPE( int gattr, (char *) );    /* Get incoming file attributes */
  228. _MYPROTOTYPE( int sattr, (void) );    /* Send file attributes */
  229. _MYPROTOTYPE( VOID ginit, (void) );    /* Transaction initialization */
  230. _MYPROTOTYPE( int scmd, (char, char *) ); /* Send command to Kermit server */
  231. _MYPROTOTYPE( VOID rinit, (void) );    /* Receive initialization */
  232. _MYPROTOTYPE( int gnfile, (void) );    /* Get next filename */
  233. _MYPROTOTYPE( int rcvfil, (void) );    /* Receive incoming file */
  234. _MYPROTOTYPE( VOID spar, (char *) );    /* Set parameters from other Kermit */
  235. _MYPROTOTYPE( char *rpar, (void) );    /* Tell parameters to other Kermit */
  236. _MYPROTOTYPE( VOID usage, (void) );    /* Give usage message */
  237. _MYPROTOTYPE( int gwart, (void) );    /* State table switcher */
  238.  
  239. #ifdef CPM68K
  240. /* function prototypes for CP/M-68K */
  241. _MYPROTOTYPE( FILE *fopen, (void) );
  242. _MYPROTOTYPE( FILE *fopenb, (void) );
  243. _MYPROTOTYPE( char *malloc, (void) );
  244. #endif
  245.  
  246. /* Externs */
  247.  
  248. extern int errno;
  249. #ifndef _GKERMIT_C
  250. extern int debug;
  251. #endif /* _GKERMIT_C */
  252.  
  253. #endif /* _GKERM_H */
  254.  
  255. /* End gkermit.h */
  256.