/* parser.c - the part of the parser that can return partial tokens */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2005,2007,2009 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/>.
*/
/* All the possible state transitions on the command line. If a
transition can not be found, it is assumed that there is no
transition and keep_value is assumed to be 1. */
{0, 0, 0, 0}
};
/* Determines the state following STATE, determined by C. */
{
/* Look for a good translation. */
{
continue;
/* An exact match was found, use it. */
if (transition->input == c)
break;
&& !grub_isdigit (c) && c != '_')
break;
/* A less perfect match was found, use this one if no exact
match can be found. */
if (transition->input == 0)
break;
}
if (!transition->from_state)
if (transition->keep_value)
*result = c;
else
*result = 0;
return transition->to_state;
}
{
/* XXX: Fixed size buffer, perhaps this buffer should be dynamically
allocated. */
char *args;
int i;
auto int check_varstate (grub_parser_state_t s);
{
return (s == GRUB_PARSER_STATE_VARNAME
|| s == GRUB_PARSER_STATE_VARNAME2
|| s == GRUB_PARSER_STATE_QVARNAME
|| s == GRUB_PARSER_STATE_QVARNAME2);
}
{
const char *val;
/* Check if a variable was being read in and the end of the name
was reached. */
return;
*(vp++) = '\0';
if (!val)
return;
/* Insert the contents of the variable in the buffer. */
}
*argc = 0;
do
{
{
if (getline)
else
break;
}
if (!rd)
break;
{
char use;
/* If a variable was being processed and this character does
not describe the variable anymore, write the variable to
the buffer. */
if (check_varstate (newstate))
{
if (use)
}
else
{
if (newstate == GRUB_PARSER_STATE_TEXT
{
/* Don't add more than one argument if multiple
spaces are used. */
{
*(bp++) = '\0';
(*argc)++;
}
}
else if (use)
}
}
}
/* A special case for when the last character was part of a
variable. */
{
*(bp++) = '\0';
(*argc)++;
}
/* Reserve memory for the return values. */
if (!args)
return grub_errno;
if (!*argv)
{
return grub_errno;
}
/* The arguments are separated with 0's, setup argv so it points to
the right values. */
for (i = 0; i < *argc; i++)
{
while (*bp)
bp++;
bp++;
}
return 0;
}
{
{
char *p;
if (!source)
{
*line = 0;
return 0;
}
if (p)
else
source = p ? p + 1 : 0;
return 0;
}
while (source)
{
char *line;
}
return grub_errno;
}