home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / uucp / Uucp.framework / prot.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-20  |  11.3 KB  |  271 lines

  1. /* prot.h
  2.    Protocol header file.
  3.  
  4.    Copyright (C) 1991, 1992, 1993, 1994, 1995 Ian Lance Taylor
  5.  
  6.    This file is part of the Taylor UUCP package.
  7.  
  8.    This program is free software; you can redistribute it and/or
  9.    modify it under the terms of the GNU General Public License as
  10.    published by the Free Software Foundation; either version 2 of the
  11.    License, or (at your option) any later version.
  12.  
  13.    This program is distributed in the hope that it will be useful, but
  14.    WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.    General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU General Public License
  19.    along with this program; if not, write to the Free Software
  20.    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  21.  
  22.    The author of the program may be contacted at ian@airs.com or
  23.    c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
  24.    */
  25.  
  26. /* We need the definition of uuconf_cmdtab to declare the protocol
  27.    parameter arrays.  */
  28. #ifndef UUCONF_H
  29. #include "uuconf.h"
  30. #endif
  31.  
  32. #if ANSI_C
  33. /* These structures are used in prototypes but are not defined in this
  34.    header file.  */
  35. struct sdaemon;
  36. struct sconnection;
  37. struct stransfer;
  38. #endif
  39.  
  40. /* The sprotocol structure holds information and functions for a specific
  41.    protocol (e.g. the 'g' protocol).  */
  42.  
  43. struct sprotocol
  44. {
  45.   /* The name of the protocol (e.g. 'g').  */
  46.   char bname;
  47.   /* Reliability requirements, an or of UUCONF_RELIABLE_xxx defines
  48.      from uuconf.h.  */
  49.   int ireliable;
  50.   /* The maximum number of channels this protocol can support.  */
  51.   int cchans;
  52.   /* Whether files may be reliably restarted using this protocol.  */
  53.   boolean frestart;
  54.   /* Protocol parameter commands.  */
  55.   struct uuconf_cmdtab *qcmds;
  56.   /* A routine to start the protocol.  If *pzlog is set to be
  57.      non-NULL, it is an informative message to be logged; it should
  58.      then be passed to ubuffree.  */
  59.   boolean (*pfstart) P((struct sdaemon *qdaemon, char **pzlog));
  60.   /* Shutdown the protocol.  */
  61.   boolean (*pfshutdown) P((struct sdaemon *qdaemon));
  62.   /* Send a command to the other side.  */
  63.   boolean (*pfsendcmd) P((struct sdaemon *qdaemon, const char *z,
  64.               int ilocal, int iremote));
  65.   /* Get buffer to space to fill with data.  This should set *pcdata
  66.      to the amount of data desired.  */
  67.   char *(*pzgetspace) P((struct sdaemon *qdaemon, size_t *pcdata));
  68.   /* Send data to the other side.  The argument z must be a return
  69.      value of pzgetspace.  The ipos argument is the file position, and
  70.      is ignored by most protocols.  */
  71.   boolean (*pfsenddata) P((struct sdaemon *qdaemon, char *z, size_t c,
  72.                int ilocal, int iremote, long ipos));
  73.   /* Wait for data to come in and call fgot_data with it until
  74.      fgot_data sets *pfexit.  */
  75.   boolean (*pfwait) P((struct sdaemon *qdaemon));
  76.   /* Handle any file level actions that need to be taken.  If a file
  77.      transfer is starting rather than ending, fstart is TRUE.  If the
  78.      file is being sent rather than received, fsend is TRUE.  If
  79.      fstart and fsend are both TRUE, cbytes holds the size of the
  80.      file.  If *pfhandled is set to TRUE, then the protocol routine
  81.      has taken care of queueing up qtrans for the next action.  */
  82.   boolean (*pffile) P((struct sdaemon *qdaemon, struct stransfer *qtrans,
  83.                boolean fstart, boolean fsend, long cbytes,
  84.                boolean *pfhandled));
  85. };
  86.  
  87. /* Send data to the other system.  If the fread argument is TRUE, this
  88.    will also receive data into the receive buffer abPrecbuf; fread is
  89.    passed as TRUE if the protocol expects data to be coming back, to
  90.    make sure the input buffer does not fill up.  Returns FALSE on
  91.    error.  */
  92. extern boolean fsend_data P((struct sconnection *qconn,
  93.                  const char *zsend, size_t csend,
  94.                  boolean fdoread));
  95.  
  96. /* Receive data from the other system when there is no data to send.
  97.    The cneed argument is the amount of data desired and the ctimeout
  98.    argument is the timeout in seconds.  This will set *pcrec to the
  99.    amount of data received.  It will return FALSE on error.  If a
  100.    timeout occurs, it will return TRUE with *pcrec set to zero.  */
  101. extern boolean freceive_data P((struct sconnection *qconn, size_t cneed,
  102.                 size_t *pcrec, int ctimeout,
  103.                 boolean freport));
  104.  
  105. /* Get one character from the remote system, going through the
  106.    procotol buffering.  The ctimeout argument is the timeout in
  107.    seconds, and the freport argument is TRUE if errors should be
  108.    reported (when closing a connection it is pointless to report
  109.    errors).  This returns a character or -1 on a timeout or -2 on an
  110.    error.  */
  111. extern int breceive_char P((struct sconnection *qconn,
  112.                 int ctimeout, boolean freport));
  113.  
  114. /* Compute a 32 bit CRC of a data buffer, given an initial CRC.  */
  115. extern unsigned long icrc P((const char *z, size_t c, unsigned long ick));
  116.  
  117. /* The initial CRC value to use for a new buffer.  */
  118. #if ANSI_C
  119. #define ICRCINIT (0xffffffffUL)
  120. #else
  121. #define ICRCINIT ((unsigned long) 0xffffffffL)
  122. #endif
  123.  
  124. /* The size of the receive buffer.  */
  125. #define CRECBUFLEN (16384)
  126.  
  127. /* Buffer to hold received data.  */
  128. extern char abPrecbuf[CRECBUFLEN];
  129.  
  130. /* Index of start of data in abPrecbuf.  */
  131. extern int iPrecstart;
  132.  
  133. /* Index of end of data (first byte not included in data) in abPrecbuf.  */
  134. extern int iPrecend;
  135.  
  136. /* There are a couple of variables and functions that are shared by
  137.    the 'i' and 'j' protocols (the 'j' protocol is just a wrapper
  138.    around the 'i' protocol).  These belong in a separate header file,
  139.    protij.h, but I don't want to create one for just a couple of
  140.    things.  */
  141.  
  142. /* An escape sequence of characters for the 'j' protocol to avoid
  143.    (protocol parameter ``avoid'').  */
  144. extern const char *zJavoid_parameter;
  145.  
  146. /* Timeout to use when sending the 'i' protocol SYNC packet (protocol
  147.    parameter ``sync-timeout'').  */
  148. extern int cIsync_timeout;
  149.  
  150. /* Shared startup routine for the 'i' and 'j' protocols.  */
  151. extern boolean fijstart P((struct sdaemon *qdaemon, char **pzlog,
  152.                int imaxpacksize,
  153.                boolean (*pfsend) P((struct sconnection *qconn,
  154.                         const char *zsend,
  155.                         size_t csend,
  156.                         boolean fdoread)),
  157.                boolean (*pfreceive) P((struct sconnection *qconn,
  158.                            size_t cneed,
  159.                            size_t *pcrec,
  160.                            int ctimeout,
  161.                            boolean freport))));
  162.  
  163. /* Prototypes for 'g' protocol functions.  */
  164.  
  165. extern struct uuconf_cmdtab asGproto_params[];
  166. extern boolean fgstart P((struct sdaemon *qdaemon, char **pzlog));
  167. extern boolean fbiggstart P((struct sdaemon *qdaemon, char **pzlog));
  168. extern boolean fvstart P((struct sdaemon *qdaemon, char **pzlog));
  169. extern boolean fgshutdown P((struct sdaemon *qdaemon));
  170. extern boolean fgsendcmd P((struct sdaemon *qdaemon, const char *z,
  171.                 int ilocal, int iremote));
  172. extern char *zggetspace P((struct sdaemon *qdaemon, size_t *pcdata));
  173. extern boolean fgsenddata P((struct sdaemon *qdaemon, char *z, size_t c,
  174.                  int ilocal, int iremote, long ipos));
  175. extern boolean fgwait P((struct sdaemon *qdaemon));
  176.  
  177. /* Prototypes for 'f' protocol functions.  */
  178.  
  179. extern struct uuconf_cmdtab asFproto_params[];
  180. extern boolean ffstart P((struct sdaemon *qdaemon, char **pzlog));
  181. extern boolean ffshutdown P((struct sdaemon *qdaemon));
  182. extern boolean ffsendcmd P((struct sdaemon *qdaemon, const char *z,
  183.                 int ilocal, int iremote));
  184. extern char *zfgetspace P((struct sdaemon *qdaemon, size_t *pcdata));
  185. extern boolean ffsenddata P((struct sdaemon *qdaemon, char *z, size_t c,
  186.                  int ilocal, int iremote, long ipos));
  187. extern boolean ffwait P((struct sdaemon *qdaemon));
  188. extern boolean fffile P((struct sdaemon *qdaemon, struct stransfer *qtrans,
  189.              boolean fstart, boolean fsend, long cbytes,
  190.              boolean *pfhandled));
  191.  
  192. /* Prototypes for 't' protocol functions.  */
  193.  
  194. extern struct uuconf_cmdtab asTproto_params[];
  195. extern boolean ftstart P((struct sdaemon *qdaemon, char **pzlog));
  196. extern boolean ftshutdown P((struct sdaemon *qdaemon));
  197. extern boolean ftsendcmd P((struct sdaemon *qdaemon, const char *z,
  198.                 int ilocal, int iremote));
  199. extern char *ztgetspace P((struct sdaemon *qdaemon, size_t *pcdata));
  200. extern boolean ftsenddata P((struct sdaemon *qdaemon, char *z, size_t c,
  201.                  int ilocal, int iremote, long ipos));
  202. extern boolean ftwait P((struct sdaemon *qdaemon));
  203. extern boolean ftfile P((struct sdaemon *qdaemon, struct stransfer *qtrans,
  204.              boolean fstart, boolean fsend, long cbytes,
  205.              boolean *pfhandled));
  206.  
  207. /* Prototypes for 'e' protocol functions.  */
  208.  
  209. extern struct uuconf_cmdtab asEproto_params[];
  210. extern boolean festart P((struct sdaemon *qdaemon, char **pzlog));
  211. extern boolean feshutdown P((struct sdaemon *qdaemon));
  212. extern boolean fesendcmd P((struct sdaemon *qdaemon, const char *z,
  213.                 int ilocal, int iremote));
  214. extern char *zegetspace P((struct sdaemon *qdaemon, size_t *pcdata));
  215. extern boolean fesenddata P((struct sdaemon *qdaemon, char *z, size_t c,
  216.                  int ilocal, int iremote, long ipos));
  217. extern boolean fewait P((struct sdaemon *qdaemon));
  218. extern boolean fefile P((struct sdaemon *qdaemon, struct stransfer *qtrans,
  219.              boolean fstart, boolean fsend, long cbytes,
  220.              boolean *pfhandled));
  221.  
  222. /* Prototypes for 'i' protocol functions.  */
  223.  
  224. extern struct uuconf_cmdtab asIproto_params[];
  225. extern boolean fistart P((struct sdaemon *qdaemon, char **pzlog));
  226. extern boolean fishutdown P((struct sdaemon *qdaemon));
  227. extern boolean fisendcmd P((struct sdaemon *qdaemon, const char *z,
  228.                 int ilocal, int iremote));
  229. extern char *zigetspace P((struct sdaemon *qdaemon, size_t *pcdata));
  230. extern boolean fisenddata P((struct sdaemon *qdaemon, char *z, size_t c,
  231.                  int ilocal, int iremote, long ipos));
  232. extern boolean fiwait P((struct sdaemon *qdaemon));
  233.  
  234. /* Prototypes for 'j' protocol functions.  The 'j' protocol mostly
  235.    uses the 'i' protocol functions, but it has a couple of functions
  236.    of its own.  */
  237.  
  238. extern boolean fjstart P((struct sdaemon *qdaemon, char **pzlog));
  239. extern boolean fjshutdown P((struct sdaemon *qdaemon));
  240.  
  241. /* Prototypes for 'a' protocol functions (these use 'z' as the second
  242.    character because 'a' is a modified Zmodem protocol).  */
  243.  
  244. extern struct uuconf_cmdtab asZproto_params[];
  245. extern boolean fzstart P((struct sdaemon *qdaemon, char **pzlog));
  246. extern boolean fzshutdown P((struct sdaemon *qdaemon));
  247. extern boolean fzsendcmd P((struct sdaemon *qdaemon, const char *z,
  248.                 int ilocal, int iremote));
  249. extern char *zzgetspace P((struct sdaemon *qdaemon, size_t *pcdata));
  250. extern boolean fzsenddata P((struct sdaemon *qdaemon, char *z, size_t c,
  251.                  int ilocal, int iremote, long ipos));
  252. extern boolean fzwait P((struct sdaemon *qdaemon));
  253. extern boolean fzfile P((struct sdaemon *qdaemon, struct stransfer *qtrans,
  254.              boolean fstart, boolean fsend, long cbytes,
  255.              boolean *pfhandled));
  256.  
  257. /* Prototypes for 'y' protocol functions.  */
  258.  
  259. extern struct uuconf_cmdtab asYproto_params[];
  260. extern boolean fystart P((struct sdaemon *qdaemon, char **pzlog));
  261. extern boolean fyshutdown P((struct sdaemon *qdaemon));
  262. extern boolean fysendcmd P((struct sdaemon *qdaemon, const char *z,
  263.                 int ilocal, int iremote));
  264. extern char *zygetspace P((struct sdaemon *qdaemon, size_t *pcdata));
  265. extern boolean fysenddata P((struct sdaemon *qdaemon, char *z, size_t c,
  266.                  int ilocal, int iremote, long ipos));
  267. extern boolean fywait P((struct sdaemon *qdaemon));
  268. extern boolean fyfile P((struct sdaemon *qdaemon, struct stransfer *qtrans,
  269.              boolean fstart, boolean fsend, long cbytes,
  270.              boolean *pfhandled));
  271.