From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1EtvIz-0001Fv-BC for mharc-grub-devel@gnu.org; Tue, 03 Jan 2006 18:11:01 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EtvIx-0001Fp-DV for grub-devel@gnu.org; Tue, 03 Jan 2006 18:10:59 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EtvIw-0001FS-Gn for grub-devel@gnu.org; Tue, 03 Jan 2006 18:10:58 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EtvIw-0001FO-Dy for grub-devel@gnu.org; Tue, 03 Jan 2006 18:10:58 -0500 Received: from [194.109.24.32] (helo=smtp-vbr12.xs4all.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EtvK9-0002ph-Nk for grub-devel@gnu.org; Tue, 03 Jan 2006 18:12:14 -0500 Received: from localhost.localdomain (mgerards.xs4all.nl [82.92.27.129]) by smtp-vbr12.xs4all.nl (8.13.3/8.13.3) with ESMTP id k03N9922035279 for ; Wed, 4 Jan 2006 00:09:09 +0100 (CET) (envelope-from mgerards@xs4all.nl) Mail-Copies-To: mgerards@xs4all.nl To: The development of GRUB 2 References: <43BAF893.5080205@omniflux.com> From: Marco Gerards Date: Wed, 04 Jan 2006 00:09:12 +0100 In-Reply-To: <43BAF893.5080205@omniflux.com> (omniflux+lists@omniflux.com's message of "Tue, 03 Jan 2006 15:20:03 -0700") Message-ID: <87acecgb8n.fsf@xs4all.nl> User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by XS4ALL Virus Scanner Subject: Re: [rfc] User definable terminfo support 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: Tue, 03 Jan 2006 23:10:59 -0000 Omniflux writes: Hi, > This code is incomplete, but I want to get some feedback from you, > Marco, to ensure I am going down the correct path. Hopefully my understanding of the code is correct so the comments are sane :) > -/* Free *PTR and set *PTR to NULL, to prevent double-free. */ > +/* Set terminfo definition. */ > static void > -grub_terminfo_free (char **ptr) > +set_definition (const char *name, const char *definition) > +{ > + unset_definition (); > + > + /* terminfo definition variable set to "". */ > + if (grub_strcmp (definition, "") == 0 ) > + return; > + > + /* Parse new definition and save as terminal_definition. */ > + /* FIXME: Write a parser. :) */ > + terminfo_definition->name = grub_strdup (name); > +} > + > +/* Write hook for the terminfo environment variable. */ > +static char * > +set_definition_hook (struct grub_env_var *var, const char *val) > { > - grub_free (*ptr); > - *ptr = 0; > + set_definition (var->name, val); > + return grub_strdup (val); > } Why do you have a hook for variables? For example, when I do: set vt100=... It's ok that is does not take effect until you change TERM, IMO. So what happens is: 1) VT100 is set 2) TERM is set 2a) The hook is executed 2b) VT100 is read by the hook. 2c) The contents of VT100 is read and parsed. 2d) From this point of the VT100 stuff can be used and the hook returns. Does this make sense and does it fit well in the design of the terminfo code? > +/* Write hook for the environment variable "TERM". */ > +static char * > +select_definition_hook (struct grub_env_var *var __attribute__ ((unused)), > + const char *val) > +{ > + select_definition (val); > + return grub_strdup (val); > +} Perhaps you can even return 0 when the definition was not valid. In that case TERM is set to 0, IIRC? Thanks, Marco