Re: typdef in iw_handler.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 1, 2010 at 2:49 PM, Darshan Ghumare
<darshan.ghumare@xxxxxxxxx> wrote:
>>
>
> http://publications.gbdirect.co.uk/c_book/chapter8/typedef.html

iw_handler is the type. For example:

int do_something(struct net_device *dev, struct iw_request_info *info,
    union iwreq_data *wrqu, char *extra)
{
    /* do stuff */
}

int do_something_else( <same thing here> )
{
    /* more stuff */
}

iw_handler handlers[10];
handlers[0] = do_something;
handlers[1] = do_something_else;
... etc. ...

int choice = 4;
handlers[choice](dev, blah1, info_arg, iwreq_blah_arg, NULL);

This allows you to set up an array of functions that all take the same
arguments but do different things. You can then use a variable to
choose the function without caring what it does, and pass the same
arguments regardless of which function is being called.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux