home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / a / awnotes.zip / AW4API.TXT < prev    next >
Text File  |  1992-12-22  |  22KB  |  542 lines

  1.  
  2.               pcANYWHERE IV Programmer's Interface
  3.  
  4.  
  5. The pcANYWHERE IV Application Programmer's Interface (API)
  6. makes it possible for a user's program to interact with and
  7. possibly modify the operation of pcANYWHERE IV. The programmer's
  8. interface is intended for use by programmers with experience
  9. in IBM PC assembly language.
  10.  
  11. pcANYWHERE IV API functions are invoked from assembly language
  12. by issuing a far call to the pcANYWHERE IV API entry point with
  13. a function number in the AX register and other parameters in
  14. various registers. The status of the function is returned in
  15. the AX register. Before a program may call the pcANYWHERE IV
  16. API, it must first determine the entry point. This is accomplished
  17. by issuing a DOS INT 21H "Set Date" function to set a specific
  18. invalid date (as described below). If pcANYWHERE IV is not resident,
  19. DOS will simply return an invalid function error code. If pcANYWHERE
  20. IV is resident, it will intercept the function and return the value
  21. 'OK' or 'ok' in the AX register and the API entry point in CX:DX.
  22. The following is a sample program that determines if pcANYWHERE IV
  23. is resident and if so, displays its current status:
  24.  
  25.  
  26.  
  27. dseg segment para public 'DATA'
  28.  
  29. AW4_Address    dd   0         ;Place to store pcANYWHERE IV API entry point
  30.  
  31. NoAW4          db   13,10,'pcANYWHERE IV is not resident.',13,10,'$'
  32. AW4Active      db   13,10,'pcANYWHERE IV is active.',13,10,'$'
  33. AW4Ready       db   13,10,'pcANYWHERE IV is ready for a connection.',13,10,'$'
  34. AW4Idle        db   13,10,'pcANYWHERE IV is inactive.',13,10,'$'
  35.  
  36. dseg ends
  37.  
  38. stack segment para stack 'STACK'
  39.  
  40.                dw   200H dup (0)
  41. stack ends
  42.  
  43. cseg segment para public 'CODE'
  44.  
  45. assume    cs:cseg, ds:dseg, ss:stack
  46.  
  47. main proc far
  48.  
  49.      push ds                       ;Put return to DOS on stack
  50.      xor  ax,ax
  51.      push ax
  52.  
  53.      mov  ax,dseg                  ;Set DS to our data segment
  54.      mov  ds,ax
  55.  
  56.      call near ptr Find_AW4        ;See if pcANYWHERE IV is resident
  57.      jz   AW4_Resident             ;Continue if so
  58.      mov  dx,Offset NoAW4          ;If not, point to not resident message
  59.      jmp  Display_Status           ;Go display status and exit
  60.  
  61. AW4_Resident:
  62.      mov  word ptr AW4_Address,dx  ;Save pcANYWHERE IV API entry point
  63.      mov  word ptr AW4_Address+2,cx
  64.      mov  ax,2                     ;Function number to get pcAW4 status
  65.      call AW4_Address              ;On return, AH=operating mode, AL=status
  66.  
  67.      mov  dx,Offset AW4Active      ;Point to pcANYWHERE IV is active message
  68.      test al,1                     ;If bit 0 of AL is set, session is active
  69.      jnz  Display_Status           ;Jump if so
  70.  
  71.      mov  dx,Offset AW4Ready       ;Point to pcANYWHERE IV is ready message
  72.      cmp  ah,2                     ;Check for mode=2, "allow incoming calls"
  73.      je   Display_Status           ; Jump if so
  74.  
  75.      mov  dx,Offset AW4Idle        ;Must be in "hot key activates" mode
  76.  
  77. Display_Status:
  78.      mov  ah,9                     ;DOS function to display a string
  79.      int  21H                      ;Display the status message
  80.      ret                           ;Return to DOS
  81.  
  82. main endp
  83.  
  84.  
  85. ;
  86. ;    This routine determines if pcANYWHERE IV is resident
  87. ;    and returns with the Z flag set if so, or clear if not.
  88. ;
  89. ;    We will check for pcANYWHERE IV by issuing a DOS INT 21H function
  90. ;    to set the date to a specific invalid date. If pcANYWHERE IV is not
  91. ;    resident, DOS will return with an invalid date error code.
  92. ;    If pcANYWHERE IV is present, it will intercept the call and return
  93. ;    with the value 'OK' in the AX register, and its entry point in CX:DX.
  94. ;    (Note: If the small version of the pcANYWHERE IV/LAN host is resident,
  95. ;    it will return with AX set to 'ok' in lowercase.)
  96. ;
  97.  
  98. Find_AW4  proc near
  99.  
  100.      mov  ah,2BH              ;DOS INT 21H set date function number.
  101.      mov  al,'D'              ;Load registers with pcANYWHERE IV signature.
  102.      mov  bx,'MA'             ; The values loaded into the registers
  103.      mov  cx,'pc'             ; are not a valid date and DOS will return
  104.      mov  dx,'AW'             ; with AL = 0FFH if pcANYWHERE IV is not
  105.      int  21H                 ; resident.
  106.      cmp  ax,'OK'             ;Is pcANYWHERE IV resident ?
  107.      je   FIND_AW4_EXIT       ; If so, return, Z flag is set
  108.      cmp  ax,'ok'             ;Set Z flag if a "small" host is resident
  109. Find_AW4_Exit:
  110.      ret                      ;If pcANYWHERE IV is resident, Z flag is set
  111.                               ; and CX:DX has its entry point.
  112. Find_AW4  endp
  113.  
  114. cseg ends
  115.  
  116. end  main
  117.  
  118.  
  119.  
  120. The pcANYWHERE IV API functions are divided into two groups:
  121. 1) general functions and 2) communications functions.
  122. All functions are passed a function number and return
  123. status in the AX register.
  124.  
  125. For general functions, additional parameters, if required,
  126. are passed to the function in a buffer pointed to by DS:SI
  127. and additional return information is placed in a buffer
  128. pointed to by DS:DI. All registers are preserved.
  129.  
  130. For communications functions, additional parameters are
  131. passed in BX and CX. DS, ES, DI, SI and BP are preserved.
  132.  
  133. The functions supported by the pcANYWHERE IV API are as follows:
  134.  
  135.      General functions
  136.  
  137.      Function number          Description
  138.      ---------------          --------------------------------------------
  139.         0000H                 Get pcANYWHERE IV version
  140.         0001H                 Initialize pcANYWHERE IV operation
  141.         0002H                 Get pcANYWHERE IV status
  142.         0003H                 Suspend remote screen updates
  143.         0004H                 Resume remote screen updates
  144.         0005H                 End current remote access session
  145.         0006H                 Remove pcANYWHERE IV from memory
  146.  
  147.      Communications functions
  148.  
  149.      Function number          Description
  150.      ---------------          --------------------------------------------
  151.         8000H                 Read data from communication channel
  152.         8001H                 Write data over communication channel
  153.         8002H                 Get connection status
  154.  
  155.  
  156. Note: The communications functions (8000H-8002H) should only
  157.       be used after function 0003H has been called to suspend
  158.       pcANYWHERE IV.
  159.  
  160.  
  161.  
  162. Function descriptions:
  163.  
  164. ============================================================================
  165.  
  166. Function 0000H - Get pcANYWHERE IV version
  167.  
  168.  
  169. Calling parameters:
  170.  
  171.           AX    = 0000H
  172.           DS:DI = Pointer to a 1 byte reply buffer where the
  173.                   host type code is to be placed.
  174.  
  175. Returns:
  176.  
  177.           AH    = Version number
  178.           AL    = Revision number
  179.           DS:DI = Pointer to host type code
  180.                     0 - host is a full featured host
  181.                     1 - host is a limited feature LAN host
  182.  
  183.  
  184. Description:
  185.  
  186.           This function returns pcANYWHERE IV's version
  187.           and revision number as well as a host type code.
  188.           This function should be used to determine if
  189.           the resident host can support the pcANYWHERE IV
  190.           functions that your program will be using.
  191.  
  192.           IMPORTANT NOTE!
  193.  
  194.                If the byte returned at DS:DI is not a 0 or a 1,
  195.                your program should refrain from making additional
  196.                API calls. Values greater than 1 are reserved for
  197.                custom versions of pcANYWHERE IV which may NOT
  198.                fully support the programmer's interface. Issuing
  199.                the API call's described here when the host type
  200.                code is not a 0 or a 1 could result in the host
  201.                PC hanging.
  202.  
  203.  
  204. ============================================================================
  205.  
  206. Function 0001H - Initialize pcANYWHERE IV operation
  207.  
  208.  
  209. Calling parameters:
  210.  
  211.           AX    = 0001H
  212.           DS:SI = Pointer to request structure formatted as follows:
  213.                     BYTE      Operating mode
  214.                                    0 = Wait for a call
  215.                                    1 = Hot key activates
  216.                                    2 = Incoming call activates
  217.                                    3 = Initiate a call
  218.                     BYTE[3]   User ID to append to config file names
  219.                     WORD      DS relative pointer to path for config files
  220.                     WORD      DS relative pointer to path for program files
  221.  
  222. Returns:
  223.  
  224.           AX    = Status of function
  225.                     0000H - Function completed successfully
  226.                     FFFDH - The specified operating mode is invalid
  227.                     FFFCH - A remote access session is active
  228.                     FFFAH - The configuration file could not be found
  229.                     FFF9H - The configuration file is invalid
  230.                     FFF7H - The communications driver type specified in the
  231.                             configuration file is different than the one
  232.                             loaded when pcANYWHERE IV was initially started.
  233.                             Once the pcANYWHERE IV host has been loaded, the
  234.                             driver type may not be changed. If a different
  235.                             driver needs to be loaded, pcANYWHERE IV must
  236.                             first be removed from memory.
  237.                     FFF6H - The host operator aborted the function
  238.                     FFF5H - The communications device could not be initialized
  239.                             The reason for initialization failure depends
  240.                             on the type of device. If the device is a software
  241.                             driver (IPX, NetBIOS, etc), then the required
  242.                             interface software is probably not installed (IPX,
  243.                             NetBIOS, etc.). If the device is a local serial
  244.                             port, then the COM port did not respond to a
  245.                             standard hardware test. If the device is NASI or
  246.                             NCSI, either the NASI/NCSI driver is not installed
  247.                             or the specified port could not be found.
  248.                     FFF4H - Modem initialization failed (no modem response)
  249.                     FFF3H - Modem configuration is invalid (corrupt config)
  250.                     FFF2H - Unable to establish a connection when operating
  251.                             mode is "Initiate a call"
  252.  
  253.  
  254. Description:
  255.  
  256.           This function causes pcANYWHERE IV to load a new
  257.           configuration and set its operating mode according
  258.           to the mode specified. If the operating mode specified
  259.           is 0 (Wait for a call), this function will not return
  260.           until the host operator cancels the function by pressing
  261.           <Esc> or until a valid connection is established.
  262.           If the function is not successful, the operating mode
  263.           will be changed to 1 (Hot key activates).
  264.  
  265. ============================================================================
  266.  
  267. Function 0002H - Get pcANYWHERE IV status
  268.  
  269.  
  270. Calling parameters:
  271.  
  272.           AX    = 0002H
  273.  
  274. Returns:
  275.           AH    = Current operating mode
  276.                     0 = Wait for a call
  277.                     1 = Hot key activates
  278.                     2 = Incoming call activates
  279.           AL    = Current connection status, where:
  280.                     Bit 0     = 1  A physical connection is active
  281.                     Bit 1     = 1  Remote screen updating is active
  282.                     Bit 2     = 1  Connection checking is active
  283.                     Bit 3     = 1  Hot key detection is active
  284.                     Bit 4     = 1  Background file transfer is active
  285.  
  286.  
  287. Notes:
  288.           The following table lists the possible bit combinations
  289.           in the connection status byte:
  290.  
  291.                Value          pcANYWHERE IV status
  292.                -----          ----------------------------------------
  293.                 08H           No connection, hot key activates
  294.                 0CH           No connection, hot key or call activates
  295.                 01H           Connection active, remote user is
  296.                               logging in or pcANYWHERE IV has been
  297.                               suspended via API function 3
  298.                 03H           Connection active, screen updates active
  299.                 11H           Connection active, background transfer active
  300.  
  301.           pcANYWHERE IV will set the connection status to 00H while
  302.           it is initializing, removing itself from memory or when it
  303.           is in "Wait for a call" mode. If initialization or cancelling
  304.           fails, the connection status will be changed to 08H and the
  305.           operating mode will be set to 1 (Hot key activates). The
  306.           only time a connection status of 00H could be returned by
  307.           this function is if the function is called from an interrupt
  308.           service routine while pcANYWHERE IV is performing one of
  309.           the above mentioned tasks.
  310.  
  311. ============================================================================
  312.  
  313. Function 0003H - Suspend remote screen updates
  314.  
  315.  
  316. Calling parameters:
  317.  
  318.           AX    = 0003H
  319.  
  320. Returns:
  321.  
  322.           AX    = 0000H - Function completed successfully
  323.                   FFFBH - A session is not active or has
  324.                           already been suspended
  325.  
  326.  
  327. Description:
  328.  
  329.           This function suspends pcANYWHERE IV's remote screen
  330.           updating, allowing a user's application to perform I/O
  331.           through the communications device that pcANYWHERE IV
  332.           is using. The file transfer program, AWSEND, uses this
  333.           function to suspend pcANYWHERE IV while it is transfering
  334.           files with the remote computer. While pcANYWHERE IV is
  335.           in a suspended state, it will not peform any communications
  336.           I/O and it will not check for loss of connection. It is
  337.           the responsibility of your application program to check
  338.           for loss of connection (see API function 8002H) when
  339.           pcANYWHERE IV has been suspended. If the connection is
  340.           lost, your application should resume pcANYWHERE IV. Once
  341.           resumed, pcANYWHERE IV will detect the connection loss
  342.           and prepare for another connection.
  343.  
  344. ============================================================================
  345.  
  346. Function 0004H - Resume remote screen updates
  347.  
  348.  
  349. Calling parameters:
  350.  
  351.           AX    = 0004H
  352.  
  353. Returns:
  354.  
  355.           AX    = 0000H - Function completed successfully
  356.                   FFFBH - A session is not active
  357.  
  358.  
  359. Description:
  360.  
  361.           This function causes pcANYWHERE IV to resume remote screen
  362.           updating after it has been suspended by API function 3.
  363.           Since suspending pcANYWHERE IV can cause the host and remote
  364.           screens to be out of sync, this function will automatically
  365.           refresh the remote screen.
  366.  
  367. ============================================================================
  368.  
  369. Function 0005H - End current remote access session
  370.  
  371.  
  372. Calling parameters:
  373.  
  374.           AX    = 0005H
  375.           DS:SI = Pointer to request structure formatted as follows:
  376.                     BYTE      Operating mode
  377.                                    00H = Wait for a call
  378.                                    01H = Hot key activates
  379.                                    02H = Incoming call activates
  380.                                    80H = Use current mode
  381.                                    FFH = Remove from memory
  382.  
  383. Returns:
  384.  
  385.           AX    = Status of function
  386.                     0000H - Function completed successfully
  387.                     FFFBH - A session is not active
  388.                     FFF6H - The host operator aborted the function
  389.                     FFF4H - Modem initialization failed (no modem response)
  390.  
  391.  
  392. Description:
  393.  
  394.           This function terminates the current remote access session
  395.           and re-initializes pcANYWHERE IV to the specified operating
  396.           mode. (See function 6 for notes on removing pcANYWHERE IV
  397.           from memory.) If the specified operating mode is invalid,
  398.           the current operating mode will be used.
  399.  
  400. ============================================================================
  401.  
  402. Function 0006H - Cancel pcANYWHERE IV and remove it from memory
  403.  
  404.  
  405. Calling parameters:
  406.  
  407.           AX    = 0006H
  408.  
  409. Returns:
  410.  
  411.           AX    = Status of function
  412.                     0000H - Function completed successfully
  413.                     FFD2H - Unable to release allocated memory
  414.                     FFD1H - Unable to release trapped interrupt vectors
  415.  
  416.  
  417. Description:
  418.  
  419.           This function terminates the current remote access
  420.           session (if one is active) and removes pcANYWHERE IV
  421.           from memory if possible. In order for pcANYWHERE IV to
  422.           remove itself from memory, it must be able to restore
  423.           all of the interrupt vectors it has trapped to their
  424.           original values and the memory block in which it resides
  425.           must be a valid DOS memory block. If pcANYWHERE IV
  426.           reports that it could not release its memory, either
  427.           the DOS memory allocation tables have been corrupted
  428.           or pcANYWHERE IV was not loaded into memory by DOS. If
  429.           one or more of the interrupt vectors that pcANYWHERE IV
  430.           has trapped is not currently pointing to pcANYWHERE IV's
  431.           service routine for that interrupt, pcANYWHERE IV will
  432.           not restore any of the vectors and will not remove
  433.           itself from memory. This situation could occur if other
  434.           TSR's are loaded after pcANYWHERE IV or if this function
  435.           is called from an application that has trapped interrupt
  436.           vectors.
  437.  
  438. ============================================================================
  439.  
  440. Function 8000H - Read data from communication channel
  441.  
  442.  
  443. Calling parameters:
  444.  
  445.           AX    = 8000H
  446.           DS:BX = Pointer to buffer for received data
  447.           CX    = Buffer size or 0 to get count of characters available
  448.  
  449. Returns:
  450.  
  451.           AX    = Number of characters read or avaiable
  452.                      0 - No data available
  453.                     >0 - Character count
  454.                     <0 - Error
  455.  
  456.  
  457. Description:
  458.  
  459.           This function reads data from pcANYWHERE IV's communication
  460.           channel and places it in the buffer at DS:BX. As many
  461.           characters as are available up to the buffer size will
  462.           be copied to the destination buffer. If the buffer size
  463.           passed to this function in the CX register is 0, the number
  464.           of bytes available for reading will be returned without
  465.           copying any data. For example, if your application expects
  466.           exactly 10 characters to be received, it may call this
  467.           function repeatedly with CX=0 until a value of 10 or greater
  468.           is returned. Once it is known that at least 10 characters
  469.           are available, it may then issue a call to this function
  470.           with CX=10 to read the required 10 bytes. Using this
  471.           method simplifies the task of reading a specific number
  472.           of characters by eliminating the need for the application
  473.           to maintain its own buffer count and pointer.
  474.  
  475.           Under normal operation, error codes should not be returned.
  476.           If an error code is returned (high bit of AX=1), a serious
  477.           problem exists in the communications driver and your program
  478.           should assume that the connection has been lost.
  479.  
  480. ============================================================================
  481.  
  482. Function 8001H - Write data over communication channel
  483.  
  484.  
  485. Calling parameters:
  486.  
  487.           AX    = 8001H
  488.           DS:BX = Pointer to buffer containing data to write
  489.           CX    = Number of characters in buffer
  490.  
  491. Returns:
  492.  
  493.           AX    = Number of characters written
  494.                      0 - No characters written
  495.                     >0 - Character count
  496.                     <0 - Error
  497.  
  498. Description:
  499.  
  500.           This function causes the data in the specified buffer to
  501.           be placed in the communications driver's transmit buffer.
  502.           If the driver cannot accept all of the data, it will take
  503.           as much as it can and return the number of characters
  504.           accepted (0 if its buffer is completely full).
  505.  
  506.           As with the read data function, this function should never
  507.           return an error. If it does, your application should
  508.           assume that the connection has been lost and should
  509.           resume pcANYWHERE IV so that it may attempt to prepare
  510.           for a new connection.
  511.  
  512. ============================================================================
  513.  
  514. Function 8002H - Get connection status
  515.  
  516.  
  517. Calling parameters:
  518.  
  519.           AX    = 8002H
  520.  
  521. Returns:
  522.  
  523.           AX    = Connection status
  524.                     >0 - Connection active
  525.                      0 - Connection lost
  526.                     <0 - Error
  527.  
  528.  
  529. Description:
  530.  
  531.           This function returns the state of the logical connection
  532.           between the host and remote. The type of device in use
  533.           and the "Connection ended by" selection specified in the
  534.           configuration determine how loss of connection is detected.
  535.           For network devices, this function returns the true state
  536.           of the logical connection. For serial devices, this function
  537.           returns the state of the signal selected in the "Connection
  538.           ended by" selection. If "Always connected" is selected,
  539.           this function will always return a non-zero value in AX.
  540.  
  541. ============================================================================
  542.