/[hurd]/hurd/boot/boot_script.c
ViewVC logotype

Diff of /hurd/boot/boot_script.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by roland, Wed May 29 02:42:34 2002 UTC revision 1.15 by roland, Sat Jan 4 21:30:10 2003 UTC
# Line 175  add_list (void *ptr, void ***ptr_list, i Line 175  add_list (void *ptr, void ***ptr_list, i
175  /* Create an argument with TEXT, value type TYPE, and value VAL.  /* Create an argument with TEXT, value type TYPE, and value VAL.
176     Add the argument to the argument list of CMD.  */     Add the argument to the argument list of CMD.  */
177  static struct arg *  static struct arg *
178  add_arg (struct cmd *cmd, char *text, int type, int val)  add_arg (struct cmd *cmd, const char *text, int textlen, int type, int val)
179  {  {
180    struct arg *arg;    struct arg *arg;
181    
182    arg = boot_script_malloc (sizeof (struct arg));    arg = boot_script_malloc (sizeof (struct arg) + textlen);
183    if (arg)    if (arg)
184      {      {
185        arg->text = text;        arg->text = text == 0 ? 0 : memcpy (arg + 1, text, textlen);
186        arg->type = type;        arg->type = type;
187        arg->val = val;        arg->val = val;
188        if (add_list (arg, (void ***) &cmd->args,        if (add_list (arg, (void ***) &cmd->args,
# Line 255  boot_script_parse_line (void *hook, char Line 255  boot_script_parse_line (void *hook, char
255    if (p == q)    if (p == q)
256        return 0;        return 0;
257    
258    *q = '\0';    *q++ = '\0';
259    
260    /* Allocate a command structure.  */    /* Allocate a command structure.  */
261    cmd = boot_script_malloc (sizeof (struct cmd));    cmd = boot_script_malloc (sizeof (struct cmd) + (q - p));
262    if (! cmd)    if (! cmd)
263      return BOOT_SCRIPT_NOMEM;      return BOOT_SCRIPT_NOMEM;
264    memset (cmd, 0, sizeof (struct cmd));    memset (cmd, 0, sizeof (struct cmd));
265    cmd->hook = hook;    cmd->hook = hook;
266    cmd->path = p;    cmd->path = memcpy (cmd + 1, p, q - p);
267    p = q + 1;    p = q;
268    
269    for (arg = 0;;)    for (arg = 0;;)
270      {      {
# Line 408  boot_script_parse_line (void *hook, char Line 408  boot_script_parse_line (void *hook, char
408                       associated with an argument.  */                       associated with an argument.  */
409                    if (! arg && end_char == '}')                    if (! arg && end_char == '}')
410                      {                      {
411                        if (! add_arg (cmd, 0, type, val))                        if (! add_arg (cmd, 0, 0, type, val))
412                          {                          {
413                            error = BOOT_SCRIPT_NOMEM;                            error = BOOT_SCRIPT_NOMEM;
414                            goto bad;                            goto bad;
# Line 437  boot_script_parse_line (void *hook, char Line 437  boot_script_parse_line (void *hook, char
437            *q = '\0';            *q = '\0';
438    
439            /* Add argument to list.  */            /* Add argument to list.  */
440            arg = add_arg (cmd, p, VAL_NONE, 0);            arg = add_arg (cmd, p, q + 1 - p, VAL_NONE, 0);
441            if (! arg)            if (! arg)
442              {              {
443                error = BOOT_SCRIPT_NOMEM;                error = BOOT_SCRIPT_NOMEM;

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26