From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MBsfF-0000Cw-HR for mharc-grub-devel@gnu.org; Wed, 03 Jun 2009 11:46:05 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MBsfD-0000CU-68 for grub-devel@gnu.org; Wed, 03 Jun 2009 11:46:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MBsf8-0000BD-H2 for grub-devel@gnu.org; Wed, 03 Jun 2009 11:46:02 -0400 Received: from [199.232.76.173] (port=44828 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MBsf8-0000B8-BQ for grub-devel@gnu.org; Wed, 03 Jun 2009 11:45:58 -0400 Received: from moutng.kundenserver.de ([212.227.17.10]:59738) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MBsf7-0006nd-DB for grub-devel@gnu.org; Wed, 03 Jun 2009 11:45:57 -0400 Received: from [85.180.52.120] (e180052120.adsl.alicedsl.de [85.180.52.120]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0MKt2u-1MBsf51UPl-0006EW; Wed, 03 Jun 2009 17:45:55 +0200 From: Felix Zielcke To: The development of GRUB 2 In-Reply-To: References: <1243426603.3425.2.camel@fz.local> <1243865933.3417.2.camel@fz.local> Content-Type: multipart/mixed; boundary="=-FylZ2/JoReoEtdpASVcM" Date: Wed, 03 Jun 2009 17:45:54 +0200 Message-Id: <1244043954.3407.4.camel@fz.local> Mime-Version: 1.0 X-Mailer: Evolution 2.26.2 X-Provags-ID: V01U2FsdGVkX18A4oKB/ZcEOSC0zIm67p9bHCaEOndlpRuLMp8 /ifGCg9uZ8idc0hic5znGwWABx436qQNmx8+tlK+4GYkdt6IY9 ozc2aQZ4+UAr3t6gzDsDyBLVIbrDACT X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [PATCH] add true and false commands X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2009 15:46:03 -0000 --=-FylZ2/JoReoEtdpASVcM Content-Type: text/plain Content-Transfer-Encoding: 7bit Am Montag, den 01.06.2009, 16:24 +0200 schrieb Vladimir 'phcoder' Serbinenko: > However convention for > creating false is: > return grub_error (GRUB_ERR_TEST_FAILURE, "false"); > and not > return 1; Ok changed it. If everyone is fine with placing this in normal/main.c, I commit it. -- Felix Zielcke --=-FylZ2/JoReoEtdpASVcM Content-Disposition: attachment; filename="true_false.patch.3" Content-Type: text/plain; name="true_false.patch.3"; charset="UTF-8" Content-Transfer-Encoding: 7bit 2009-06-03 Felix Zielcke * normal/main.c (grub_cmd_true): New function. (grub_cmd_false): Likewise. (cmd_true): New static variable. (cmd_false): Likewise. (GRUB_MOD_INIT(normal)): Register commands true and false. (GRUB_MOD_FINI(normal)): Unregister commands true and false. diff --git a/normal/main.c b/normal/main.c index 9c5a827..ac657d7 100644 --- a/normal/main.c +++ b/normal/main.c @@ -536,6 +536,26 @@ grub_env_write_pager (struct grub_env_var *var __attribute__ ((unused)), return grub_strdup (val); } +/* true */ +static grub_err_t +grub_cmd_true (struct grub_command *cmd __attribute__ ((unused)), + int argc __attribute__ ((unused)), + char *argv[] __attribute__ ((unused))) +{ + return 0; +} + +/* false */ +static grub_err_t +grub_cmd_false (struct grub_command *cmd __attribute__ ((unused)), + int argc __attribute__ ((unused)), + char *argv[] __attribute__ ((unused))) +{ + return grub_error (GRUB_ERR_TEST_FAILURE, "false"); +} + +static grub_command_t cmd_true, cmd_false; + GRUB_MOD_INIT(normal) { /* Normal mode shouldn't be unloaded. */ @@ -561,6 +581,13 @@ GRUB_MOD_INIT(normal) /* Preserve hooks after context changes. */ grub_env_export ("color_normal"); grub_env_export ("color_highlight"); + + cmd_true = + grub_register_command ("true", grub_cmd_true, + 0, "do nothing, successfully"); + cmd_false = + grub_register_command ("false", grub_cmd_true, + 0, "do nothing, unsuccessfully"); } GRUB_MOD_FINI(normal) @@ -570,4 +597,6 @@ GRUB_MOD_FINI(normal) grub_register_variable_hook ("pager", 0, 0); grub_fs_autoload_hook = 0; free_handler_list (); + grub_unregister_command (cmd_true); + grub_unregister_command (cmd_false); } --=-FylZ2/JoReoEtdpASVcM--