home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / clipper / nettos11.zip / TTS / TTS.PRG
Text File  |  1993-04-01  |  10KB  |  522 lines

  1. /*
  2.  * File......: TTS.PRG
  3.  * Author....: Glenn Scott
  4.  * CIS ID....: 71620,1521
  5.  * Date......: $Date$
  6.  * Revision..: $Revision$
  7.  * Log file..: $Logfile$
  8.  * 
  9.  * This is an original work by Glenn Scott and is placed in the
  10.  * public domain.
  11.  *
  12.  * Modification history:
  13.  * ---------------------
  14.  *
  15.  * $Log$
  16.  *
  17.  */
  18.  
  19. /*  $DOC$
  20.  *  $FUNCNAME$
  21.  *      OVERVIEW
  22.  *  $CATEGORY$
  23.  *      TTS
  24.  *  $ONELINER$
  25.  *      TTS Overview
  26.  *  $SYNTAX$
  27.  *
  28.  *  $ARGUMENTS$
  29.  *
  30.  *  $RETURNS$
  31.  *
  32.  *  $DESCRIPTION$
  33.  *
  34.  *       [ Put the Overview here ]
  35.  *
  36.  *  $EXAMPLES$
  37.  *
  38.  *  $SEEALSO$
  39.  *
  40.  *  $INCLUDE$
  41.  *
  42.  *  $END$
  43.  */
  44.  
  45. #include "ftint86.ch"
  46. #include "netto.ch"
  47.  
  48. #define    TT_BEGIN       0  /* Never change these defines! */
  49. #define    TT_END         1
  50. #define    TT_AVAIL       2
  51. #define    TT_ABORT       3
  52. #define    TT_STATUS      4
  53. #define    TT_GET_AT      5
  54. #define    TT_SET_AT      6
  55. #define    TT_GET_WT      7
  56. #define    TT_SET_WT      8
  57.  
  58. /*  $DOC$
  59.  *  $FUNCNAME$
  60.  *     FN_TTAVAIL()
  61.  *  $CATEGORY$
  62.  *     TTS
  63.  *  $ONELINER$
  64.  *     Determine TTS availability
  65.  *  $SYNTAX$
  66.  *
  67.  *     fn_ttAvail() -> nAvail
  68.  *
  69.  *  $ARGUMENTS$
  70.  *
  71.  *     None
  72.  *
  73.  *  $RETURNS$
  74.  *
  75.  *    <nAvail>, a numeric as follows:
  76.  *
  77.  *             0     Transaction tracking not available
  78.  *             1     Transaction tracking is available
  79.  *           253     Transaction tracking disabled
  80.  *
  81.  *  $DESCRIPTION$
  82.  *
  83.  *    Use this call to determine whether or not TTS has been
  84.  *    installed on the network.  Note that you can use TTS
  85.  *    calls even if the NetWare network doesn't have TTS
  86.  *    installed, and you'll get 0 return codes from all the 
  87.  *    TTS API functions.
  88.  *
  89.  *    A simple wrapper around this function is FN_HASTTS(),
  90.  *    which allows a simple true/false return.  See the 
  91.  *    FN_HASTTS() documentation.
  92.  *
  93.  *  $EXAMPLES$
  94.  *
  95.  *    if fn_ttAvail() == 1
  96.  *       qout( "We have transaction tracking!" )
  97.  *    endif
  98.  * 
  99.  *  $SEEALSO$
  100.  *    FN_HASTTS()
  101.  *  $INCLUDE$
  102.  *
  103.  *  $END$
  104.  */
  105.  
  106.  
  107. function fn_ttAvail()
  108.   local aRet := _fnTTreq( TT_AVAIL )
  109.   return lowbyte( aRet[ AX ] )
  110.  
  111. /*  $DOC$
  112.  *  $FUNCNAME$
  113.  *     FN_HASTTS()
  114.  *  $CATEGORY$
  115.  *     TTS
  116.  *  $ONELINER$
  117.  *     Is TTS available?  Yes or No?
  118.  *  $SYNTAX$
  119.  *     
  120.  *     fn_hasTTS() -> lHasTTS
  121.  *
  122.  *  $ARGUMENTS$
  123.  *
  124.  *     None
  125.  *
  126.  *  $RETURNS$
  127.  *
  128.  *     Logical TRUE (.t.) if TTS is available, FALSE (.f.) if it 
  129.  *     isn't.
  130.  *
  131.  *  $DESCRIPTION$
  132.  *
  133.  *     See the documentation for FN_TTAVAIL().  
  134.  *
  135.  *  $EXAMPLES$
  136.  *
  137.  *    if fn_hasTTS()
  138.  *       qout( "We have TTS!" )
  139.  *    endif
  140.  *
  141.  *  $SEEALSO$
  142.  *    FN_TTAVAIL()
  143.  *  $INCLUDE$
  144.  *
  145.  *  $END$
  146.  */
  147.  
  148.  
  149. function fn_hasTTS()
  150.   return ( fn_ttAvail() == 1 )
  151.  
  152. /*  $DOC$
  153.  *  $FUNCNAME$
  154.  *     FN_TTBEGIN()
  155.  *  $CATEGORY$
  156.  *     TTS
  157.  *  $ONELINER$
  158.  *     Begin transaction
  159.  *  $SYNTAX$
  160.  *
  161.  *     fn_ttBegin() -> nRes
  162.  *
  163.  *  $ARGUMENTS$
  164.  *
  165.  *     None
  166.  *
  167.  *  $RETURNS$
  168.  *
  169.  *     <nRes>, a numeric, as follows:
  170.  *
  171.  *          0       Success!
  172.  *        150       Out of dynamic workspace
  173.  *        254       There's an implicit transaction already 
  174.  *                  active, but now it has been converted to
  175.  *                  an explicit transaction
  176.  *        255       There's an explicit transaction already 
  177.  *                  active
  178.  *
  179.  *  $DESCRIPTION$
  180.  *
  181.  *     Begin an explicit transaction on the current file server.
  182.  *
  183.  *  $EXAMPLES$
  184.  *
  185.  *    if fn_hasTTS()
  186.  *       if fn_ttBegin() == 0
  187.  *          qout( "Transaction started!" )
  188.  *          nTrans := fn_ttEnd()
  189.  *          qout( "Transaction ended, trans # = ", nTrans )
  190.  *       else
  191.  *          qout( "Can't begin the transaction" )
  192.  *       endif
  193.  *    endif
  194.  *
  195.  *  $SEEALSO$
  196.  *    FN_TTEND()
  197.  *  $INCLUDE$
  198.  *
  199.  *  $END$
  200.  */
  201.  
  202.  
  203. function fn_ttBegin()
  204.   local aRet := _fnTTreq( TT_BEGIN )
  205.   return lowbyte( aRet[ AX ] )
  206.  
  207. /*  $DOC$
  208.  *  $FUNCNAME$
  209.  *     FN_TTEND()
  210.  *  $CATEGORY$
  211.  *     TTS 
  212.  *  $ONELINER$
  213.  *     End transaction
  214.  *  $SYNTAX$
  215.  *
  216.  *     fn_ttEnd( @nTran ) -> nRes
  217.  *
  218.  *  $ARGUMENTS$
  219.  *
  220.  *     <nTran>, a numeric, which will be replaced with the 
  221.  *     transaction reference number.  THIS MUST BE PASSED
  222.  *     BY REFERENCE!
  223.  *
  224.  *  $RETURNS$
  225.  *
  226.  *    <nTran>, the transaction's "transaction reference number."
  227.  *    You can use this number with FN_TTSTAT().
  228.  *
  229.  *    <nRes>, a numeric, as follows:
  230.  *
  231.  *          0     Success
  232.  *        253     Transaction tracking is disabled
  233.  *        254     Transaction ended, records locked
  234.  *        255     No explicit transaction active
  235.  *
  236.  *  $DESCRIPTION$
  237.  *
  238.  *  $EXAMPLES$
  239.  *
  240.  *  $SEEALSO$
  241.  *     FN_TTBEGIN() FN_TTSTAT()
  242.  *  $INCLUDE$
  243.  *
  244.  *  $END$
  245.  */
  246.  
  247.  
  248. function fn_ttEnd( nTran )
  249.   local aRegs := _fnTTreq( TT_END )
  250.   default nTran to 0
  251.  
  252.   nTran := _fnReg2L( aRegs[ CX ], aRegs[ DX ] )
  253.  
  254.   return lowbyte( aRegs[ AX ] ) 
  255.  
  256. /*  $DOC$
  257.  *  $FUNCNAME$
  258.  *     FN_TTABORT()
  259.  *  $CATEGORY$
  260.  *     TTS
  261.  *  $ONELINER$
  262.  *     Abort transaction
  263.  *  $SYNTAX$
  264.  *
  265.  *     fn_ttAbort() -> nRes
  266.  *
  267.  *  $ARGUMENTS$
  268.  *
  269.  *     None
  270.  *
  271.  *  $RETURNS$
  272.  *
  273.  *     <nRes>, a numeric, as follows:
  274.  *
  275.  *          0     Success!
  276.  *        253     TTS was disabled, nothing done
  277.  *        254     Transaction ended; records locked
  278.  *        255     No explicit transaction was active
  279.  *
  280.  *  $DESCRIPTION$
  281.  *
  282.  *  $EXAMPLES$
  283.  *
  284.  *  $SEEALSO$
  285.  *
  286.  *  $INCLUDE$
  287.  *
  288.  *  $END$
  289.  */
  290.  
  291.  
  292. function fn_ttAbort()
  293.   local aRet := _fnTTreq( TT_ABORT )
  294.   return lowbyte( aRet[ AX ] )
  295.  
  296. /*  $DOC$
  297.  *  $FUNCNAME$
  298.  *     FN_TTSTAT()
  299.  *  $CATEGORY$
  300.  *     TTS
  301.  *  $ONELINER$
  302.  *     Get TTS Transaction Status
  303.  *  $SYNTAX$
  304.  * 
  305.  *     fn_ttStat( nTran ) -> lWritten
  306.  *
  307.  *  $ARGUMENTS$
  308.  *
  309.  *     <nTran>, a numeric, which is the transaction reference 
  310.  *     number returned from fn_ttEnd().
  311.  *
  312.  *  $RETURNS$
  313.  *
  314.  *    <lWritten>, logical TRUE (.t.) if the transaction has been
  315.  *    written to disk, FALSE (.f.) if it hasn't yet been 
  316.  *    written.
  317.  *
  318.  *  $DESCRIPTION$
  319.  *
  320.  *  $EXAMPLES$
  321.  *
  322.  *  $SEEALSO$
  323.  *
  324.  *  $INCLUDE$
  325.  *
  326.  *  $END$
  327.  */
  328.  
  329.  
  330. function fn_ttStat( nNum )
  331.   local aTmp := _fnL2Reg( nNum ), aRet
  332.   aRet := _fnTTreq( TT_STATUS, aTmp[1], aTmp[2] )
  333.   return lowbyte( aRet[ AX ] ) == 0 
  334.  
  335. /*  $DOC$
  336.  *  $FUNCNAME$
  337.  *      FN_TTGAPT()
  338.  *  $CATEGORY$
  339.  *      TTS
  340.  *  $ONELINER$
  341.  *      Get TTS Application Thresholds
  342.  *  $SYNTAX$
  343.  *
  344.  *      fn_ttGApT() -> aRes
  345.  *
  346.  *  $ARGUMENTS$
  347.  *
  348.  *  $RETURNS$
  349.  *
  350.  *      <aRes>, an array, as follows:
  351.  *
  352.  *             aRes[1]     Return code.  Should be 0.
  353.  *             aRes[2]     Logical lock threshold
  354.  *             aRes[3]     Physical lock threshold
  355.  *
  356.  *  $DESCRIPTION$
  357.  *
  358.  *  $EXAMPLES$
  359.  *
  360.  *  $SEEALSO$
  361.  *
  362.  *  $INCLUDE$
  363.  *
  364.  *  $END$
  365.  */
  366.  
  367.  
  368. function fn_ttGapT()
  369.   return _fnGThresh( TT_GET_AT )
  370.  
  371. /*  $DOC$
  372.  *  $FUNCNAME$
  373.  *     FN_TTSAPT()
  374.  *  $CATEGORY$
  375.  *     TTS
  376.  *  $ONELINER$
  377.  *     Set TTS Application Thresholds
  378.  *  $SYNTAX$
  379.  *
  380.  *     fn_ttSApT( nLog, nPhy ) -> lSuccess
  381.  *
  382.  *  $ARGUMENTS$
  383.  *
  384.  *     <nLog>, a numeric
  385.  *
  386.  *     <nPhy>, a numeric
  387.  *
  388.  *  $RETURNS$
  389.  *
  390.  *     
  391.  *  $DESCRIPTION$
  392.  *
  393.  *  $EXAMPLES$
  394.  *
  395.  *  $SEEALSO$
  396.  *
  397.  *  $INCLUDE$
  398.  *
  399.  *  $END$
  400.  */
  401.  
  402.  
  403. function fn_ttSapT( nLog, nPhy )
  404.   return ( _fnSThresh( TT_SET_AT, nLog, nPhy ) == 0 )
  405.  
  406. /*  $DOC$
  407.  *  $FUNCNAME$
  408.  *      FN_TTGWST()
  409.  *  $CATEGORY$
  410.  *      TTS
  411.  *  $ONELINER$
  412.  *      Get TTS workstation thresholds
  413.  *  $SYNTAX$
  414.  *
  415.  *      fn_ttGWsT() -> aRes
  416.  *
  417.  *  $ARGUMENTS$
  418.  *
  419.  *      None
  420.  *
  421.  *  $RETURNS$
  422.  *
  423.  *      <aRes>, an array, as follows
  424.  *
  425.  *             aRes[1]     Return code.  Should be 0.
  426.  *             aRes[2]     Logical lock threshold
  427.  *             aRes[3]     Physical lock threshold
  428.  *
  429.  *  $DESCRIPTION$
  430.  *
  431.  *  $EXAMPLES$
  432.  *
  433.  *  $SEEALSO$
  434.  *
  435.  *  $INCLUDE$
  436.  *
  437.  *  $END$
  438.  */
  439.  
  440.  
  441. function fn_ttGwsT()
  442.   return _fnGThresh( TT_GET_WT )     
  443.  
  444. /*  $DOC$
  445.  *  $FUNCNAME$
  446.  *     FN_TTSWST()
  447.  *  $CATEGORY$
  448.  *     TTS
  449.  *  $ONELINER$
  450.  *     Set TTS Workstation Thresholds
  451.  *  $SYNTAX$
  452.  *
  453.  *     fn_ttSWsT( nLog, nPhy ) -> lSuccess
  454.  *
  455.  *  $ARGUMENTS$
  456.  *
  457.  *    <nLog>, a numeric
  458.  *
  459.  *    <nPhy>, a numeric
  460.  *
  461.  *  $RETURNS$
  462.  *
  463.  *    <lSuccess>
  464.  *
  465.  *  $DESCRIPTION$
  466.  *
  467.  *  $EXAMPLES$
  468.  *
  469.  *  $SEEALSO$
  470.  *
  471.  *  $INCLUDE$
  472.  *
  473.  *  $END$
  474.  */
  475.  
  476.  
  477. function fn_ttSwsT( nLog, nPhy )
  478.   return ( _fnSThresh( TT_SET_WT, nLog, nPhy ) == 0 )
  479.  
  480. /* ------------------------------------------------------------------------ */
  481.  
  482. static function _fnGThresh( xFunc )
  483.   local aRegs := _fnTTReq( xFunc )
  484.   return { ;
  485.      lowbyte(  aRegs[ AX ] ), ;    // Completion code
  486.      lowbyte(  aRegs[ CX ] ), ;    // Logical lock threshold
  487.      highbyte( aRegs[ CX ] )  ;    // Physical lock threshold
  488.      }
  489.  
  490. static function _fnSThresh( xFunc, nLog, nPhy )
  491.   local aRet
  492.   default nLog to 0, nPhy to 0
  493.  
  494.   aRet := _fnTTReq( xFunc, makehi( nPhy ) + nLog )
  495.   return lowbyte( aRet[ AX ] )
  496.  
  497. static function _fnTTreq( xFunc, cx, dx )
  498.   local aRegs[ INT86_MAX_REGS ]
  499.  
  500.   default cx to 0, dx to 0
  501.  
  502.   aRegs[ AX ] := makehi( 199 ) + xFunc      // C7h
  503.  
  504.   if ( xFunc == TT_SET_AT ) .or. ( xFunc == TT_SET_WT )
  505.      aRegs[ CX ] := cx
  506.   endif
  507.  
  508.   if ( xFunc == TT_STATUS )
  509.      aRegs[ CX ] := cx
  510.      aRegs[ DX ] := dx
  511.   endif
  512.  
  513.   if !ft_int86( INT21, aRegs )
  514.      _fnSetErr( EINT86 )
  515.   else
  516.      _fnSetErr( lowbyte( aRegs[ AX ] ) )
  517.   endif
  518.  
  519.   return aRegs
  520.      
  521. /* ------------------------------------------------------------------------ */
  522.