May 18, 2024, 04:33:38 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


conversion trouble

Started by Zen, January 09, 2006, 01:26:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Zen

Hi all.

I am having some trouble converting a function (inet_addr to be specific). The function is declared in the platform SDK as...


unsigned long inet_addr(
  const char* cp
);


i have tried the following...


declare import,inet_addr(byte *cp),unsigned int64;


and...


declare import,inet_addr(string *cp),unsigned int64;


non of my above are working, at least i dont think they are as i am getting the 10049 winsock error which means the address is not correctly formated, the nature of the above function is to do the correct formatting ???

If anyone can solve this little problem that would be great.

Lewis

Earn

Lewis,
I haven't even fired up the Aurora demo yet but my guess (for a thousand points) would be....declare import,inet_addr(string cp),unsigned int;
Earn

Zen

yeh i tried it without the pointer and without the long, just the int. something is going wrong somewhere but i dont know where. i am prety sure it is this function call that is doing it. The trouble is i dont know how and IP address is meant to look after it has been processed.

Lewis

Earn

Okay here's something to test against.

Given an IP address string of "192.168.1.1" inet_addr will return 16885952 or in other words:
ret = inet_addr("192.168.1.1")
ret would equal 16885952

Earn

Zen

oh great thanks earn. Now i can at least check if its giving back the right IP.

Cheers, Lewis

Parker

A long isn't an int64, it's an int. It's kind of confusing, but in C an integer is based on the processors bits, I think. Then you have char(8), short(16), long(32), long long(64, I think).

Zen

Yes i got confused when i looked through the SDK at the data types. I saw long and somehow (because i was tired) came to think it was int64 instead of plain old int.

Lewis