home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / com / zocdev / pip / pip.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-16  |  9.3 KB  |  228 lines

  1. #ifndef PIP_OK    /* Prevent multiple inclusion
  2.  
  3. /*********************************************************************/
  4. /*                                                                   */
  5. /*  Headerfile for PLUG-IN-PROTOCOLS (see Abstract)                  */
  6. /*                                                                   */
  7. /*  This file contains the necessary declarations to create          */
  8. /*  plug in DLLs for ZOC or compatible communication packages.       */
  9. /*                                                                   */
  10. /*  See TECH.DOC for a more detailed description                     */
  11. /*                                                                   */
  12. /*                                                                   */
  13. /*********************************************************************/
  14. #define PIP_OK 0
  15. #define PIP_ERROR 1
  16.  
  17. /*********************************************************************/
  18. /*  Store your INI data under this Application-Name                  */
  19. /*********************************************************************/
  20. #define PIP_INIAPPL    "Zap-O-Com PIPs"
  21.  
  22.  
  23. /*********************************************************************/
  24. /*  The PIP_SOCKET describes the socket (host) application.          */
  25. /*  Values are filled by the socket and given to all plug functions. */
  26. /*  The plug must not modify this structure.                         */
  27. /*********************************************************************/
  28. typedef struct _PIP_SOCKET PIP_SOCKET;
  29.  
  30. struct _PIP_SOCKET {
  31.  
  32.     // PIP_VERSION of the socket (as defined below)
  33.     int  PipVersion;
  34.  
  35.     // Anchor Block Handle. If zero, running a non-PM Application
  36.     HAB  hab;
  37.  
  38.     // File handle for com device. If zero no modification of com 
  39.     // device allowed. If nonzero the plug may use DosDevIoctls, but
  40.     // should reset the com device to the initial state when terminating.
  41.     HFILE hfComDevice;
  42.  
  43.     // Actual com speed. Will always be non zero.
  44.     ULONG ulBaud;
  45.  
  46.     // Default path for up- and downloads. Must not be terminated
  47.     // by "\". If empty ("") up-/download to current directory.
  48.     unsigned char    szUploadDir[CCHMAXPATH],
  49.                     szDownloadDir[CCHMAXPATH];
  50.  
  51.     /************************************************/
  52.     /* Pointers to functions, the plug may use.     */
  53.     /************************************************/
  54.  
  55.     // output to the terminal text window (helpful for debugging purposes) 
  56.     void (*_System ioConPutChar)(unsigned char chr);
  57.     void (*_System ioConPutData)(unsigned char *pdata, long length);
  58.  
  59.     // query how many characters are in the input queue
  60.     int  (*_System ioSerQueryAvail)(void);
  61.  
  62.     // Read character. If none available, PIP_READ_NODATA (256) is retured
  63.     int  (*_System ioSerGetChar)(void);
  64.     int  (*_System ioSerTimedGetChar)(int timeout);
  65.  
  66.     // Write single character or block of characters to com device 
  67.     void (*_System ioSerPutChar)(unsigned char chr);
  68.     void (*_System ioSerPutData)(unsigned char  *pdata, long length);
  69.  
  70.     // Put characters back into the input queue. Max length is 16,
  71.     // must not be used incrementally.
  72.     void (*_System ioSerUngetData)(unsigned char *pdata, int length);
  73.  
  74.     // Send a modem break 
  75.     void (*_System ioSerPutBrk)(void);
  76.  
  77.     // Handle of PM frame window (eg to center upon). 
  78.     // (Zero for VIO applications)
  79.     HWND dlgHwndFrame;
  80.  
  81.     // Display an info or error message 
  82.     void (*_System dlgErrorMsg)(unsigned char *txt);
  83.     void (*_System dlgInfoMsg)(unsigned char *txt);
  84.  
  85.     // file transfer functions that know about tapping 
  86.     FILE *    (*_System fopen)(char *name, char *mode, long size);
  87.     int        (*_System fclose)(FILE *f);
  88.     int        (*_System fseek)(FILE *f, int offset, int origin) ;
  89.     long    (*_System ftell)(FILE *f);
  90.     int        (*_System fwrite)(void *buf, int size, int num, FILE *f);
  91.     int        (*_System fread)(void *buf, int size, int num, FILE *f);
  92.     int        (*_System fgetc)(FILE *f);
  93.  
  94.     // Allow the socket to dispatch messages or update statusline
  95.     // This has to be called at least once a second. Otherwise 
  96.     // PM might hang.
  97.     void (*_System CoreLoop)(void);
  98.  
  99.     // Data for future use - don't touch that in any way.
  100.     long    __Future[32];
  101.  
  102. } ;
  103.  
  104. // Return value for ioSerGetChar if no data available (see above)
  105. #define PIP_READ_NODATA 256
  106.  
  107.  
  108. /*********************************************************************/
  109. /*  The PIP_PLUG structure is partially filled by the plug,          */
  110. /*  partially by the socket. It is given as the second parameter     */
  111. /*  to every plug function (except Intro)                            */
  112. /*********************************************************************/
  113. typedef struct _PIP_PLUG PIP_PLUG ;
  114.  
  115. struct _PIP_PLUG {
  116.  
  117.     /* public: -------------------------------------------------------- */
  118.  
  119.     /***************************************************/
  120.     /* Reply from pipIntro(duce yourself)              */
  121.     /***************************************************/
  122.     int  PlugPipVersion;        // PIP_VERSION of the plug (as defined below)
  123.     long PlugBits;                            // PIP_PBITs (see below)
  124.     int PlugType;                            // PIP_TYPE_XXX (see below)
  125.     unsigned char PlugName[16+1];            // Short name like 'ZMODEM'
  126.     unsigned char PlugDescription[64+1];    // Long description
  127.     unsigned char PlugAutoUpload[32+1];        // Seq. for auto upload detection
  128.     unsigned char PlugAutoDownload[32+1];    // Seq. for auto download detection
  129.  
  130.  
  131.     /***************************************************/
  132.     /* May be used freely from plug for private data   */
  133.     /***************************************************/
  134.     void *PlugPrivate;    // should be pointer to option block by convention */
  135.     void *PlugPrivate2;
  136.     void *PlugPrivate3;
  137.     void *PlugPrivate4;
  138.  
  139.     /***************************************************/
  140.     /* Handle of the plug DLL.                         */
  141.     /* Set from socket, may be used by the plug.       */
  142.     /***************************************************/
  143.     HMODULE hmPlugDll;
  144.  
  145.     /* private: ------------------------------------------------------- */
  146.  
  147.     /***************************************************/
  148.     /* Every plug needs to implement these functions   */
  149.     /* Addresses filled in from socket upon DLL-loading*/
  150.     /* Check PIPPLUG.C for function descriptions.      */
  151.     /* The plug must not use these fields or make any  */
  152.     /* assumptions about them. They are strictly for   */
  153.     /* use by the socket!                              */
  154.     /***************************************************/
  155.     int (*_System pipIntro)(PIP_SOCKET*, PIP_PLUG *);
  156.     int (*_System pipInit)(PIP_SOCKET *, PIP_PLUG *);
  157.     int (*_System pipSetup)(PIP_SOCKET *, PIP_PLUG *);
  158.     int (*_System pipSend)(PIP_SOCKET *, PIP_PLUG *, 
  159.                             unsigned char *single, unsigned char **multi);
  160.     int (*_System pipReceive)(PIP_SOCKET *, PIP_PLUG *, 
  161.                             unsigned char *single, unsigned char **multi);
  162.     int (*_System pipCleanup)(PIP_SOCKET *, PIP_PLUG *);
  163.  
  164.  
  165.     /***************************************************/
  166.     /* Data for future use - don't touch that!!        */
  167.     /***************************************************/
  168.     long    __Future[32];
  169. } ;
  170.  
  171.  
  172.  
  173. /*********************************************************************/
  174. /*  Set the PlugPipVersion of the _PIP_PLUG struct to PIP_VERSION    */
  175. /*********************************************************************/
  176. #define PIP_VERSION 0x20        /* Version 2.0 */
  177. #define PIP_COMPATIBLE(x,y)        (((x)&0xF0)==((y)&0xF0))
  178.  
  179.  
  180.  
  181. /*********************************************************************/
  182. /*  If you are doing a protocol, set PlugType to PIP_TYPE_PROTOCOL   */
  183. /*  (other types might be available in the future)                   */
  184. /*********************************************************************/
  185. #define PIP_TYPE_PROTOCOL   0x0001
  186.  
  187.  
  188.  
  189. /*********************************************************************/
  190. /*  Set PlugBits to a combination of these constants                 */
  191. /*  See TECH.DOC for a discussion of possible combinations           */
  192. /*********************************************************************/
  193. #define PIP_PBIT_SINGLEUPLOAD        (1U<<0)
  194. #define PIP_PBIT_MULTIPLEUPLOAD        (1U<<1)
  195. #define PIP_PBIT_SINGLEDOWNLOAD        (1U<<2)
  196. #define PIP_PBIT_MULTIPLEDOWNLOAD    (1U<<3)
  197. #define PIP_PBIT_PM_OPTIONS            (1U<<4)
  198. #define PIP_PBIT_PM_FILEREQUESTER    (1U<<5)
  199. #define PIP_PBIT_VIO_OPTIONS        (1U<<6)
  200. #define PIP_PBIT_VIO_FILEREQUESTER    (1U<<7)
  201. #define PIP_PBIT_DISABLE_SETUP        (1U<<8)
  202. #define PIP_PBIT_DISABLE_UPLOAD        (1U<<9)
  203. #define PIP_PBIT_DISABLE_DOWNLOAD    (1U<<10)
  204.  
  205.  
  206. /*********************************************************************/
  207. /*  Function prototypes for plugs.                                   */
  208. /*  (set #define PIP_INCL_PLUG from your plug in protocol source,    */
  209. /*  before including PIP.H)                                          */
  210. /*********************************************************************/
  211. #ifdef PIP_INCL_PLUG
  212.     int _System pipIntro(PIP_SOCKET const * const, PIP_PLUG * const);
  213.     int _System pipInit(PIP_SOCKET const * const, PIP_PLUG * const);
  214.     int _System pipSetup(PIP_SOCKET const * const, PIP_PLUG * const);
  215.     int _System pipSend(PIP_SOCKET const * const, PIP_PLUG * const, 
  216.                         unsigned char *, unsigned char **);
  217.     int _System pipReceive(PIP_SOCKET const * const, PIP_PLUG * const, 
  218.                         unsigned char *, unsigned char **);
  219.     int _System pipCleanup(PIP_SOCKET const * const, PIP_PLUG * const);
  220. #endif    /* PIP_INCL_PLUG */
  221.  
  222. /* Socket specific stuff
  223. #ifdef PIP_INCL_SOCKET
  224.  
  225. #endif /* PIP_INCL_SOCKET */
  226.  
  227. #endif /* PIP_OK */
  228.