home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / com / zocdev / pip / tech.doc < prev   
Encoding:
Text File  |  1993-12-11  |  11.2 KB  |  454 lines

  1.  
  2.     This document discusses technical matters of the Plug-In-
  3.     Protocol (PIP) interface.
  4.  
  5.     No (C) of any kind applies - implementation of PIP in clients or
  6.     terminals is free. 
  7.  
  8.     However sole host of truth about the Plug-In-Protocol is me.
  9.  
  10.     If you plan to implement the terminal side of the TAP interface
  11.     contact me for sample sources.
  12.  
  13.  
  14.     Keep OS/2 interesting for the people, develop for OS/2!!
  15.  
  16.  
  17.  
  18.     Markus Schmidt
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.     Introduction:
  27.     ==============
  28.  
  29.  
  30.  
  31.     Each PIP is a DLL that begins with the name PIP. The name shall
  32.     not be longer than eight characters to be compatible with the
  33.     FAT file system. 
  34.  
  35.  
  36.  
  37.     Every PIP-DLL has to export five fuctions:
  38.  
  39.       int pipIntro(PIP_SOCKET *, PIP_PLUG * )
  40.  
  41.       int pipInit(PIP_SOCKET *, PIP_PLUG * )
  42.  
  43.       int pipSetup(PIP_SOCKET *, PIP_PLUG * )
  44.  
  45.       int pipSend(PIP_SOCKET *, PIP_PLUG *, char *, char **)
  46.  
  47.       int pipReceive(PIP_SOCKET *, PIP_PLUG *, char*, char **)
  48.  
  49.       int pipCleanup(PIP_SOCKET *, PIP_PLUG *)
  50.  
  51.  
  52.  
  53.     Each function receives as parameters a pointer to a socket
  54.     structure and a pointer to a plug structure. The socket
  55.     structure is initialized by ZOC and must not be modified by the
  56.     plug (thus being defined as const). The plug gets its connection
  57.     to socket functions through the socket structure. The plug
  58.     structure is used by both the plug and the socket. 
  59.  
  60.  
  61.  
  62.  
  63.  
  64.     Export Functions:
  65.     =================
  66.  
  67.  
  68.  
  69.     pipIntro():
  70.  
  71.     -----------
  72.  
  73.     The pipIntro() functions is called once, when the DLL is loaded
  74.     into memory. It fills the fields PlugName, PlugDescription,
  75.     PlugType, PlugBits and PlugPipVersion fields of the plug
  76.     stucture to tell the socket what it is capable off. The socket
  77.     shall not request any services the plug is not capable of, but
  78.     it is a good idea for the plug not to rely on that. 
  79.  
  80.     Additionaly the plug can request automatic start of upload or
  81.     download by filling the PlugAutoUpload and PlugAutoDownload
  82.     fields of the plug structure. Both fields are zero terminated
  83.     and must not contain a Carriage Return (0x0D)or a Line Feed
  84.     (0x0A). 
  85.  
  86.  
  87.  
  88.  
  89.  
  90.     pipInitialize():
  91.     ----------------
  92.  
  93.     This function is called by the socket before it calls any of the
  94.     pipSetup(), pipSend() or pipReceive() functions so the plug has
  95.     a chance to do internal initialisations. Each pipInitialize() is
  96.     paired with a call to pipCleanup(). pipInitialize() will not be
  97.     called twice without calling pipCleanup() in between. However
  98.     the following calling sequences :
  99.  
  100.         pipIntro(), pipInitialize(), pipSetup(),
  101.  
  102.         pipCleanup(), pipInitialize(), pipSend(),
  103.  
  104.         pipCleanup()
  105.  
  106.     and 
  107.  
  108.         pipIntro(), pipInitialize(), pipSetup(), 
  109.  
  110.         pipSend(), pipCleanup()
  111.  
  112.     are both legal.
  113.  
  114.  
  115.  
  116.     Mostly pipInitialize() will allocate memory to the private
  117.     pointer of the plug structure and try to initialize it with
  118.     potential options from the INI file. 
  119.  
  120.     Calls to pipInitialize() and pipCleanup() will be strictly
  121.     paired and will not be nested (except if called from different
  122.     applications as it might occur with every DLL). 
  123.  
  124.  
  125.  
  126.  
  127.  
  128.     pipSetup():
  129.     -----------
  130.  
  131.     The taks of pipSetup() is to allow the user to defined protocol
  132.     specific options like transfer mode or something alike. 
  133.  
  134.     These options should be stored to the OS2.INI file under the
  135.     application name defined in PIP_INIAPPL under a unique key.
  136.     pipSend() and pipReceive() shall retrieve the options from 
  137.     OS2.INI because the user will not always call pipSetup() before
  138.     calling pipSend()/pipReceive(). Further there might have been a
  139.     pipCleanup(), pipInitialize() call between pipSetup() and
  140.     pipSend()/pipReceive() as shown above. 
  141.  
  142.     pipSetup() should check the dlgHwndFrame field from the socket
  143.     structure to see if it was called from a PM or VIO application
  144.     and eventually return PIP_ERROR. 
  145.  
  146.  
  147.  
  148.  
  149.  
  150.     pipSend()/pipReceive():
  151.     -----------------------
  152.  
  153.     This function will be called if the user selected the upload
  154.     option in the terminal program. According to the bits reported
  155.     by pipIntro() the socket will supply pointers for path or
  156.     multipath. 
  157.  
  158.     Path is a zero terminated string with one filename and optional
  159.     directory (absolute or realative to the current working
  160.     directory). Multipath is an array of pointer to such strings
  161.     with a NULL pointer to end the list. The value of path/multipath
  162.     is related to the PlugBits:
  163.  
  164.  
  165.  
  166.     If the plug reports FILEREQUESTER for the current environment
  167.     (PM/VIO) path and multipath will always be NULL. The plug has to
  168.     handle file dialogs by itself. 
  169.  
  170.     If the plug reports SINGLEUPLOAD multipath will always be NULL.
  171.     Path will contain one zero terminated string of a filename.
  172.  
  173.     If the plug reports MULTIPLEUPLOAD path will always be NULL.
  174.     Multipath will contain one or more pointers to a filename.
  175.  
  176.     If the plug reports both SINGLEUPLOAD and MULTIPLEUPLOAD one of
  177.     path or multipath will be NULL the other containing a value as
  178.     described above. 
  179.  
  180.  
  181.  
  182.     Transfer protocols that receive the file name from the remote
  183.     station (e. g. Compuserve B) should report the FILEREQUESTER bit
  184.     to the socket but should never display one. This way no filerequester
  185.     is shown and the files can be transferred to/from the default
  186.     directories as given in the socket parameter structure.
  187.  
  188.  
  189.  
  190.     The file transfer options shall be retrieved from the OS2.INI
  191.     file as described under pipInitialize() and pipSetup(). 
  192.  
  193.  
  194.  
  195.     IMPORTANT: To prevent locking of PM and to give the socket
  196.     opportunity to update timers and other stuff the pipSend/Receive()
  197.     has to call the CoreLoop() function of the socket at least once a
  198.     second. 
  199.  
  200.  
  201.  
  202.     Processing of pipReceive() is analog to pipSend().
  203.  
  204.  
  205.  
  206.  
  207.  
  208.     pipCleanup():
  209.     -------------
  210.  
  211.     The pipCleanup() function is the complement to pipInitialize()
  212.     and will only be called after that. Its task is to free memory
  213.     and other resources before the DLL might be unloaded. Calls to
  214.     pipInitialize() and pipCleanup() are strictly paired and will
  215.     not be nested (except if called from different applications as
  216.     it might occur with every DLL).  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.     Description of PIP_SOCKET:
  225.     ==========================
  226.  
  227.  
  228.  
  229.     What follows is a description of the most important fields in
  230.     the PIP_SOCKET structure. 
  231.  
  232.  
  233.  
  234.  
  235.  
  236.     int PipVersion:
  237.     ---------------
  238.  
  239.     Version of the PIP interface the socket uses. Socket and plug
  240.     will normally be downward compatible. If changes have to be
  241.     implemented that impair compatibility tha major version number
  242.     (bit 8 to 4) of PIP_VERSION will change. So compare this field
  243.     to PIP_VERSION (as defined in PIP.H) with the PIP_COMPATIBLE()
  244.     macro and report an error if not equal.
  245.  
  246.  
  247.  
  248.  
  249.  
  250.     HAB hab:
  251.     --------
  252.  
  253.     When running in PM environment this is the anchor block handle
  254.     of the socket. If zero, you are running under a non-PM
  255.     Application. 
  256.  
  257.  
  258.  
  259.  
  260.  
  261.     HFILE hfComDevice:
  262.     -------------------
  263.  
  264.     File handle for com device. If zero no modification of com
  265.     device (mainly serial options) is not allowed. If nonzero the
  266.     plug may use DosDevIoctl, but shall reset the com device to its
  267.     initial state when terminating. 
  268.  
  269.  
  270.  
  271.  
  272.  
  273.     ULONG ulBaud:
  274.     -------------
  275.  
  276.     Actual com speed. Will always be supplied by the socket.
  277.  
  278.  
  279.  
  280.  
  281.  
  282.     unsigned char szUploadDir[CCHMAXPATH]:
  283.     --------------------------------------
  284.  
  285.     Default path for uploads. Never terminated by "\". If empty ("")
  286.     upload from current directory. May be overriden by directory
  287.     path in the path/multipath parameters of pipSend()/pipReceive().
  288.     So just use this, if path/ multipath is just a filename or a
  289.     filename with relative path. 
  290.  
  291.  
  292.  
  293.  
  294.  
  295.     unsigned char szDownloadDir[CCHMAXPATH]:
  296.     ----------------------------------------
  297.  
  298.     Default path for downloads. Never terminated by "\". If empty
  299.     ("") download to the current directory. May be overriden by
  300.     directory path in the path/multipath parameters of
  301.     pipSend()/pipReceive().
  302.  
  303.  
  304.  
  305.  
  306.  
  307.     void ioConPutChar(unsigned char chr):
  308.     -------------------------------------
  309.  
  310.     Output of one character to the main terminal window. 
  311.  
  312.  
  313.  
  314.  
  315.  
  316.     void ioConPutData(unsigned char *pdata, long length):
  317.     -----------------------------------------------------
  318.  
  319.     Output of a block of character to the main terminal window. 
  320.  
  321.  
  322.  
  323.  
  324.  
  325.     int  ioSerQueryAvail(void):
  326.     ---------------------------
  327.  
  328.     Query if there are any characters are in the input queue.
  329.     Returns TRUE or FALSE. 
  330.  
  331.  
  332.  
  333.  
  334.  
  335.     int  ioSerGetChar(void):
  336.     ------------------------
  337.  
  338.     Read one character from the serial device. Returns
  339.     PIP_READ_NODATA (256) if no data available. 
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.     int  ioSerTimedGetChar(int timeout):
  347.     ------------------------------------
  348.  
  349.     Read one character from the serial device within a given time
  350.     (timeout is 1/10 seconds). If PIP_READ_NODATA (256) is returned
  351.     no data arrived within the given time (timeout).
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.     void ioSerPutChar(unsigned char chr):
  359.     -------------------------------------
  360.  
  361.     Write a single character to the com device.
  362.  
  363.  
  364.  
  365.  
  366.  
  367.     void ioSerPutData(unsigned char  *pdata, long length):
  368.     ------------------------------------------------------
  369.  
  370.     Write a block of characters to the com device.
  371.  
  372.  
  373.  
  374.  
  375.  
  376.     void ioSerUngetData(unsigned char *pdata, int length):
  377.     ------------------------------------------------------
  378.  
  379.     Put characters back into the input queue for later reading. Max
  380.     length is 16. Must not be used incrementally. 
  381.  
  382.  
  383.  
  384.  
  385.  
  386.     void ioSerPutBrk(void):
  387.     -----------------------
  388.  
  389.     Send a modem break
  390.  
  391.  
  392.  
  393.  
  394.  
  395.     HWND dlgHwndFrame:
  396.     ------------------
  397.  
  398.     Handle of PM frame window (eg to center upon). Zero for VIO
  399.     applications, but determine PM/VIO environment from 'hab'. 
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.     void dlgErrorMsg(unsigned char *txt):
  408.     -------------------------------------
  409.  
  410.     View an error message. 
  411.  
  412.  
  413.  
  414.  
  415.  
  416.     void dlgInfoMsg(unsigned char *txt):
  417.     ------------------------------------
  418.  
  419.     View an information message. 
  420.  
  421.  
  422.  
  423.  
  424.  
  425.     File I/O functions:
  426.     -------------------
  427.  
  428.     The sockte structure contains pointers to file I/O functions
  429.     that are wrappers for the stream I/O functions defined by
  430.     the ANSI standard. 
  431.  
  432.     These functions are equivalent to the ANSI functions, but 
  433.     additionally send messages to a TAP (see ..\TAP\TECH.DOC).
  434.     The only difference is the fopen function which has an additional
  435.     size parameter to indicate the size when opening a file for 
  436.     writing. This field is sent with the TAP_OPENFORXXXX message 
  437.     to an eventual tap. If not available (e.g. for X-Modem) size 
  438.     should be set to zero. 
  439.  
  440.     When opening a file for reading, size is ignored and calcualated 
  441.     internally
  442.  
  443.  
  444.  
  445.  
  446.  
  447.     void CoreLoop(void):
  448.     --------------------
  449.  
  450.     Call this function periodically to allow the socket to dispatch
  451.     messages or update statusline. This function has to be called at
  452.     least once a second. Otherwise PM might hang.
  453.  
  454.