home *** CD-ROM | disk | FTP | other *** search
/ PC Press 1997 July / Sezamfile97_1.iso / msdos / clipper / nettos11.a01 / SYNCHRO / CLRRELFI.PRG next >
Text File  |  1993-02-23  |  5KB  |  223 lines

  1. /*
  2.  * File......: CLRRELFI.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. #include "netto.ch"
  20. #include "ftint86.ch"
  21.  
  22. #define OP_RELEASE     236      /* DON'T CHANGE THIS! */
  23. #define OP_CLEAR       237      /* DON'T CHANGE THIS! */
  24.  
  25.  
  26. /*  $DOC$
  27.  *  $FUNCNAME$
  28.  *     FN_RELFILE()
  29.  *  $CATEGORY$
  30.  *     Synchronization
  31.  *  $ONELINER$
  32.  *     Release file (ASCIIZ)
  33.  *  $SYNTAX$
  34.  *
  35.  *     fn_relFile( <cFile> ) -> lSuccess
  36.  *
  37.  *  $ARGUMENTS$
  38.  *
  39.  *     <cFile> is the name of the specific file to unlock 
  40.  *
  41.  *  $RETURNS$
  42.  *     
  43.  *     <lSuccess>, .t. if you succeed, .f. if you don't.  Check
  44.  *     FN_ERROR() for error codes.  The only valid one is 
  45.  *
  46.  *            255 - No files found
  47.  *
  48.  *   
  49.  *  $DESCRIPTION$
  50.  *
  51.  *     Use fn_relFile() to unlock a specific file.
  52.  *
  53.  *  $EXAMPLES$
  54.  *
  55.  *  $SEEALSO$
  56.  *
  57.  *  $INCLUDE$
  58.  *
  59.  *  $END$
  60.  */
  61.  
  62.  
  63. function fn_relfile( cFn )
  64.   return _fnOpFile( OP_RELEASE, cFn )
  65.  
  66.  
  67. /*  $DOC$
  68.  *  $FUNCNAME$
  69.  *     FN_RELFISE()
  70.  *  $CATEGORY$
  71.  *     Synchronization
  72.  *  $ONELINER$
  73.  *     Release file set
  74.  *  $SYNTAX$
  75.  *
  76.  *     fn_relFiSe() -> lSuccess
  77.  *
  78.  *  $ARGUMENTS$
  79.  *
  80.  *     None
  81.  *
  82.  *  $RETURNS$
  83.  *
  84.  *     <lSuccess>, which should be meaningless because the 
  85.  *     underlying API returns nothing.  Ignore the result
  86.  *     code.
  87.  *
  88.  *  $DESCRIPTION$
  89.  *
  90.  *     This unlocks every file in the workstation's log table, yet
  91.  *     leaves them in the log table.  If you happen to have left
  92.  *     one or more files open when you "release" them, they become
  93.  *     detached and can't be accessed until you do a LockFileSet 
  94.  *     again.
  95.  *
  96.  *     If you want to clear a file from the log table, you'll 
  97.  *     need to use fn_clrFile() or fn_clFiSet().
  98.  *
  99.  *  $EXAMPLES$
  100.  *
  101.  *  $SEEALSO$
  102.  *     FN_CLRFILE() FN_CLFISET()
  103.  *  $INCLUDE$
  104.  *
  105.  *  $END$
  106.  */
  107.  
  108. function fn_relFiSe()
  109.   return _fnReq( 205, "", "" ) == ESUCCESS
  110.  
  111.  
  112. /*  $DOC$
  113.  *  $FUNCNAME$
  114.  *     FN_CLRFILE()
  115.  *  $CATEGORY$
  116.  *     Synchronization 
  117.  *  $ONELINER$
  118.  *     Clear file (ASCIIZ)
  119.  *  $SYNTAX$
  120.  *   
  121.  *     fn_clrFile( <cFn> ) -> lSuccess
  122.  *
  123.  *  $ARGUMENTS$
  124.  *
  125.  *    <cFn> -  The name of the file to remove from the log table
  126.  *
  127.  *  $RETURNS$
  128.  *
  129.  *    <lSuccess>, .t. if the call succeeds, .f. if it doesn't.
  130.  *    Check FN_ERROR() for a specific error code.  Currently the 
  131.  *    only error code reported is code 255, "No files found."
  132.  *
  133.  *  $DESCRIPTION$
  134.  *
  135.  *    Use this call to unlock a specific file _and_ remove it from
  136.  *    the log table.  
  137.  *
  138.  *    If you want to unlock all files and remove all files from 
  139.  *    the log table, use fn_clFiSet().
  140.  *
  141.  *  $EXAMPLES$
  142.  *
  143.  *  $SEEALSO$
  144.  *    FN_CLFISET()
  145.  *  $INCLUDE$
  146.  *
  147.  *  $END$
  148.  */
  149.  
  150. function fn_clrFile( cFn )
  151.   return _fnOpFile( OP_CLEAR, cFn )
  152.  
  153.  
  154.  
  155. /*  $DOC$
  156.  *  $FUNCNAME$
  157.  *     FN_CLFISET()
  158.  *  $CATEGORY$
  159.  *     Synchronization 
  160.  *  $ONELINER$
  161.  *     Clear file set
  162.  *  $SYNTAX$
  163.  *
  164.  *     fn_clFiSet() -> lSuccess
  165.  *
  166.  *  $ARGUMENTS$
  167.  *
  168.  *     None
  169.  *
  170.  *  $RETURNS$
  171.  *
  172.  *     <lSuccess>, a value to be ignored since the underlying API
  173.  *     returns nothing.  Pay no attention to this return value.
  174.  *
  175.  *  $DESCRIPTION$
  176.  *
  177.  *     Use this call to unlock every file in the log table, and 
  178.  *     then wipes out the log table.  
  179.  *
  180.  *  $EXAMPLES$
  181.  *
  182.  *  $SEEALSO$
  183.  *      FN_CLRFILE()
  184.  *  $INCLUDE$
  185.  *
  186.  *  $END$
  187.  */
  188.  
  189. function fn_clFiSet()
  190.   return _fnReq( 207, "", "" ) == ESUCCESS
  191.  
  192. /* ------------------------------------------------------------------ */
  193.  
  194. static function _fnOpFile( nOp, cFn )
  195.   local aRegs[ INT86_MAX_REGS ], lRes := .f.
  196.  
  197.   if pcount() == 1 .and. valtype( cFn ) == "C" .and. !empty( cFn )
  198.  
  199.      cFn := alltrim( cFn )
  200.      cFn := iif( len( cFn ) > 254, substr( cFn, 1, 254 ), cFn )
  201.      cFn += chr( 0 )
  202.  
  203.      aRegs[ AX ]  := makehi( nOp )
  204.      aRegs[ DS ]  := cFn
  205.      aRegs[ DX ]  := REG_DS
  206.  
  207.      lRes := ft_int86( INT21, aRegs )
  208.      if lRes 
  209.         if UNSIGNED( LOWBYTE( aRegs[ AX ] ) ) # 0
  210.            lRes := .f.
  211.            _fnSetErr( UNSIGNED( LOWBYTE( aRegs[ AX ] ) ) )
  212.         else
  213.            _fnSetErr( ESUCCESS )
  214.         endif
  215.      else
  216.         _fnSetErr( EINT86 )
  217.      endif
  218.   else
  219.      _fnSetErr( EBADPARM )
  220.   endif    
  221.  
  222.   return lRes
  223.