From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Gps4D-0002D8-AC for mharc-grub-devel@gnu.org; Thu, 30 Nov 2006 14:59:33 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Gps4B-0002As-Cy for grub-devel@gnu.org; Thu, 30 Nov 2006 14:59:31 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Gps4A-00029n-HA for grub-devel@gnu.org; Thu, 30 Nov 2006 14:59:30 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Gps4A-00029Z-DC for grub-devel@gnu.org; Thu, 30 Nov 2006 14:59:30 -0500 Received: from [207.69.195.61] (helo=pop-gadwall.atl.sa.earthlink.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Gps4A-0007xO-Fe for grub-devel@gnu.org; Thu, 30 Nov 2006 14:59:30 -0500 Received: from user-0vvdf2d.cable.mindspring.com ([63.246.188.77] helo=[192.168.0.2]) by pop-gadwall.atl.sa.earthlink.net with esmtp (Exim 3.36 #1) id 1Gps47-0007bW-00 for grub-devel@gnu.org; Thu, 30 Nov 2006 14:59:27 -0500 From: Hollis Blanchard To: The development of GRUB 2 In-Reply-To: <87k61c3e94.fsf@xs4all.nl> References: <1164913211.4067.46.camel@diesel> <87k61c3e94.fsf@xs4all.nl> Content-Type: text/plain Date: Thu, 30 Nov 2006 13:59:18 -0600 Message-Id: <1164916758.4067.63.camel@diesel> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 (2.6.3-1.fc5.5) Content-Transfer-Encoding: 7bit Subject: Re: user-defined hooks 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: Thu, 30 Nov 2006 19:59:32 -0000 On Thu, 2006-11-30 at 20:50 +0100, Marco Gerards wrote: > Actually, what I would prefer is something hooks. It would be nice if > the C code in GRUB and perhaps also scripts can be hooked anywhere. > We have to be very careful about this, so perhaps limit the sets of > commands that can be used this way. But I think it will make GRUB > more flexible while it is not too much effort. I like this idea. > I am thinking of the following functions: > > One to install a hook: > grub_err_t grub_hook_register (const char *name, (*hook) (...)); > > To trigger the hook (for example, when the user types something, > selects another menu entry, etc. > void grub_hook_call (const char *name, ...); > > How to pass arguments to functions and to scripts is something that we > have to think about. For example, scripting functions have to get > strings, while in other cases we just want to deal with regular > function calls. Perhaps a printf-like mechanism can help us with > this. I do not think it's important that we be able to hook C functions directly. In other words, the argument passed to --function (below) should be a script command (or script function), and not a C function name. > In that case your problem can be solved by using: > > function handlemenu { > beep depending on menuentry selected, the index is passed to this function > } > > hook --install --hook=select-menu-entry --function=handlemenu Defining the set of useful hooks, the arguments passed to each, and documenting them will be critical. Also, just like with commands, once we implement a hook we can't remove or change it without breaking config files. -Hollis