diff --git a/src/arch/x86/hci/commands/cpuid_cmd.c b/src/arch/x86/hci/commands/cpuid_cmd.c index d73ce2a3e..b1978d5f2 100644 --- a/src/arch/x86/hci/commands/cpuid_cmd.c +++ b/src/arch/x86/hci/commands/cpuid_cmd.c @@ -95,7 +95,4 @@ static int cpuid_exec ( int argc, char **argv ) { } /** x86 CPU feature detection command */ -struct command cpuid_command __command = { - .name = "cpuid", - .exec = cpuid_exec, -}; +COMMAND ( cpuid, cpuid_exec ); diff --git a/src/arch/x86/hci/commands/pxe_cmd.c b/src/arch/x86/hci/commands/pxe_cmd.c index 473b97f97..cf1a36ed6 100644 --- a/src/arch/x86/hci/commands/pxe_cmd.c +++ b/src/arch/x86/hci/commands/pxe_cmd.c @@ -105,13 +105,5 @@ static int stoppxe_exec ( int argc __unused, char **argv __unused ) { } /** PXE commands */ -struct command pxe_commands[] __command = { - { - .name = "startpxe", - .exec = startpxe_exec, - }, - { - .name = "stoppxe", - .exec = stoppxe_exec, - }, -}; +COMMAND ( startpxe, startpxe_exec ); +COMMAND ( stoppxe, stoppxe_exec ); diff --git a/src/core/exec.c b/src/core/exec.c index a13884b68..534fb9993 100644 --- a/src/core/exec.c +++ b/src/core/exec.c @@ -428,10 +428,7 @@ static int echo_exec ( int argc, char **argv ) { } /** "echo" command */ -struct command echo_command __command = { - .name = "echo", - .exec = echo_exec, -}; +COMMAND ( echo, echo_exec ); /** "exit" options */ struct exit_options {}; @@ -472,10 +469,7 @@ static int exit_exec ( int argc, char **argv ) { } /** "exit" command */ -struct command exit_command __command = { - .name = "exit", - .exec = exit_exec, -}; +COMMAND ( exit, exit_exec ); /** "isset" options */ struct isset_options {}; @@ -507,10 +501,7 @@ static int isset_exec ( int argc, char **argv ) { } /** "isset" command */ -struct command isset_command __command = { - .name = "isset", - .exec = isset_exec, -}; +COMMAND ( isset, isset_exec ); /** "iseq" options */ struct iseq_options {}; @@ -544,10 +535,7 @@ static int iseq_exec ( int argc, char **argv ) { } /** "iseq" command */ -struct command iseq_command __command = { - .name = "iseq", - .exec = iseq_exec, -}; +COMMAND ( iseq, iseq_exec ); /** "sleep" options */ struct sleep_options {}; @@ -587,7 +575,4 @@ static int sleep_exec ( int argc, char **argv ) { } /** "sleep" command */ -struct command sleep_command __command = { - .name = "sleep", - .exec = sleep_exec, -}; +COMMAND ( sleep, sleep_exec ); diff --git a/src/crypto/mishmash/cmd_md4.c b/src/crypto/mishmash/cmd_md4.c index 6413d565a..8991b0250 100644 --- a/src/crypto/mishmash/cmd_md4.c +++ b/src/crypto/mishmash/cmd_md4.c @@ -30,7 +30,4 @@ static int md4sum_exec ( int argc, char **argv ) { return digest_exec ( argc, argv, &md4_algorithm ); } -struct command md4sum_command __command = { - .name = "md4sum", - .exec = md4sum_exec, -}; +COMMAND ( md4sum, md4sum_exec ); diff --git a/src/crypto/mishmash/cmd_sha224.c b/src/crypto/mishmash/cmd_sha224.c index ffc4bf87d..3975a37c5 100644 --- a/src/crypto/mishmash/cmd_sha224.c +++ b/src/crypto/mishmash/cmd_sha224.c @@ -30,7 +30,4 @@ static int sha224sum_exec ( int argc, char **argv ) { return digest_exec ( argc, argv, &sha224_algorithm ); } -struct command sha224sum_command __command = { - .name = "sha224sum", - .exec = sha224sum_exec, -}; +COMMAND ( sha224sum, sha224sum_exec ); diff --git a/src/crypto/mishmash/cmd_sha256.c b/src/crypto/mishmash/cmd_sha256.c index 918c3350b..8076e8dbf 100644 --- a/src/crypto/mishmash/cmd_sha256.c +++ b/src/crypto/mishmash/cmd_sha256.c @@ -30,7 +30,4 @@ static int sha256sum_exec ( int argc, char **argv ) { return digest_exec ( argc, argv, &sha256_algorithm ); } -struct command sha256sum_command __command = { - .name = "sha256sum", - .exec = sha256sum_exec, -}; +COMMAND ( sha256sum, sha256sum_exec ); diff --git a/src/crypto/mishmash/cmd_sha384.c b/src/crypto/mishmash/cmd_sha384.c index c1c505818..ed7265ab9 100644 --- a/src/crypto/mishmash/cmd_sha384.c +++ b/src/crypto/mishmash/cmd_sha384.c @@ -30,7 +30,4 @@ static int sha384sum_exec ( int argc, char **argv ) { return digest_exec ( argc, argv, &sha384_algorithm ); } -struct command sha384sum_command __command = { - .name = "sha384sum", - .exec = sha384sum_exec, -}; +COMMAND ( sha384sum, sha384sum_exec ); diff --git a/src/crypto/mishmash/cmd_sha512.c b/src/crypto/mishmash/cmd_sha512.c index 1bb8e1286..96b8ade88 100644 --- a/src/crypto/mishmash/cmd_sha512.c +++ b/src/crypto/mishmash/cmd_sha512.c @@ -30,7 +30,4 @@ static int sha512sum_exec ( int argc, char **argv ) { return digest_exec ( argc, argv, &sha512_algorithm ); } -struct command sha512sum_command __command = { - .name = "sha512sum", - .exec = sha512sum_exec, -}; +COMMAND ( sha512sum, sha512sum_exec ); diff --git a/src/hci/commands/autoboot_cmd.c b/src/hci/commands/autoboot_cmd.c index 56f39a1ce..010c6fcb0 100644 --- a/src/hci/commands/autoboot_cmd.c +++ b/src/hci/commands/autoboot_cmd.c @@ -73,9 +73,4 @@ static int autoboot_exec ( int argc, char **argv ) { } /** Booting commands */ -struct command autoboot_commands[] __command = { - { - .name = "autoboot", - .exec = autoboot_exec, - }, -}; +COMMAND ( autoboot, autoboot_exec ); diff --git a/src/hci/commands/cert_cmd.c b/src/hci/commands/cert_cmd.c index 75d2ccbed..efa4c3c12 100644 --- a/src/hci/commands/cert_cmd.c +++ b/src/hci/commands/cert_cmd.c @@ -289,17 +289,6 @@ static int certfree_exec ( int argc, char **argv ) { } /** Certificate management commands */ -struct command certmgmt_commands[] __command = { - { - .name = "certstat", - .exec = certstat_exec, - }, - { - .name = "certstore", - .exec = certstore_exec, - }, - { - .name = "certfree", - .exec = certfree_exec, - }, -}; +COMMAND ( certstat, certstat_exec ); +COMMAND ( certstore, certstore_exec ); +COMMAND ( certfree, certfree_exec ); diff --git a/src/hci/commands/config_cmd.c b/src/hci/commands/config_cmd.c index ad415e045..39272196a 100644 --- a/src/hci/commands/config_cmd.c +++ b/src/hci/commands/config_cmd.c @@ -79,7 +79,4 @@ static int config_exec ( int argc, char **argv ) { } /** Configuration UI commands */ -struct command config_command __command = { - .name = "config", - .exec = config_exec, -}; +COMMAND ( config, config_exec ); diff --git a/src/hci/commands/console_cmd.c b/src/hci/commands/console_cmd.c index ba472b9f6..19d19ef1b 100644 --- a/src/hci/commands/console_cmd.c +++ b/src/hci/commands/console_cmd.c @@ -251,17 +251,6 @@ static int cpair_exec ( int argc, char **argv ) { } /** Console management commands */ -struct command console_commands[] __command = { - { - .name = "console", - .exec = console_exec, - }, - { - .name = "colour", - .exec = colour_exec, - }, - { - .name = "cpair", - .exec = cpair_exec, - }, -}; +COMMAND ( console, console_exec ); +COMMAND ( colour, colour_exec ); +COMMAND ( cpair, cpair_exec ); diff --git a/src/hci/commands/dhcp_cmd.c b/src/hci/commands/dhcp_cmd.c index 45a922b51..33c23fc6e 100644 --- a/src/hci/commands/dhcp_cmd.c +++ b/src/hci/commands/dhcp_cmd.c @@ -92,13 +92,5 @@ static int pxebs_exec ( int argc, char **argv ) { } /** DHCP management commands */ -struct command dhcp_commands[] __command = { - { - .name = "dhcp", - .exec = ifconf_exec, /* synonym for "ifconf" */ - }, - { - .name = "pxebs", - .exec = pxebs_exec, - }, -}; +COMMAND ( dhcp, ifconf_exec ); /* synonym for "ifconf" */ +COMMAND ( pxebs, pxebs_exec ); diff --git a/src/hci/commands/digest_cmd.c b/src/hci/commands/digest_cmd.c index 20d33a5d8..a7f43f69e 100644 --- a/src/hci/commands/digest_cmd.c +++ b/src/hci/commands/digest_cmd.c @@ -128,15 +128,8 @@ static int sha1sum_exec ( int argc, char **argv ) { return digest_exec ( argc, argv, &sha1_algorithm ); } -struct command md5sum_command __command = { - .name = "md5sum", - .exec = md5sum_exec, -}; - -struct command sha1sum_command __command = { - .name = "sha1sum", - .exec = sha1sum_exec, -}; +COMMAND ( md5sum, md5sum_exec ); +COMMAND ( sha1sum, sha1sum_exec ); /* Drag in commands for any other enabled algorithms */ REQUIRING_SYMBOL ( digest_exec ); diff --git a/src/hci/commands/dynui_cmd.c b/src/hci/commands/dynui_cmd.c index 6cad63868..56a4acd06 100644 --- a/src/hci/commands/dynui_cmd.c +++ b/src/hci/commands/dynui_cmd.c @@ -350,25 +350,8 @@ static int present_exec ( int argc, char **argv ) { } /** Dynamic user interface commands */ -struct command dynui_commands[] __command = { - { - .name = "menu", - .exec = dynui_exec, - }, - { - .name = "form", - .exec = dynui_exec, - }, - { - .name = "item", - .exec = item_exec, - }, - { - .name = "choose", - .exec = choose_exec, - }, - { - .name = "present", - .exec = present_exec, - }, -}; +COMMAND ( menu, dynui_exec ); +COMMAND ( form, dynui_exec ); +COMMAND ( item, item_exec ); +COMMAND ( choose, choose_exec ); +COMMAND ( present, present_exec ); diff --git a/src/hci/commands/fcmgmt_cmd.c b/src/hci/commands/fcmgmt_cmd.c index 97f10f4dd..c03ebb05f 100644 --- a/src/hci/commands/fcmgmt_cmd.c +++ b/src/hci/commands/fcmgmt_cmd.c @@ -207,13 +207,5 @@ static int fcels_exec ( int argc, char **argv ) { } /** Fibre Channel management commands */ -struct command fcmgmt_commands[] __command = { - { - .name = "fcstat", - .exec = fcstat_exec, - }, - { - .name = "fcels", - .exec = fcels_exec, - }, -}; +COMMAND ( fcstat, fcstat_exec ); +COMMAND ( fcels, fcels_exec ); diff --git a/src/hci/commands/fdt_cmd.c b/src/hci/commands/fdt_cmd.c index dbcbf4447..7cd39279b 100644 --- a/src/hci/commands/fdt_cmd.c +++ b/src/hci/commands/fdt_cmd.c @@ -88,9 +88,4 @@ static int fdt_exec ( int argc, char **argv ) { } /** Flattened Device Tree commands */ -struct command fdt_commands[] __command = { - { - .name = "fdt", - .exec = fdt_exec, - }, -}; +COMMAND ( fdt, fdt_exec ); diff --git a/src/hci/commands/gdbstub_cmd.c b/src/hci/commands/gdbstub_cmd.c index c4a831e7a..ba5edde3a 100644 --- a/src/hci/commands/gdbstub_cmd.c +++ b/src/hci/commands/gdbstub_cmd.c @@ -107,9 +107,4 @@ static int gdbstub_exec ( int argc, char **argv ) { } /** GDB stub commands */ -struct command gdbstub_commands[] __command = { - { - .name = "gdbstub", - .exec = gdbstub_exec, - }, -}; +COMMAND ( gdbstub, gdbstub_exec ); diff --git a/src/hci/commands/ibmgmt_cmd.c b/src/hci/commands/ibmgmt_cmd.c index 1154d749e..be8b58cc2 100644 --- a/src/hci/commands/ibmgmt_cmd.c +++ b/src/hci/commands/ibmgmt_cmd.c @@ -71,9 +71,4 @@ static int ibstat_exec ( int argc, char **argv ) { } /** Infiniband commands */ -struct command ibmgmt_commands[] __command = { - { - .name = "ibstat", - .exec = ibstat_exec, - }, -}; +COMMAND ( ibstat, ibstat_exec ); diff --git a/src/hci/commands/ifmgmt_cmd.c b/src/hci/commands/ifmgmt_cmd.c index 591cb3da8..2906d1d45 100644 --- a/src/hci/commands/ifmgmt_cmd.c +++ b/src/hci/commands/ifmgmt_cmd.c @@ -303,25 +303,8 @@ static int iflinkwait_exec ( int argc, char **argv ) { } /** Interface management commands */ -struct command ifmgmt_commands[] __command = { - { - .name = "ifopen", - .exec = ifopen_exec, - }, - { - .name = "ifclose", - .exec = ifclose_exec, - }, - { - .name = "ifstat", - .exec = ifstat_exec, - }, - { - .name = "ifconf", - .exec = ifconf_exec, - }, - { - .name = "iflinkwait", - .exec = iflinkwait_exec, - }, -}; +COMMAND ( ifopen, ifopen_exec ); +COMMAND ( ifclose, ifclose_exec ); +COMMAND ( ifstat, ifstat_exec ); +COMMAND ( ifconf, ifconf_exec ); +COMMAND ( iflinkwait, iflinkwait_exec ); diff --git a/src/hci/commands/image_archive_cmd.c b/src/hci/commands/image_archive_cmd.c index a2212aecf..6b907830e 100644 --- a/src/hci/commands/image_archive_cmd.c +++ b/src/hci/commands/image_archive_cmd.c @@ -97,9 +97,4 @@ static int imgextract_exec ( int argc, char **argv ) { } /** Archive image commands */ -struct command image_archive_commands[] __command = { - { - .name = "imgextract", - .exec = imgextract_exec, - }, -}; +COMMAND ( imgextract, imgextract_exec ); diff --git a/src/hci/commands/image_cmd.c b/src/hci/commands/image_cmd.c index 4b42695c4..179256862 100644 --- a/src/hci/commands/image_cmd.c +++ b/src/hci/commands/image_cmd.c @@ -393,54 +393,22 @@ static int imgfree_exec ( int argc, char **argv ) { return imgmulti_exec ( argc, argv, unregister_image ); } -/** Image management commands */ -struct command image_commands[] __command = { - { - .name = "imgfetch", - .exec = imgfetch_exec, - }, - { - .name = "module", - .exec = imgfetch_exec, /* synonym for "imgfetch" */ - }, - { - .name = "initrd", - .exec = imgfetch_exec, /* synonym for "imgfetch" */ - }, - { - .name = "kernel", - .exec = imgselect_exec, /* synonym for "imgselect" */ - }, - { - .name = "chain", - .exec = imgexec_exec, /* synonym for "imgexec" */ - }, - { - .name = "imgselect", - .exec = imgselect_exec, - }, - { - .name = "imgload", - .exec = imgselect_exec, /* synonym for "imgselect" */ - }, - { - .name = "imgargs", - .exec = imgargs_exec, - }, - { - .name = "imgexec", - .exec = imgexec_exec, - }, - { - .name = "boot", /* synonym for "imgexec" */ - .exec = imgexec_exec, - }, - { - .name = "imgstat", - .exec = imgstat_exec, - }, - { - .name = "imgfree", - .exec = imgfree_exec, - }, -}; +/* "imgfetch" and synonyms */ +COMMAND ( imgfetch, imgfetch_exec ); +COMMAND ( module, imgfetch_exec ); +COMMAND ( initrd, imgfetch_exec ); + +/* "imgselect" and synonyms */ +COMMAND ( imgselect, imgselect_exec ); +COMMAND ( imgload, imgselect_exec ); +COMMAND ( kernel, imgselect_exec ); + +/* "imgexec" and synonyms */ +COMMAND ( imgexec, imgexec_exec ); +COMMAND ( chain, imgexec_exec ); +COMMAND ( boot, imgexec_exec ); + +/* Other image management commands */ +COMMAND ( imgargs, imgargs_exec ); +COMMAND ( imgstat, imgstat_exec ); +COMMAND ( imgfree, imgfree_exec ); diff --git a/src/hci/commands/image_crypt_cmd.c b/src/hci/commands/image_crypt_cmd.c index 4dfb5b131..54568cc28 100644 --- a/src/hci/commands/image_crypt_cmd.c +++ b/src/hci/commands/image_crypt_cmd.c @@ -117,9 +117,4 @@ static int imgdecrypt_exec ( int argc, char **argv ) { } /** Image encryption management commands */ -struct command image_crypt_commands[] __command = { - { - .name = "imgdecrypt", - .exec = imgdecrypt_exec, - }, -}; +COMMAND ( imgdecrypt, imgdecrypt_exec ); diff --git a/src/hci/commands/image_mem_cmd.c b/src/hci/commands/image_mem_cmd.c index fcd766627..60c0bf92a 100644 --- a/src/hci/commands/image_mem_cmd.c +++ b/src/hci/commands/image_mem_cmd.c @@ -89,9 +89,4 @@ static int imgmem_exec ( int argc, char **argv ) { } /** Read memory command */ -struct command imgmem_commands[] __command = { - { - .name = "imgmem", - .exec = imgmem_exec, - }, -}; +COMMAND ( imgmem, imgmem_exec ); diff --git a/src/hci/commands/image_trust_cmd.c b/src/hci/commands/image_trust_cmd.c index 9b9e3f859..314aa0998 100644 --- a/src/hci/commands/image_trust_cmd.c +++ b/src/hci/commands/image_trust_cmd.c @@ -163,13 +163,5 @@ static int imgverify_exec ( int argc, char **argv ) { } /** Image trust management commands */ -struct command image_trust_commands[] __command = { - { - .name = "imgtrust", - .exec = imgtrust_exec, - }, - { - .name = "imgverify", - .exec = imgverify_exec, - }, -}; +COMMAND ( imgtrust, imgtrust_exec ); +COMMAND ( imgverify, imgverify_exec ); diff --git a/src/hci/commands/ipstat_cmd.c b/src/hci/commands/ipstat_cmd.c index 763e4dfd6..488016e3a 100644 --- a/src/hci/commands/ipstat_cmd.c +++ b/src/hci/commands/ipstat_cmd.c @@ -66,9 +66,4 @@ static int ipstat_exec ( int argc, char **argv ) { } /** Routing table management commands */ -struct command ipstat_commands[] __command = { - { - .name = "ipstat", - .exec = ipstat_exec, - }, -}; +COMMAND ( ipstat, ipstat_exec ); diff --git a/src/hci/commands/iwmgmt_cmd.c b/src/hci/commands/iwmgmt_cmd.c index b61ee8c7b..b430353d9 100644 --- a/src/hci/commands/iwmgmt_cmd.c +++ b/src/hci/commands/iwmgmt_cmd.c @@ -113,13 +113,5 @@ static int iwlist_exec ( int argc, char **argv ) { } /** Wireless interface management commands */ -struct command iwmgmt_commands[] __command = { - { - .name = "iwstat", - .exec = iwstat_exec, - }, - { - .name = "iwlist", - .exec = iwlist_exec, - }, -}; +COMMAND ( iwstat, iwstat_exec ); +COMMAND ( iwlist, iwlist_exec ); diff --git a/src/hci/commands/login_cmd.c b/src/hci/commands/login_cmd.c index c9e196437..005d40342 100644 --- a/src/hci/commands/login_cmd.c +++ b/src/hci/commands/login_cmd.c @@ -71,7 +71,4 @@ static int login_exec ( int argc, char **argv ) { } /** Login commands */ -struct command login_command __command = { - .name = "login", - .exec = login_exec, -}; +COMMAND ( login, login_exec ); diff --git a/src/hci/commands/lotest_cmd.c b/src/hci/commands/lotest_cmd.c index 393b3c36e..ee3b0d3b5 100644 --- a/src/hci/commands/lotest_cmd.c +++ b/src/hci/commands/lotest_cmd.c @@ -100,7 +100,4 @@ static int lotest_exec ( int argc, char **argv ) { } /** Loopback testing commands */ -struct command lotest_command __command = { - .name = "lotest", - .exec = lotest_exec, -}; +COMMAND ( lotest, lotest_exec ); diff --git a/src/hci/commands/neighbour_cmd.c b/src/hci/commands/neighbour_cmd.c index 816e87357..520d5aa06 100644 --- a/src/hci/commands/neighbour_cmd.c +++ b/src/hci/commands/neighbour_cmd.c @@ -65,9 +65,4 @@ static int nstat_exec ( int argc, char **argv ) { } /** Neighbour management commands */ -struct command neighbour_commands[] __command = { - { - .name = "nstat", - .exec = nstat_exec, - }, -}; +COMMAND ( nstat, nstat_exec ); diff --git a/src/hci/commands/nslookup_cmd.c b/src/hci/commands/nslookup_cmd.c index 265afdc3d..dc9d61704 100644 --- a/src/hci/commands/nslookup_cmd.c +++ b/src/hci/commands/nslookup_cmd.c @@ -73,7 +73,4 @@ static int nslookup_exec ( int argc, char **argv ) { } /** The "nslookup" command */ -struct command nslookup_command __command = { - .name = "nslookup", - .exec = nslookup_exec, -}; +COMMAND ( nslookup, nslookup_exec ); diff --git a/src/hci/commands/ntp_cmd.c b/src/hci/commands/ntp_cmd.c index 8f741a512..fed126f4c 100644 --- a/src/hci/commands/ntp_cmd.c +++ b/src/hci/commands/ntp_cmd.c @@ -75,7 +75,4 @@ static int ntp_exec ( int argc, char **argv ) { } /** NTP command */ -struct command ntp_command __command = { - .name = "ntp", - .exec = ntp_exec, -}; +COMMAND ( ntp, ntp_exec ); diff --git a/src/hci/commands/nvo_cmd.c b/src/hci/commands/nvo_cmd.c index 6ad7e7428..69ab97dca 100644 --- a/src/hci/commands/nvo_cmd.c +++ b/src/hci/commands/nvo_cmd.c @@ -356,25 +356,8 @@ static int inc_exec ( int argc, char **argv ) { } /** Non-volatile option commands */ -struct command nvo_commands[] __command = { - { - .name = "show", - .exec = show_exec, - }, - { - .name = "set", - .exec = set_exec, - }, - { - .name = "clear", - .exec = clear_exec, - }, - { - .name = "read", - .exec = read_exec, - }, - { - .name = "inc", - .exec = inc_exec, - }, -}; +COMMAND ( show, show_exec ); +COMMAND ( set, set_exec ); +COMMAND ( clear, clear_exec ); +COMMAND ( read, read_exec ); +COMMAND ( inc, inc_exec ); diff --git a/src/hci/commands/param_cmd.c b/src/hci/commands/param_cmd.c index dad99f840..0924df597 100644 --- a/src/hci/commands/param_cmd.c +++ b/src/hci/commands/param_cmd.c @@ -163,13 +163,5 @@ static int param_exec ( int argc, char **argv ) { } /** Request parameter commands */ -struct command param_commands[] __command = { - { - .name = "params", - .exec = params_exec, - }, - { - .name = "param", - .exec = param_exec, - }, -}; +COMMAND ( params, params_exec ); +COMMAND ( param, param_exec ); diff --git a/src/hci/commands/pci_cmd.c b/src/hci/commands/pci_cmd.c index fa1fa5ece..0b54902fb 100644 --- a/src/hci/commands/pci_cmd.c +++ b/src/hci/commands/pci_cmd.c @@ -115,9 +115,4 @@ static int pciscan_exec ( int argc, char **argv ) { } /** PCI commands */ -struct command pci_commands[] __command = { - { - .name = "pciscan", - .exec = pciscan_exec, - }, -}; +COMMAND ( pciscan, pciscan_exec ); diff --git a/src/hci/commands/ping_cmd.c b/src/hci/commands/ping_cmd.c index ab271e75a..4e86ae1c0 100644 --- a/src/hci/commands/ping_cmd.c +++ b/src/hci/commands/ping_cmd.c @@ -107,7 +107,4 @@ static int ping_exec ( int argc, char **argv ) { } /** Ping command */ -struct command ping_command __command = { - .name = "ping", - .exec = ping_exec, -}; +COMMAND ( ping, ping_exec ); diff --git a/src/hci/commands/poweroff_cmd.c b/src/hci/commands/poweroff_cmd.c index afdf12dde..2c6f1369a 100644 --- a/src/hci/commands/poweroff_cmd.c +++ b/src/hci/commands/poweroff_cmd.c @@ -70,7 +70,4 @@ static int poweroff_exec ( int argc, char **argv ) { } /** "poweroff" command */ -struct command poweroff_command __command = { - .name = "poweroff", - .exec = poweroff_exec, -}; +COMMAND ( poweroff, poweroff_exec ); diff --git a/src/hci/commands/profstat_cmd.c b/src/hci/commands/profstat_cmd.c index dc6f649e3..da01068b2 100644 --- a/src/hci/commands/profstat_cmd.c +++ b/src/hci/commands/profstat_cmd.c @@ -66,9 +66,4 @@ static int profstat_exec ( int argc, char **argv ) { } /** Profiling commands */ -struct command profstat_commands[] __command = { - { - .name = "profstat", - .exec = profstat_exec, - }, -}; +COMMAND ( profstat, profstat_exec ); diff --git a/src/hci/commands/reboot_cmd.c b/src/hci/commands/reboot_cmd.c index 5d4e151b8..c5b71c045 100644 --- a/src/hci/commands/reboot_cmd.c +++ b/src/hci/commands/reboot_cmd.c @@ -81,7 +81,4 @@ static int reboot_exec ( int argc, char **argv ) { } /** "reboot" command */ -struct command reboot_command __command = { - .name = "reboot", - .exec = reboot_exec, -}; +COMMAND ( reboot, reboot_exec ); diff --git a/src/hci/commands/route_cmd.c b/src/hci/commands/route_cmd.c index 8aa535363..a33754399 100644 --- a/src/hci/commands/route_cmd.c +++ b/src/hci/commands/route_cmd.c @@ -66,9 +66,4 @@ static int route_exec ( int argc, char **argv ) { } /** Routing table management commands */ -struct command route_commands[] __command = { - { - .name = "route", - .exec = route_exec, - }, -}; +COMMAND ( route, route_exec ); diff --git a/src/hci/commands/sanboot_cmd.c b/src/hci/commands/sanboot_cmd.c index 6ab9e8844..122bee527 100644 --- a/src/hci/commands/sanboot_cmd.c +++ b/src/hci/commands/sanboot_cmd.c @@ -204,17 +204,6 @@ static int sanunhook_exec ( int argc, char **argv ) { } /** SAN commands */ -struct command sanboot_commands[] __command = { - { - .name = "sanhook", - .exec = sanhook_exec, - }, - { - .name = "sanboot", - .exec = sanboot_exec, - }, - { - .name = "sanunhook", - .exec = sanunhook_exec, - }, -}; +COMMAND ( sanhook, sanhook_exec ); +COMMAND ( sanboot, sanboot_exec ); +COMMAND ( sanunhook, sanunhook_exec ); diff --git a/src/hci/commands/shim_cmd.c b/src/hci/commands/shim_cmd.c index 11956290a..a53bb3fde 100644 --- a/src/hci/commands/shim_cmd.c +++ b/src/hci/commands/shim_cmd.c @@ -123,9 +123,4 @@ static int shim_exec ( int argc, char **argv ) { } /** Shim commands */ -struct command shim_commands[] __command = { - { - .name = "shim", - .exec = shim_exec, - }, -}; +COMMAND ( shim, shim_exec ); diff --git a/src/hci/commands/sync_cmd.c b/src/hci/commands/sync_cmd.c index 54799d422..9d6e6a284 100644 --- a/src/hci/commands/sync_cmd.c +++ b/src/hci/commands/sync_cmd.c @@ -77,7 +77,4 @@ static int sync_exec ( int argc, char **argv ) { } /** Sync commands */ -struct command sync_command __command = { - .name = "sync", - .exec = sync_exec, -}; +COMMAND ( sync, sync_exec ); diff --git a/src/hci/commands/time_cmd.c b/src/hci/commands/time_cmd.c index 08148bf38..aba080792 100644 --- a/src/hci/commands/time_cmd.c +++ b/src/hci/commands/time_cmd.c @@ -77,7 +77,4 @@ static int time_exec ( int argc, char **argv ) { } /** "time" command */ -struct command time_command __command = { - .name = "time", - .exec = time_exec, -}; +COMMAND ( time, time_exec ); diff --git a/src/hci/commands/usb_cmd.c b/src/hci/commands/usb_cmd.c index 4ee2f2ddb..2e3a82371 100644 --- a/src/hci/commands/usb_cmd.c +++ b/src/hci/commands/usb_cmd.c @@ -115,9 +115,4 @@ static int usbscan_exec ( int argc, char **argv ) { } /** USB commands */ -struct command usb_commands[] __command = { - { - .name = "usbscan", - .exec = usbscan_exec, - }, -}; +COMMAND ( usbscan, usbscan_exec ); diff --git a/src/hci/commands/vlan_cmd.c b/src/hci/commands/vlan_cmd.c index 8a2f0c749..636e5927f 100644 --- a/src/hci/commands/vlan_cmd.c +++ b/src/hci/commands/vlan_cmd.c @@ -131,13 +131,5 @@ static int vdestroy_exec ( int argc, char **argv ) { } /** VLAN commands */ -struct command vlan_commands[] __command = { - { - .name = "vcreate", - .exec = vcreate_exec, - }, - { - .name = "vdestroy", - .exec = vdestroy_exec, - }, -}; +COMMAND ( vcreate, vcreate_exec ); +COMMAND ( vdestroy, vdestroy_exec ); diff --git a/src/hci/shell.c b/src/hci/shell.c index 8ecf73a6f..7e2ecaab6 100644 --- a/src/hci/shell.c +++ b/src/hci/shell.c @@ -72,10 +72,7 @@ static int help_exec ( int argc __unused, char **argv __unused ) { } /** "help" command */ -struct command help_command __command = { - .name = "help", - .exec = help_exec, -}; +COMMAND ( help, help_exec ); /** * Start command shell @@ -137,7 +134,4 @@ static int shell_exec ( int argc, char **argv ) { } /** "shell" command */ -struct command shell_command __command = { - .name = "shell", - .exec = shell_exec, -}; +COMMAND ( shell, shell_exec ); diff --git a/src/image/script.c b/src/image/script.c index 01e38cd6f..257e59a09 100644 --- a/src/image/script.c +++ b/src/image/script.c @@ -352,10 +352,7 @@ static int goto_exec ( int argc, char **argv ) { } /** "goto" command */ -struct command goto_command __command = { - .name = "goto", - .exec = goto_exec, -}; +COMMAND ( goto, goto_exec ); /** "prompt" options */ struct prompt_options { @@ -418,7 +415,4 @@ static int prompt_exec ( int argc, char **argv ) { } /** "prompt" command */ -struct command prompt_command __command = { - .name = "prompt", - .exec = prompt_exec, -}; +COMMAND ( prompt, prompt_exec ); diff --git a/src/include/ipxe/command.h b/src/include/ipxe/command.h index a208e7d8f..331536313 100644 --- a/src/include/ipxe/command.h +++ b/src/include/ipxe/command.h @@ -21,7 +21,12 @@ struct command { #define COMMANDS __table ( struct command, "commands" ) -#define __command __table_entry ( COMMANDS, 01 ) +#define __command( name ) __table_entry ( COMMANDS, _C2 ( 01., name ) ) + +#define COMMAND( name, exec ) \ + struct command name ## _command __command ( name ) = { \ + #name, exec \ + } extern char * concat_args ( char **args );