[sane-devel] attach function status?

Henning Meier-Geinitz henning@meier-geinitz.de
Wed, 1 May 2002 22:53:31 +0200


Hi,

On Wed, May 01, 2002 at 11:09:28AM -0700, Dave Close wrote:
> The usual sequence of operations in most backends is to call
> sanei_config_attach_matching_devices() in the sane_init() function.
> Because it cannot return status while sane_init() can, sane_init()
> lies to the frontend and always returns SANE_STATUS_GOOD.

That's not a lie. The backend was inited successfully. It's not a
failure if the device wasn't found. The backend doesn't know if it's
supposed to find one (or even several) device(s). Some backends don't
even search for devices in sane_init(). There aren't that many reasons
for sane_init to return anything other than SANE_STATUS_GOOD. One
reason may be that insufficient memory or that it depends on a library
that doesn't exist on the system.

Currently the meaning of return values for sane_init is not defined
but it's on the tODO list for SANE2.

> Then when the frontend tries to call sane_open(), there is no valid
> device name and sane_open() reports SANE_STATUS_INVALID. This is
> misleading at best.

No, that's ok. A device could have been added or removed after
sane_init() was called. However, if you call a frontend with an
explicit device name, the backend can check exactly this device and
return a meaningful status in sane_open.

Bye,
  Henning