I like this :)
If/when HPA commits this, you may want to document it on the Wiki here :
http://syslinux.zytor.com/wiki/index.php/Category:Comboot
On Tue, Oct 21, 2008 at 9:37 PM, Gene Cumm <gene.cumm at gmail.com> wrote:
> From: Gene Cumm <gene.cumm at gmail.com>
>
> alias.c: A simple COM32 module that allows the creation of an alias
> within the config for SYSLINUX, etc.
>
> Signed-off-by: Gene Cumm <gene.cumm at gmail.com>
>
> ---
>
> If, for example, you had two labels that only differed by the length
> of the label (a short name) or additional APPENDd parameters, this
> would reduce the amount of copies of the same configuration.
>
> LABEL boot1
> KERNEL kernel
> APPEND initrd=initrd.img
>
> LABEL boot2
> KERNEL kernel
> APPEND initrd=initrd.img extraParamForBoot2
>
> could be shortened to
>
> LABEL boot1
> KERNEL kernel
> APPEND initrd=initrd.img
>
> LABEL boot2
> KERNEL alias.c32
> APPEND boot1 extraParamForBoot2
>
> I created this as I've got several instances of both short names and
> extra APPENDd parameters in a config file I use. The only thing that
> would be better (if this benefits others) would be an ALIAS option in
> the config file.
>
> com32/modules/alias.c:
>
> /* -----------------------------------------------------------------------
> *
> *
> * Copyright 2008 Gene Cumm - All Rights Reserved
> *
> * This program is free software; you can redistribute it and/or modify
> * it under the terms of the GNU General Public License as published by
> * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
> * Boston MA 02111-1307, USA; either version 2 of the License, or
> * (at your option) any later version; incorporated herein by reference.
> *
> * -----------------------------------------------------------------------
> */
>
> /*
> * alias.c
> *
> * Alias COM32 application; Call as a KERNEL with a boot line command as
> the
> * APPEND line.
> */
>
> /*
> * History
> * b002 Alter the concatenation of the command line arguments to use memcpy
> * b001 Initial version
> */
>
> #include <stdio.h>
> #include <stdlib.h>
> // #include <stdbool.h>
> #include <string.h>
>
> #ifdef __COM32__ /* Allow targetting Linux, etc to test */
> #include <syslinux/boot.h> /* syslinux_run_command() */
> #endif /* __COM32__ */
>
> #define ALIAS_CMD_SZ 128
>
> // #define DO_DEBUG 1
>
> #define APP_LONGNAME "Alias COM32"
> #define APP_NAME "alias"
> #define APP_YEAR "2008"
> #define APP_AUTHOR "Gene Cumm"
> #define APP_VER "beta-b002"
>
> int main(int argc, char *argv[]){
> char cmdstr[ALIAS_CMD_SZ]; // Command string to execute
> int curpos; // Current position in cmdstr; Use memcpy rather
> than strcat
> int arglen; // length of current argument string
> int i;
>
> // Initialization
> curpos = 0;
> cmdstr[0] = 0;
> for(i=1; i<argc; i++){
> arglen = strlen(argv[i]);
> memcpy(cmdstr + curpos, argv[i], arglen);
> curpos += arglen;
> cmdstr[curpos] = ' ';
> curpos += 1;
> cmdstr[curpos] = 0;
> }
> curpos -= 1;
> cmdstr[curpos] = 0;
> #ifdef DO_DEBUG
> printf("Parsed arg list\n");
> #endif
> printf("--alias: '%s'\n", cmdstr);
> #ifdef __COM32__
> syslinux_run_command(cmdstr);
> #endif /* __COM32__ */
>
> return 0;
> }
>
> _______________________________________________
> Syslinux mailing list
> Submissions to Syslinux at zytor.com
> Unsubscribe or set options at:
> http://www.zytor.com/mailman/listinfo/syslinux
> Please do not send private replies to mailing list traffic.
>
>
--
Kevin Landreth, RHCE