[sane-devel] Last call for new backends

Henning Meier-Geinitz henning at meier-geinitz.de
Tue Apr 15 22:32:24 BST 2003


Hi,

On Wed, Apr 16, 2003 at 01:56:56AM +1000, Martijn van Oosterhout wrote:
> I guess I wasn't clear. Many of the commands sent to the scanner consist of
> integers (both 2 and 4 byte) and sometimes they are big endian, sometimes
> little endian. So, the code has hton(l|s) in places and not in others.

I have seen that in the code now.

> To solve that we'd have to go through the entire code base checking that the
> right bytes appear in the right places in each structure (maybe do away
> with the structures altogether). That's a bit of work and I'd rather do that
> when I have someone who can actually *test* the result.

Yes, no problem.

> Actually, params.xres = htons( xres ) would probably work fine on most
> architectures. It's the more insidious little accesses that'll trip you up.

I had to use an #ifdef for the __attribute__ (packed) for the
structures so it won't be used on non-gcc compilers. So if there are
alihnment issues on some systems, the struct may nor work even if the
endianess is ok.

In my backends I usually create such buffers manually which is more
ugly but safe:

SANE_Byte command[20];
command[0] = command_byte;
command[1] = (some_value >> 16) & 0xff;
command[2] = (some_value >> 8) & 0xff;
command[3] = (some_value >> 0) & 0xff;
...

Bye,
  Henning



More information about the sane-devel mailing list