dhcpd code changes
Jeffrey Hutzelman
jhutz at cmu.edu
Tue Nov 10 16:54:14 UTC 2009
--On Tuesday, November 10, 2009 05:21:14 PM +0530 Ashmath Khan
<hashmat.email at gmail.com> wrote:
> Hi Jeffrey,
Please use the mailing list, rather than sending mail to me directly.
There are lots of people there who can potentially help you and/or correct
errors. Sending privately to me means that those people don't get to see
your message, and you get to wait until I have time to respond. That may
be a very long time -- if I don't have time to answer something the moment
I see it, I may never get back to it.
> I couldn't figure out much about print_subexpression. I couldn't find from
> where this function is invoked.
>From itself, and from print_expression(), which is used for logging
expressions for debugging purposes. Contrary to my previous note, this is
not actually used for dumping code to the leases file; write_expression()
is used for that.
> Also I couldn't understand how are the magic numbers associated with
> 'len'. thanks.
They're not magic. The 'len' parameter is the amount of space left in the
output buffer.
> if (*len *> 6) {
My code says "if (len > 6)". It looks like you put ** around things here
in an attempt to highlight them. Don't do that -- it doesn't look like
emphasis, and it _does_ change the meaning of the code.
> rv = 4;
> strcpy (buf, "(eq ");
Add 4 constant characters to the output
> rv += print_subexpression (expr -> data.equal [0],
> buf + rv, len - rv - 2);
recursive call for the first subexpression, putting the output past the
constant characters we already added and leaving room for the 2 we have not
yet added. Whatever space is left can be used to print the subexpression.
> buf [rv++] = ' ';
Add another constant character
> rv += print_subexpression (expr -> data.equal [1],
> buf + rv, len - rv - 1);
Another recursive call, this time leaving space only for the one character
we haven't added yet.
> buf [rv++] = ')';
Add the close paren.
> buf [rv] = 0;
> return rv;
> }
This whole time, 'rv' has been the number of characters we added to the
buffer. That becomes the return value of print_subexpressioin.
-- Jeffrey T. Hutzelman (N3NHS) <jhutz+ at cmu.edu>
Carnegie Mellon University - Pittsburgh, PA
More information about the dhcp-hackers
mailing list