IonicWind Software

Aurora Compiler => General Discussion => Topic started by: Zen on January 09, 2006, 01:26:10 PM

Title: conversion trouble
Post by: Zen on January 09, 2006, 01:26:10 PM
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
Title: Re: conversion trouble
Post by: Earn on January 09, 2006, 01:52:03 PM
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
Title: Re: conversion trouble
Post by: Zen on January 09, 2006, 01:59:24 PM
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
Title: Re: conversion trouble
Post by: Earn on January 09, 2006, 02:34:25 PM
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
Title: Re: conversion trouble
Post by: Zen on January 09, 2006, 02:37:30 PM
oh great thanks earn. Now i can at least check if its giving back the right IP.

Cheers, Lewis
Title: Re: conversion trouble
Post by: Parker on January 09, 2006, 06:48:57 PM
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).
Title: Re: conversion trouble
Post by: Zen on January 10, 2006, 05:38:29 AM
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