home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / clipper / nettos11.zip / SYNCHRO / LOGFILE.PRG < prev    next >
Text File  |  1993-02-23  |  3KB  |  117 lines

  1. /*
  2.  * File......: LOGFILE.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 LOG_FILE             0
  23. #define LOG_AND_LOCK_FILE    1
  24. #define NO_WAIT              0
  25.  
  26. /*  $DOC$
  27.  *  $FUNCNAME$
  28.  *     FN_LOGFILE()
  29.  *  $CATEGORY$
  30.  *     Synchronization
  31.  *  $ONELINER$
  32.  *     Log file (ASCIIZ)
  33.  *  $SYNTAX$
  34.  *
  35.  *     fn_logFile( cFn, nLockDir, nTimeout ) -> nRes
  36.  *
  37.  *  $ARGUMENTS$
  38.  *
  39.  *     <cFn>        - File path (full path and name of file)
  40.  *                    Maximum length is 254 characters
  41.  *
  42.  *     <nLockDir>   - Locking directive:
  43.  *                     
  44.  *                        0 = Log File.  This only logs the record
  45.  *                            in the table; it does not lock the file.
  46.  *                        1 = Log and Lock File
  47.  *
  48.  *                    The default is 0.
  49.  *
  50.  *     <nTimeout>   - Amount of time to wait for a file to 
  51.  *                    become available, in ticks (1 tick = 
  52.  *                    1/18th of a second).  0 (the default) =
  53.  *                    no wait.
  54.  *
  55.  *     The <nLockDir> and <nTimeOut> parameters are only supported
  56.  *     in "extended lock mode" (see FN_GETLMOD()) and will be 
  57.  *     ignored if you are currently in "compatibility mode."
  58.  *
  59.  *  $RETURNS$
  60.  *
  61.  *     <nRes>, a numeric, as follows:
  62.  *
  63.  *         If you're in extended lock mode:
  64.  *
  65.  *                 0   =  Success
  66.  *               150   =  Server out of memory
  67.  *               254   =  Timeout failure
  68.  *               255   =  Hardware failure
  69.  *
  70.  *         If you're in compatibility mode:
  71.  *
  72.  *                 0   =  No error
  73.  *               255   =  Failure
  74.  *
  75.  *  $DESCRIPTION$
  76.  *
  77.  *      This is the first call you use to do file locks.  You use this
  78.  *      call to place the name of the file in a log table the server
  79.  *      maintains for each workstation, and optionally lock the file.
  80.  *
  81.  *      You can log more files if you need to and lock them later with
  82.  *      fn_lkFiSet().
  83.  *
  84.  *  $EXAMPLES$
  85.  *
  86.  *  $SEEALSO$
  87.  *     FN_GETLMOD() FN_SETLMOD()
  88.  *  $INCLUDE$
  89.  *
  90.  *  $END$
  91.  */
  92.  
  93. function fn_logFile( cFn, nLockDir, nTimeout )          // Log file (ASCIIZ)
  94.   local aRegs[ INT86_MAX_REGS ], nCurMode
  95.  
  96.   default cFn      to "",       ;
  97.           nLockDir to LOG_FILE, ;
  98.           nTimeOut to NO_WAIT
  99.  
  100.   cFn := iif( len( cFn ) > 254, substr( cFn, 1, 254 ), cFn )
  101.   cFn += chr( 0 )
  102.  
  103.   nCurMode := fn_getLMod()
  104.  
  105.   aRegs[ AX ]          := makehi( 235 )     // EBh
  106.   aRegs[ DS ]          := cFn
  107.   aRegs[ DX ]          := REG_DS
  108.  
  109.   if nCurMode == 1                          // Extended lock mode?
  110.     aRegs[ AX ]          += nLockDir
  111.     aRegs[ BP ]          := nTimeout
  112.   endif
  113.  
  114.   _fnSetErr( iif( ft_int86( INT21, aRegs ), ESUCCESS, EINT86 ) )
  115.  
  116.   return UNSIGNED( lowbyte( aRegs[AX] ) )
  117.