/* argv.c - methods for constructing argument vector */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010 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/>.
*/
#include <grub/script_sh.h>
/* Return nearest power of two that is >= v. */
static unsigned
round_up_exp (unsigned v)
{
COMPILE_TIME_ASSERT (sizeof (v) == 4);
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v++;
v += (v == 0);
return v;
}
void
{
unsigned i;
{
}
}
/* Make argv from argc, args pair. */
int
{
int i;
struct grub_script_argv r = { 0, 0, 0 };
for (i = 0; i < argc; i++)
if (grub_script_argv_next (&r)
{
grub_script_argv_free (&r);
return 1;
}
*argv = r;
return 0;
}
/* Prepare for next argc. */
int
{
return 0;
if (! p)
return 1;
return 0;
}
/* Append `s' to the last argument. */
int
{
grub_size_t a;
if (! s)
return 0;
a = p ? grub_strlen (p) : 0;
if (! p)
return 1;
grub_memcpy (p + a, s, slen);
p[a+slen] = 0;
return 0;
}
/* Split `s' and append words as multiple arguments. */
int
{
const char *p;
int errors = 0;
if (! s)
return 0;
while (! errors && *s)
{
p = s;
while (*s && ! grub_isspace (*s))
s++;
while (*s && grub_isspace (*s))
s++;
if (*s)
}
return errors;
}