0

these days i have been reading the dhcpd source code in which there are many such usage represented below,i don't understand what that is...

what happened when the struct packet *packet; between the param list and the { ?

int locate_network (packet)
struct packet *packet;
{
    struct iaddr ia;
    struct data_string data;
    struct subnet *subnet = (struct subnet *)0;
    struct option_cache *oc;

    if ((oc = lookup_option(&agent_universe, packet->options,
               RAI_LINK_SELECT)) == NULL)
    oc = lookup_option(&dhcp_universe, packet->options,
               DHO_SUBNET_SELECTION);
    //.........
}
Hank Zhang
  • 89
  • 5
  • The real question is what modern compiler can still handle old-style K&R function declarations. Is the code you're reading of historical interest only? – Cody Gray - on strike Jul 10 '13 at 09:04
  • 3
    Other duplicates: [What weird C syntax is this?](http://stackoverflow.com/questions/4380599/what-weird-c-syntax-is-this), [What is this strange function definition syntax in C?](http://stackoverflow.com/q/3016213), [C statement between function declaration and curly brace](http://stackoverflow.com/q/9834916), [C variable declarations after function heading in definition](http://stackoverflow.com/q/2633776), [Alternate C syntax for function declaration use cases](http://stackoverflow.com/q/1630631), [Why c functions can be defined this way?](http://stackoverflow.com/q/4191649) – Cody Gray - on strike Jul 10 '13 at 09:04
  • no its not for historical interest only,i want to know how the dhcp server works @CodyGray – Hank Zhang Jul 10 '13 at 09:09

1 Answers1

4

That's the older K&R style of function declaration, superceded by the ANSI style you are probably more familiar with. See also Function declaration: K&R vs ANSI

Community
  • 1
  • 1
Paul Dixon
  • 295,876
  • 54
  • 310
  • 348