Re: Questions re Sane API digression & MF Scanner

Oliver Rauch (oliver.rauch@Wolfsburg.DE)
Mon, 15 Nov 1999 09:19:27 +0100

Dave Restall - System Administrator wrote:

> Hi,
> I have started writing a backend for the Scanace 9630 scanner and
> unfortunately I hit a brick wall at my first attempt. The brick wall
> being :-
> The API seems pretty clear to follow and relatively simple to
> implement, however there are a few things that I don't understand in the
> code that I've looked at for backends. I'm only dealing with sane_init
> here, but the API says this :-
> "The version code of the backend is returned in the value pointed to by
> version_code. If the pointer is NULL, no version code is returned.
> Argument authorize is either a pointer to a function that is invoked
> when the backend requires authentication for a specific resource or NULL
> if the frontend does not support authentication."
> Regarding authorization, should "frontend" read "backend" ?

The frontend may have a routine that asks for authorization.
If the backend likes to do a authorization test, it can call
the authorization routine if the pointer to it is != NULL.
The returned values are loagin string and password string.

You do not need this for a simple backend. In fact there is no
backend that uses that in the moment.

If you want to test it, xsane is the only frontend (as far as I know)
that supports the authorization dialog.

> Apart from that this bit of the spec seems pretty clear, however when I
> started to read the code for other backends, all sorts of stuff seems to
> go on, especially when it comes to initialising the hardware. Surely
> this belongs in sane_open ?
> I also don't understand the following :-
> stubs.c What is it for ?

Each backend uses the sane_* names for the defined sane function calls.
So for a frontend you have to hide the 20 or more names of e.g. sane_init,
only the sane_init function of the backend the frontend wants to use
is seen by the frontend.sane-dll needs this so you can
select a backend, otherwise you would have to link only ONE backend
to a frontend.

You do not have to care about that.

> I was hoping it would be a pile of function stubs with comments in like
> "put code for function Y here" in it, e.g. a template for the backend
> but it seems to have a more sinister use.
> What does the ENTRY macro do in stubs.c ?

Simply forget this here.
There is no demo backend code.
look at the existing backends. The pnm backend is a short backend
where you can see how comunication between frontend and
backend is done, but it is coded a bit ugly.
I think the umax backend is good to read, you can find out
everything you need if you look at it - I think.

> I'm not new to C but am new to the style used in the code development
> for sane so all help will be greatly appreciated.
> I'm also willing to create an empty template with the "Put code to do X
> for your scanner here" if it will help and write the FAQ for writing a
> backend but I'll need help and guidance, can I use the list for this ?

Yes, of course.


E-Mail:         mailto:Oliver.Rauch@Wolfsburg.DE

Source code, list archive, and docs:
To unsubscribe: echo unsubscribe sane-devel | mail