FT_NWSEMOPEN

FT_NWSEMOPEN()
 Open or create a NetWare semaphore

 Syntax

       FT_NWSEMOPEN( <cName>, <nInitVal>, <@nHandle>, <@nOpenCnt> ) -> nRc

 Arguments

      <cName> is the semaphore name, maximum length is 127 characters.

      <nInitVal> is the initial value for the semaphore.  It must start
      as a positive number, to a maximum of 127.

      <@nHandle> is the semaphore handle.  THIS MUST BE PASSED BY
      REFERENCE!  On exit, <nHandle> will contain a numeric value that
      refers to the opened semaphore.  You will need it to pass to
      other semaphore functions!  PASS IT BY REFERENCE!

      <@nOpenCnt> is the number of stations that have opened the
      semaphore.  THIS MUST BE PASSED BY REFERENCE! On exit, <nOpenCnt>
      will contain a numeric value.

 Returns

      nRc, a numeric result code, as follows:

            0 - success
          254 - Invalid semaphore name length
          255 - Invalid semaphore value

      <nHandle> will contain the semaphore handle, and
      <nOpenCnt> will contain the number of stations that have opened
      the semaphore.

 Description

      A semaphore is simply a label that indirectly controls network
      activity.  There is a semaphore name, which can be up to 127
      characters, and an associated value, which can range from 0 to
      127.

      A semaphore can be used for many things, but is most often used
      to limit the number of users in an application, and to control
      access to a network resource.

      A semaphore essentially allows you to place locks on resources
      other than files.

      An application begins the process by calling FT_NWSEMOPEN().
      If the semaphore doesn't exist, NetWare will create it.
      FT_NWSEMOPEN() returns a handle that is used in other semaphore
      calls.

      Applications use FT_NWSEMWAIT() to wait for a semaphore to
      become available.  FT_NWSEMWAIT() decrements the semaphore's
      value by 1.  If the value > 0, then the application should
      be allowed to access the semaphore's resource.  If the value
      goes negative, then the application is placed in a queue.
      How long your app is in the queue is determined by how you
      set the timeout parameter.  If you can't get the resource in
      the time you allot, you're let out of the queue and the
      value increments by 1 again.

      When an application finishes with a semaphore, it should
      call FT_NWSEMSIG() to increment the value, and then
      FT_NWSEMCLOSE() to close the semaphore.  When the semaphore's
      open count goes to 0, NetWare deletes it.

      FT_NWSEMEX() can be used to examine the value and open count
      without affecting them.

      For an interesting discussion on the operating system aspects
      of semaphores, check "Operating Systems Design and Implementation"
      by A. Tanenbaum, page 60.  For more details on NetWare's
      semaphore facilities, refer to Charles Rose's "Programmer's
      Guide to NetWare".  The "Programmer's Guide" will make an
      excellent companion guide to the source code for all NetWare
      functions in the Nanforum Toolkit.

 Examples

      LOCAL nInitVal, nRc, nHandle, nOpenCnt

      nInitVal := 2
      nRc      := FT_NWSEMOPEN( "Semaphore Test", nInitVal, ;
                                @nHandle, @nOpenCnt )

      IF nRc != 0
        QOUT =: "Error: " + STR( nRc ) )
        QUIT
      ENDIF

 Source: NWSEM.PRG

 Author: Glenn Scott

See Also: FT_NWSEMEX() FT_NWSEMWAIT() FT_NWSEMSIG() FT_NWSEMCLOSE() FT_NWSEMLOCK()

FT_NWSEMLOCK

