[HACKERS] arithmetic about inet

2010-03-07 Thread fanng yuan
I got some point from others.I already red and debug network.c . Now I now
the basic logic behind that. But still I'm confused by arithmetic. I find
some comments on that , I need some one's help.

/*
 * int
 * bitncmp(l, r, n)
 * compare bit masks l and r, for n bits.
 * return:
 * -1, 1, or 0 in the libc tradition.
 * note:
 * network byte order assumed.  this means 192.5.5.240/28 has
 * 0x in its fourth octet.
 * author:
 * Paul Vixie (ISC), June 1996
 */

Why we finish it in this way. Can you help me?


Re: [HACKERS] arithmetic about inet

2010-03-07 Thread tomas
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Mon, Mar 08, 2010 at 09:47:00AM +0800, fanng yuan wrote:
 I got some point from others.I already red and debug network.c . Now I now
 the basic logic behind that. But still I'm confused by arithmetic. I find
 some comments on that , I need some one's help.
 
 /*
  * int
  * bitncmp(l, r, n)
  * compare bit masks l and r, for n bits.
  * return:
  * -1, 1, or 0 in the libc tradition.
  * note:
  * network byte order assumed.  this means 192.5.5.240/28 has
  * 0x in its fourth octet.
  * author:
  * Paul Vixie (ISC), June 1996
  */
 
 Why we finish it in this way. Can you help me?

Sorry, I don't understand your question. Are you asking: why this return
value?

If that is your question then: Paul Vixie is referring to the function
strcmp() from libc: it returns an integer less than 0 if the first string
is less than the second, 0 if both are equal and an integer greater
than 0 if the second string is greater than the first.

This is a very handy convention, which you can see at work in Kerninghan
 Ritchie's classical Programming in C.

Now I hope I understood your question right :-)

Regards
- -- tomás
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFLlJYbBcgs9XrR2kYRAgebAJ9f9VtjwfYjBUtKvxG4iFQCqisnzACfdBe2
y+giKF0WENVEXgbhCPtYs2Q=
=uLJS
-END PGP SIGNATURE-

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] arithmetic about inet

2010-03-05 Thread fanng yuan
Hi Guys:
I just do some research on ip address storage and comparing. I found pgsql
already fixed that issue. I want to get some point from your guys about how
this work. Could you give me some data about that . Also I'm interesting in
pgsql . Could you give me some suggestion about how to hack pgsql.
Thank.


Re: [HACKERS] arithmetic about inet

2010-03-05 Thread Robert Haas
On Thu, Mar 4, 2010 at 4:36 AM, fanng yuan fanngy...@gmail.com wrote:
 Hi Guys:
 I just do some research on ip address storage and comparing. I found pgsql
 already fixed that issue. I want to get some point from your guys about how
 this work. Could you give me some data about that . Also I'm interesting in
 pgsql . Could you give me some suggestion about how to hack pgsql.
 Thank.

You asked almost this exact some question 2 days ago and got a response, so...?

...Robert

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers