[SLUG] c programming - structures

2004-10-16 Thread Lucas King
hello,
how does one compare two structures of the same type?
Anjuta is returning an error when i compile :
 if (sin1 == sin2) {
   ..
   ..
 }
where sin1 and sin2 are structures of the same type.  the sin structure 
is sockaddr_in.

thanking you in advance,
Lucas


The information contained in this e-mail message and any accompanying files
is or may be confidential.If you are not the intended recipient, any use, 
dissemination, reliance,forwarding, printing or copying of this e-mail or
any attached files is unauthorised.This e-mail is subject to copyright. No
part of it should be reproduced,adapted or communicated without the written
consent of the copyright owner.If you have received this e-mail in error,
please advise the sender immediately by return e-mail, or telephone and
delete all copies.Fairfax does not guarantee the accuracy or completeness
of any information contained in this e-mail or attached files. Internet
communications are not secure, therefore Fairfax does not accept legal
responsibility for the contents of this message or attached files.


--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] c programming - structures

2004-10-16 Thread Benno
On Sat Oct 16, 2004 at 16:21:04 +1000, Lucas King wrote:
hello,

how does one compare two structures of the same type?

Anjuta is returning an error when i compile :
 if (sin1 == sin2) {
   ..
   ..
 }

where sin1 and sin2 are structures of the same type.  the sin structure 
is sockaddr_in.

thanking you in advance,


You need to either compare each element, or use memcp; eg:

if (memcmp(sin1, sin2, sizeof sin1) == 0) {


}

Benno
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] c programming - structures

2004-10-16 Thread Jan Schmidt
quote who=Benno
 On Sat Oct 16, 2004 at 16:21:04 +1000, Lucas King wrote:
 how does one compare two structures of the same type?
 You need to either compare each element, or use memcp; eg:
 
 if (memcmp(sin1, sin2, sizeof sin1) == 0) {
 
 
 }

and memcmp isn't usually a great idea, because most structures have padding
bytes that will be uninitialised (random) data.

J.
-- 
Jan Schmidt  [EMAIL PROTECTED]

I came for the quality. I stayed for the freedom. -- Sean Neakums
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] bind: rndc setup, where the keygen files go ?

2004-10-16 Thread Voytek

quote who=O Plameras
 Voytek wrote:

yes, I have, though, that's a bit of a moot point at this time, as, I
can't even reload named, so, whatever change I make, won't get reflected
till I can control named

 You do not need to have named running to check your  zone files and the
 rest of
 it including your configuration.

 Also, examine the following files:

 1. /etc/sysconfig/named

empty, except for comments

 2. /etc/init.d/named

on 1st look, that will start/stop bind without rndc, but, uses rnds for
other functions... I think..?

I should've tried it before I gave up, maybe

 3. /var/log/messages after starting named and especially when it fails.

it was essentially pointing out that authentication was failing

Oscar,

I've given up on trying to make it work (once I've figured out how to
disable the key requirements...)

fwiw, the bind and zones are seemingly OK, as, the dns server is working
fine, as master dns

I'll try it again at another time... maybe...

-- 
Voytek
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Maximum process ID

2004-10-16 Thread Christopher Vance
On Fri, Oct 15, 2004 at 03:33:57PM +1000, Michael Kraus wrote:
I'm developing a database application that  uses the inserting processes
pid. Problem is that I'm wondering how big this pid should be?
It depends on your platform:
traditional 3
Linux   32768
FreeBSD 9
Solaris tunable up to 99
Plan9   just uses 32 bits - I can't be bothered booting
to check if it's signed or not
(You might care to +/- 1 on the values above, as some may be
inclusive, and some exclusive.)
Given that this is mostly a Linux list, you know which number to use,
and why things will break if you move your stuff elsewhere.  :-)
--
Christopher Vance
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] c programming - structures

2004-10-16 Thread amos
Jan Schmidt wrote:
quote who=Benno
On Sat Oct 16, 2004 at 16:21:04 +1000, Lucas King wrote:
how does one compare two structures of the same type?
You need to either compare each element, or use memcp; eg:
if (memcmp(sin1, sin2, sizeof sin1) == 0) {
}

and memcmp isn't usually a great idea, because most structures have padding
bytes that will be uninitialised (random) data.
J.
You can overcome this by memset(3)'ing the struc to zero's when it's 
allocated, or use calloc(3).

How usually do you compare structures? Member by member?
C++'s default comparison is at the bit level, how does it overcome
the uninitialized padding problem you pointed?
Cheers,
--Amos
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html