From: Bj�rn Hell Larsen
Subject: Problems with Allecro CL Foreign Function interface/unsigned values
Date: 
Message-ID: <usobl8p53.fsf@infostream.no>
I am trying to access the byte-order support routines
htonl/ntohl/htons/ntohs from Allegro CL using the
foreign function interface, and have run into problems
with passing/converting unsigned values.

My attempt at this is

(ff:def-foreign-call ntohl ((l :unsigned-long)) 
	:returning (:unsigned-long integer))

which evaluates OK and seems to work for most
input values, however:

USER(18): (ff:def-foreign-call ntohl ((l :unsigned-long)) 
              :returning (:unsigned-long integer))
NTOHL
USER(19): (ntohl 172705729)
-1052292342
USER(20): 

And so my question is: When I specify that ntohl returns an
unsigned long value that should be converted into an integer,
why does Allegro CL stick me with a negative value?

And how do I get around this?

Thanks in advance for all and any help.


Bjorn
From: Bj�rn Hell Larsen
Subject: Re: Problems with Allegro CL Foreign Function interface/unsigned values
Date: 
Message-ID: <upv6o8cwr.fsf_-_@infostream.no>
Steve Gonedes <········@worldnet.att.net> writes:

> < And so my question is: When I specify that ntohl returns an
> < unsigned long value that should be converted into an integer,
> < why does Allegro CL stick me with a negative value?
> 
> Dunno much about the ff stuff.
> 
> < And how do I get around this?
> 
> You can use the predefined functions. I'm using acl5 and
> `socket:*socket-version*' is set to 2.0, just in case it matters.
> 
> (socket:dotted-to-ipaddr "199.70.101.217") => 3343279577
> (socket:dotted-to-ipaddr "199.70.217" :errorp nil) => -1
> (socket:ipaddr-to-dotted 3343279577) => "199.70.101.217"
> (socket:lookup-hostname "www.yahoo.com") => 3427256394
> (socket:lookup-port "http" "tcp") => 80

Thanks, but this does not really help me address
host/network byte ordering issues.

And what I'm more concerned with is finding out why the ff
definitions doesn't work the way I thought they should.


Bj�rn