/* arg.c - argument parser */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2004,2005,2007,2008 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
/* Built-in parser for default options. */
{
{"help", 0, 0,
{"usage", 0, 0,
{0, 0, 0, 0, 0, 0}
};
static struct grub_arg_option *
{
{
{
return (struct grub_arg_option *) opt;
opt++;
}
return 0;
}
if (options)
if (! found)
{
switch (c)
{
case 'h':
break;
case 'u':
break;
default:
break;
}
}
return found;
}
static struct grub_arg_option *
{
{
{
return (struct grub_arg_option *) opt;
opt++;
}
return 0;
}
if (options)
if (! found)
return found;
}
static void
{
}
void
{
int h_is_used = 0;
int u_is_used = 0;
{
{
grub_printf ("-h, ");
grub_printf ("-u, ");
else
grub_printf (" ");
{
{
}
}
if (spacing < 0)
spacing = 3;
while (spacing--)
grub_xputs (" ");
{
case 'h':
h_is_used = 1;
break;
case 'u':
u_is_used = 1;
break;
default:
break;
}
}
}
show_usage (cmd);
#if 0
#endif
}
static int
{
if (opt == help_options)
{
return -1;
}
{
show_usage (cmd);
return -1;
}
{
{
}
else
{
}
}
return 0;
}
int
{
int curarg;
int arglen;
char **argl = 0;
int num = 0;
auto grub_err_t add_arg (char *s);
{
char **p = argl;
if (! argl)
{
grub_free (p);
return grub_errno;
}
return 0;
}
{
char *option = 0;
/* No option is used. */
{
goto fail;
continue;
}
/* One or more short options. */
{
char *curshort;
{
break;
if (*curshort)
{
goto fail;
continue;
}
}
while (1)
{
if (! opt)
{
"unknown argument `-%c'", *curshort);
goto fail;
}
curshort++;
/* Parse all arguments here except the last one because
it can have an argument value. */
if (*curshort)
{
goto fail;
}
else
{
{
{
}
}
break;
}
}
}
else /* The argument starts with "--". */
{
/* If the argument "--" is used just pass the other
arguments. */
{
goto fail;
break;
}
if (option)
{
option++;
}
else
{
goto fail;
continue;
}
if (! opt)
{
goto fail;
}
}
{
if (! option)
{
goto fail;
}
{
case ARG_TYPE_NONE:
/* This will never happen. */
break;
case ARG_TYPE_STRING:
/* No need to do anything. */
break;
case ARG_TYPE_INT:
{
char *tail;
{
"the argument `%s' requires an integer",
arg);
goto fail;
}
break;
}
case ARG_TYPE_DEVICE:
case ARG_TYPE_DIR:
case ARG_TYPE_FILE:
case ARG_TYPE_PATHNAME:
/* XXX: Not implemented. */
break;
}
goto fail;
}
else
{
if (option)
{
"a value was assigned to the argument `%s' while it "
"doesn't require an argument", arg);
goto fail;
}
goto fail;
}
}
return 1;
fail:
return 0;
}
struct grub_arg_list*
{
int i;
char **args;
unsigned argcnt;
if (! options)
return 0;
argcnt = 0;
{
}
if (! list)
return 0;
{
{
}
}
return list;
}