Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- db_VISTA III - d_setlock http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   D_SETLOCK

SUMMARY
   d_setlock(SET,type[,dbn])
   int SET;
   char *type;
   int dbn;

ARGUMENTS
   SET         The set type for which the files are to be locked.

   type        Pointer to a string containing the type of lock to be applied.

   dbn         (optional) The number of the database containing the record.

DESCRIPTION
   This function places a lock on the data files associated with SET. The type
   of lock to be applied is specified by type as follows:
                     Type            Description
                      "r"              Read lock.
                      "w"              Write lock.
                      "x"              Exclusive lock.
                      "k"              Keep lock.
   Read locks allow other programs to read but not update the locked files.
   Write locks prevent all other programs from accessing the locked files and
   can only be issued from within a transaction. Exclusive locks also prevent
   all other programs from accessing the locked files but can be issued
   independent of transactions. Keep locks can only be issued from within a
   transaction and will keep read- and write-locked files read-locked after a
   transaction ends (d_trend normally frees all read- and write-locked files).
   The set type must be locked in order to apply a keep lock; otherwise,
   status S_NOTLOCKED is returned.

   Within a transaction, a read-locked file can be upgraded to a write or
   exculsive lock by calling d_setlock with a write or exclusive lock where a
   read lock already exists. If the upgrade lock request is denied, the read
   lock will remain in effect.

   This function is present in the single-user version of db-VISTA, but
   performs no action. This allows multi-user applications to link with the
   single-user version for operation on stand-alone computers.

CURRENCY CHANGES
   None;

RETURN CODES

    5     S_UNAVAIL     One of the requested files is not available  (i.e.
                        you were on the quere waiting for a file longer
                        than your current time out value).

   -2     S_INVSET      Invalid set type. Probably passed a record or field
                        type instead of a set type.

  -11     S_BADTYPE     An invalid lock type was specified. You may have
                        passed a character (e.g.'r') instead of a
                        string (e.g. "r").

  -23     S_NOTFREE     Set type already locked by your application.

  -31     S_NOTRANS     Requested a write lock outside of a transaction.

EXAMPLE
  char name[32];  /*This function is present in the single-user version of
                   db_VISTA, but performs no action. This allows multi-user
                   applications to link with the single-user version for
                   operation on stand-alone computers.
   author name*/
   ..
   /*Print list of authors*/
   d_setlock (AUTHOR_LIST,"r");
   for(   d_findfm(AUTHOR_LIST);
          db_status == S_OKAY;
          d_findfm(AUTHOR_LIST))
       {
        d_crread(NAME,name);
        printf ("author:%s\n",name);
       }
    d_setfree(AUTHOR_LIST);

See Also: d_freeall d_keyfree d_keylock d_keylstat d_lock d_recfree

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson