6 * Main code for "iwmulticall". This is a wrapper for the multicall version
7 * of the wireless tools.
8 * You need to link this code against "-lm".
9 * Thanks to Ned Ludd <solar@gentoo.org> for the inspiration...
11 * This file is released under the GPL license.
12 * Copyright (c) 1997-2004 Jean Tourrilhes <jt@hpl.hp.com>
15 /***************************** INCLUDES *****************************/
17 #include <libgen.h> /* Basename */
19 /**************************** PROTOTYPES ****************************/
21 /* Prototypes of the main of each tool */
23 main_iwconfig(int argc,
35 main_iwgetid(int argc,
38 /************************** MULTICALL HACK **************************/
40 * The idea for multicall is to put all the tools and the library in
41 * the same binary. This way, you can save the overhead of the library,
42 * of each tool, can better optimise the code and throw away the stuff
43 * you don't need from the library.
44 * This almost divide the size of the tools by two (without stripping).
45 * On the down side, you no longer have the libiw for other tools to
46 * use, but for the target systems (embedded), this doesn't matter
47 * much, as they just need to configure the card...
48 * Note that splitting the lib and the multicall tools would not
49 * make sense, as most gains are found in the inclusion of the lib...
51 * Our strategy is to include directly the *.c, rather than compile
52 * them separatly. This allow to simplify compilation and hide the
53 * multicall tweaks from the other tools.
54 * Yeah, this leads to a bit a preprocessor abuse...
58 /* We need the library */
61 /* Get iwconfig in there. Mandatory. */
62 #define main(args...) main_iwconfig(args)
63 #define iw_usage(args...) iwconfig_usage(args)
64 #define find_command(args...) iwconfig_find_command(args)
70 /* Get iwlist in there. Scanning support is pretty sweet. */
71 #define main(args...) main_iwlist(args)
72 #define iw_usage(args...) iwlist_usage(args)
73 #define find_command(args...) iwlist_find_command(args)
80 /* Get iwspy in there, it's not that big. */
81 #define main(args...) main_iwspy(args)
84 #endif /* WE_ESSENTIAL */
86 /* Get iwpriv in there. Mandatory for HostAP and some other drivers. */
87 #define main(args...) main_iwpriv(args)
88 #define iw_usage(args...) iwpriv_usage(args)
93 /* Do we really need iwgetid ? Well, it's not like it's a big one */
94 #define main(args...) main_iwgetid(args)
95 #define iw_usage(args...) iwgetid_usage(args)
100 /* iwevent is useless for most people, don't grab it ? */
102 /* ifrename is big and useless for those systems */
105 /******************************* MAIN ********************************/
107 /*------------------------------------------------------------------*/
115 char * call_name = basename(argv[0]); /* Strip path */
117 /* This is a testing hack */
118 if(!strcmp(call_name, "iwmulticall") && (argc > 0))
122 call_name = basename(argv[0]);
125 /* Just check the name under which we were called... */
127 if(!strcmp(call_name, "iwconfig"))
128 return(main_iwconfig(argc, argv));
129 if(!strcmp(call_name, "iwlist"))
130 return(main_iwlist(argc, argv));
132 if(!strcmp(call_name, "iwspy"))
133 return(main_iwspy(argc, argv));
134 #endif /* WE_ESSENTIAL */
135 if(!strcmp(call_name, "iwpriv"))
136 return(main_iwpriv(argc, argv));
137 if(!strcmp(call_name, "iwgetid"))
138 return(main_iwgetid(argc, argv));
140 /* Uh oh... Not supposed to come here. */
141 printf("iwmulticall : you are not supposed to call me this way...\n");