SANEI 1.3.1.74-c434
Functions
sanei_access.h File Reference

Interface file for the sanei_access functions. More...

Go to the source code of this file.

Functions

void sanei_access_init (const char *backend)
 Initialize sanei_access. More...
 
SANE_Status sanei_access_lock (const char *devicename, SANE_Word timeout)
 Set a lock. More...
 
SANE_Status sanei_access_unlock (const char *devicename)
 Unlock a previously set lock. More...
 

Detailed Description

Interface file for the sanei_access functions.

The idea is to provide some simple locking/unlocking mechanism, which can be used to protect device access from more than one frontend simultaneously.

Function Documentation

◆ sanei_access_init()

void sanei_access_init ( const char *  backend)

Initialize sanei_access.

This function must be called before any other sanei_access function.

Parameters
backend- backend name, who uses this lib

◆ sanei_access_lock()

SANE_Status sanei_access_lock ( const char *  devicename,
SANE_Word  timeout 
)

Set a lock.

The function tries to open/create exclusively a lock file in $PATH_SANE_LOCK_DIR. If the file could be created successfully, the function fills in the process ID. The complete filename of the lockfile is created as follows: $PATH_SANE_LOCK_DIR/LCK..<devicename> If the lock could not be set, the function tries it until the timeout period has been elapsed.

Parameters
devicename- unique part of the lockfile name
timeout- time in seconds to try to set a lock
Returns
  • SANE_STATUS_GOOD - if the lock has been successfully set
  • SANE_STATUS_ACCESS_DENIED - the lock could not set

◆ sanei_access_unlock()

SANE_Status sanei_access_unlock ( const char *  devicename)

Unlock a previously set lock.

The function tries to unlock a previously created lock. The lockfile will be closed and removed.

Parameters
devicename- part of the lockfile name, use for sanei_acess_lock()
Returns
  • SANE_STATUS_GOOD - currently the one and only return value