FT_NWSEMLOCK()
 Perform a semaphore "lock"

 Syntax

      FT_NWSEMLOCK ( <cSemaphore>, <@nHandle> ) -> lRet

 Arguments

     <cSemaphore> is the name of a semaphore you want to "lock."
     <nHandle> is the semaphore's handle, if you get the lock.
     THIS MUST BE PASSED BY REFERENCE!

 Returns

     lRet == .t. if you get the lock, .f. if you don't.
     If the lock succeeds, <nHandle> will contain the semaphore
     handle.  If it fails, the value of <nHandle> is undefined.

 Description

     FT_NWSEMLOCK() uses the Nanforum Toolkit's NetWare Semaphore API
     functions in order to provide a general purpose "lock" you can use in
     a NetWare environment.

     An interesting byproduct of NetWare's semaphore functions is
     the "open count" which tells you how many connections have this
     semaphore open.  This is different from the semaphore's _value_,
     which is set when the semaphore is opened and changed with
     signal() and wait().

     The point of semaphores is that you don't care how many users
     are using the resource; you merely wait on a semaphore until
     the resource becomes available or you give up.  When you're done,
     you signal it and off you go.

     Back to the open count.  FT_NWSEMLOCK() opens the semaphore
     as named in <cSemaphore>.  After it is opened, the open count
     is checked.  If it is anything other than 1, that means someone
     else has it (or you failed in your open) so the semaphore is
     closed and the "lock" is refused.  If the value is 1, then your
     app is that 1 station so the "lock" is granted.

     You can use a semaphore lock to control access to anything
     that Clipper's RLOCK() and FLOCK() can't help you with, such
     as text files written with the low level file i/o functions,
     etc.

 Examples

     LOCAL nHandle := 0
     IF FT_NWSEMLOCK( "k:\apps\error.log", @nHandle )
         // Note, you aren't actually LOCKING this file, you are
         // just locking a semaphore by the same name.  As long as
         // all apps that might be using this file are cooperating
         // with the same kind of semaphore lock, you can effectively
         // control access to the file.
       ELSE
         QOUT("Couldn't lock file.")
       ENDIF
       * Processing, then:
       FT_NWSEMUNLOCK( nHandle )

 Source: NWSEM.PRG

 Author: Glenn Scott

See Also: FT_NWSEMOPEN() FT_NWSEMEX() FT_NWSEMWAIT() FT_NWSEMSIG() FT_NWSEMUNLOCK()

FT_NWSEMEX

FT_NWSEMEX()
 Examine a NetWare semaphore's value and open count

 Syntax

       FT_NWSEMEX( <nHandle>, <@nValue>, <@nOpenCnt> ) -> nRc

 Arguments

      <nHandle> is the semaphore handle, returned from a previous call
      to FT_NWSEMOPEN().

      <@nValue> will get the current semaphore value.  THIS NUMERIC
      ARGUMENT MUST BE PASSED BY REFERENCE!

      <@nOpenCnt> will get the current number of workstations
      that have opened the semaphore.  THIS NUMERIC ARGUMENT MUST BE
      PASSED BY REFERENCE!

 Returns

      nRc, a numeric, as follows:

            0 - success
          255 - invalid semaphore handle

      In addition, nValue will be set to the semaphore's current value,
      and nOpenCnt will be set to the number of stations that have
      opened the semaphore.

 Description

      See the description for FT_NWSEMOPEN().

 Examples

    nInitVal := 2
    nHandle  := 0
    nOpenCnt := 0

    FT_NWSEMOPEN( "Semaphore Test", nInitVal, @nHandle, @nOpenCnt )

    nRc := FT_NWSEMWAIT( nHandle )
        IF nRc == 254
       QOUT( "All slots for this resource are currently in use" )
       QUIT
    ENDIF

    FT_NWSEMEX( nHandle, @nValue, @nOpenCnt )
    QOUT( "Semaphore test -> Open at [" + ;
          ALLTRIM(STR(nOpenCnt))        + ;
          "] stations, value is ["      + ;
          ALLTRIM(STR(nValue)) + "]" )

 Source: NWSEM.PRG

 Author: Glenn Scott

See Also: FT_NWSEMOPEN() FT_NWSEMWAIT() FT_NWSEMSIG() FT_NWSEMCLOSE() FT_NWSEMLOCK()


			

FT_NWSEMCLOSE

FT_NWSEMCLOSE()
 Close a NetWare semaphore

 Syntax

      FT_NWSEMCLOSE( <nHandle> )  -> nRc

 Arguments

     <nHandle> is the semaphore handle, returned from a previous call
     to FT_NWSEMOPEN().

 Returns

     nRc, a numeric, as follows:

            0 - success
          255 - invalid semaphore handle

 Description

     Call FT_NWSEMCLOSE() when the app is finished.  This decrements
     the open count for the semaphore.  If the open count hits zero,
     the semaphore is deleted by NetWare.

 Examples

     QOUT( "Close returns:  " + STR( FT_NWSEMCLOSE( nHandle ) ) )

 Source: NWSEM.PRG

 Author: Glenn Scott

See Also: FT_NWSEMOPEN() FT_NWSEMEX() FT_NWSEMWAIT() FT_NWSEMSIG() FT_NWSEMLOCK()

FT_NWLSTAT

