Re: MoreSCF troubles (beginner)
Re: MoreSCF troubles (beginner)
- Subject: Re: MoreSCF troubles (beginner)
- From: Jens Bauer <email@hidden>
- Date: Tue, 4 Jun 2002 03:51:32 +0200
Hi Juan,
On Mon, 3 Jun, 2002, Juan I. Leon <email@hidden> wrote:
>
Having said that, I am trying to make use of the MoreSCDNSDigest
>
construct. I am obviously not doing it correctly as I keep getting an
>
incompatible pointer warning when I try to assign serverAddresses and
>
the searchDomains . Can someone please give me an example of how to
>
properly set this up (I need to be able to assign multiple in_addr's and
>
multiple domains as well).
Try something like this:
MoreSCDNSDigest dnsDigest;
in_addr ip_addr;
ItemCount dnsCount;
in_addr *dnsBuf;
...
...
memset(&dnsDigest, 0, sizeof(dnsDigest));
dnsDigest.serverAddressesCount = 0;
dnsDigest.serverAddresses = NULL; /* NULL is OK if the count is 0. */
dnsDigest.searchDomainsCount = 0;
dnsDigest.searchDomains = NULL; /* NULL is OK if the count is 0. */
dnsCount = 0;
if(dns1) /* if we have a primary IP address */
{
dnsCount++;
}
if(dns2)
{
dnsCount++;
}
dnsBuf = NULL;
if(dnsCount)
{
dnsBuf = (in_addr *) malloc(sizeof(in_addr) * dnsCount);
dnsCount = 0;
if(dnsBuf)
{
if(dns1 && inet_aton(dns1, &dnsBuf[dnsCount]))
{
dnsCount++;
}
if(dns2 && inet_aton(dns2, &dnsBuf[dnsCount]))
{
dnsCount++;
}
}
dnsDigest.serverAddresses = dnsBuf;
dnsDigest.serverAddressesCount = dnsCount;
}
Note: dns1 and dns2 are plain cstrings.
(The above snippet was modified for readability after copying it).
Love,
Jens
--
Jens Bauer, Faster Software.
-Let's make the World better, shall we ?
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.