Re: Q: Developing a backend

David Mosberger-Tang (David.Mosberger@acm.org)
Mon, 26 Jan 1998 21:33:31 -0800

>>>>> On Fri, 23 Jan 1998 20:51:18 +0200, Vassilis Virvilis <vasvir@iit.nrcps.ariadne-t.gr> said:

Vassilis> 1 Does the below statement make any sense

Vassilis> c=SANE_UNFIX(a+b);

Vassilis> Is this somewhere close to c=SANE_UNFIX(a) + SANE_UNFIX(b);

If a+b does not overflow, then the two expressions are identical
(except for machines where "double" has less than 32 bits of
precision).

Vassilis> which one should be used?

I'd say the latter is safer, as overflow is likely to be a bigger
problem than loss of precision.

Vassilis> 2 I noticed my sane_read is called with a buffer of
Vassilis> 32768. Why is that? Has anything to do with SCSI_SG_BUF
Vassilis> (or whatever the name is).

No, that's the size of the buffer the frontend passes to it. It's
unrelated to SCSI_SG_BUF. scanimage.c happens to use a 32KB buffer.

Vassilis> 3 Should be the sane_controlo_option Reentrant? If not how
Vassilis> am I going to handle complex dependancies without code
Vassilis> doubling? I don't have this one very clear in my mind. I
Vassilis> will be more specific when I 'll have my code handy...

The SANE distribution is not designed for multi-threading. So doesn't
have to be re-entrant in this sense. However, it must be re-entrant
with respect to having multiple independent devices open at the same
time (i.e., avoid global variables to hold scanner specific state).

Vassilis> 4 My backend is based on sane-0.68. What issues must have
Vassilis> in mind in order to be most portable with the newer
Vassilis> sane's. Does the API changed?

The API is meant to be fairly stable (at least until work on v2.0
begins, which is still far in the future). I'd say: hack away, then
lets take a look at your code.

In general, I prefer if backends respect the GNU coding standard
(available from prep.ai.mit.edu:/pub/gnu)---it makes it easier for me
to maintain the many backends.

Good luck,

--david

--
Source code, list archive, and docs: http://www.mostang.com/sane/
To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com