FT_NWLSTAT()
 Return the current Novell NetWare logical station number

 Syntax

      FT_NWLSTAT() -> nStatNum

 Arguments

     None

 Returns

     A numeric corresponding to the current logical station number
     assigned by NetWare.

 Description

     In order to find out information about a particular node logged
     in to a NetWare server, you will need the logical
     station number, also known as a "connection number."  This
     function will return that number.  This will be a number from 1 to 100
     under NetWare 286, or from 1 to 250 under NetWare 386.  This is *not*
     the same as a physical station number.

     This function requires FT_INT86().

     This function does NOT test for the existence of the NetWare shell.
     The behavior is undefined if no shell is loaded.

 Examples

     QOut( "Logical station: " + str( FT_NWLSTAT() ) )

 Source: NWLSTAT.PRG

 Author: Glenn Scott

 

FT_NOVPURGE

FT_NOVPURGE()
 Purge all deleted files on a Novell server

 Syntax

    FT_NOVPURGE() -> lTemp

 Arguments

   None

 Returns

   .T. if successful, otherwise .F.

 Description

  This function is to purge those files that a workstation has
  previously deleted.  This function only works on a Novell network.

 Examples

  ERASE FILE foo.bar
  ERASE FILE foo2.bar
  ERASE FILE foo3.bar
  ? FT_NOVPURGE()

 Source: NOVPURGE.ASM

 Author: David Minter

 

FT_NOVDMP2

FT_NOVDMP2()
 Determine Novell server's dynamic memory area 2 availability

 Syntax

    FT_NOVDMP2() -> nDMP2

 Arguments

   None

 Returns

   The total available dynamic memory area 2 on current server, in bytes.

 Description

  This function is used primarily on Novell 2.15 TTS Servers.  Dynamic
  Memory area 2 is where the transaction tracking takes place.  This
  function allows you to query the ability of the server to handle any
  transactions you may wish to start.  (I personally don't let the area
  fall below 8K).  It is generally only useful in large batch situations
  and if you are using NETLIB's TTS capability.

 Examples

  t_trans(ON)       // Netlib function
  DO WHILE FT_NOVDMP2() > 8000 .AND. ! Eof()

     REPLACE foo WITH 'bar'
     SKIP

  ENDDO
  t_trans(OFF)

 Source: NOVDMP2.ASM

 Author: David Minter

 

FT_LOGOUT

FT_LOGOUT()
 Logout from all currently connected NetWare file servers

 Syntax

     FT_LOGOUT() -> NIL

 Arguments

    None

 Returns

    NIL

 Description

   This routine is used to log the current user out of all connected file
   servers and return control back to Clipper.  This is handy for writing
   your own login screens in Clipper.  After the FT_LOGOUT() function is
   called, you could have a login screen come up, and the users would
   never see the DOS prompt again!

   This routine was designed and written for Advanced NetWare 286 v 2.0 or
   NetWare 386 v 3.0 or better.  It has been tested on Advanced NetWare 286
   v 2.15 rev A & C, NetWare 386 v 3.0.

   Written in Microsoft MASM v5.1

 Examples

   FT_LOGOUT()
   DO LOGINPRG

 Source: LOGOUT.ASM

 Author: James R. Zack

 

FT_ENDCAP

FT_ENDCAP()
 Cancel a specific NetWare print queue capture

 Syntax

     FT_ENDCAP( [ <nLPTPortNumber> ] ) -> lResult

 Arguments

    <nLPTPortNumber> is the captured LPT port to cancel.  If the
    parameter is omitted, the default port of LPT1: is used.

 Returns

    .T. if successful

 Description

   This routine is used to close a specific capture on the specified LPT
   port.  When this command is issued, the LPT port is no longer redirected
   to the print queue, and any information waiting in queue to be printed
   will be printed.

   This routine was designed and written for Advanced NetWare 286 v 2.1 or
   NetWare 386 v 3.0 or better.  It has been tested on Advanced NetWare 286
   v 2.15 rev A & C and NetWare 386 v 3.0.

   This source code was written for Microsoft Macro Assembler v 5.1.  It
   should work with any assembler with minor modifications.

 Examples

   (in DOS)
   F:>CAPTURE S=ServerName Q=PrintQueueName T=0 L=2
   Device LPT2: re-routed to queue PrintQueueName on server ServerName.
   F:>CAPTURE S=ServerName Q=PrintQueueName T=0 L=1
   Device LPT1: re-routed to queue PrintQueueName on server ServerName.

   (in your Clipper application)
   FT_ENDCAP(2) // Closes LPT2: capture, and flushes print buffer
   ...
   ...
   FT_ENDCAP()  // Closes LPT1: (default) capture, and flushes
                //    print buffer

 Source: ENDCAP.ASM

 Author: James R. Zack