/* test.c -- The test command.. */
/*
* 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/>.
*/
GRUB_MOD_LICENSE ("GPLv3+");
/* A simple implementation for signed numbers. */
static int
{
if (arg[0] == '-')
}
/* Parse a test expression starting from *argn. */
static int
{
int file_exists;
auto void update_val (int val);
auto void get_fileinfo (char *pathname);
/* Take care of discarding and inverting. */
{
if (! discard)
}
/* Check if file exists and fetch its information. */
{
char *device_name;
/* A hook for iterating directories. */
auto int find_file (const char *cur_filename,
const struct grub_dirhook_info *info);
const struct grub_dirhook_info *info)
{
{
file_exists = 1;
return 1;
}
return 0;
}
file_exists = 0;
if (! dev)
{
return;
}
if (! fs)
{
return;
}
if (! pathname)
else
pathname++;
/* Remove trailing '/'. */
/* Split into path and filename. */
if (! filename)
{
}
else
{
filename++;
}
/* It's the whole device. */
if (! *pathname)
{
file_exists = 1;
/* Root is always a directory. */
/* Fetch writing time. */
{
}
}
else
}
/* Here we have the real parsing. */
{
/* First try 3 argument tests. */
{
/* String tests. */
{
(*argn) += 3;
continue;
}
{
(*argn) += 3;
continue;
}
/* GRUB extension: lexicographical sorting. */
{
(*argn) += 3;
continue;
}
{
(*argn) += 3;
continue;
}
{
(*argn) += 3;
continue;
}
{
(*argn) += 3;
continue;
}
/* Number tests. */
{
(*argn) += 3;
continue;
}
{
(*argn) += 3;
continue;
}
{
(*argn) += 3;
continue;
}
{
(*argn) += 3;
continue;
}
{
(*argn) += 3;
continue;
}
{
(*argn) += 3;
continue;
}
/* GRUB extension: compare numbers skipping prefixes.
Useful for comparing versions. E.g. vmlinuz-2 -plt vmlinuz-11. */
{
int i;
/* Skip common prefix. */
/* Go the digits back. */
i--;
i--;
i++;
else
(*argn) += 3;
continue;
}
/* -nt and -ot tests. GRUB extension: when doing -?t<bias> bias
will be added to the first mtime. */
{
int file1exists;
int bias = 0;
/* Fetch fileinfo. */
else
(*argn) += 3;
continue;
}
}
/* Two-argument tests. */
{
/* File tests. */
{
(*argn) += 2;
return ret;
}
{
(*argn) += 2;
return ret;
}
{
/* FIXME: check for other types. */
(*argn) += 2;
return ret;
}
{
if (file)
(*argn) += 2;
return ret;
}
/* String tests. */
{
(*argn) += 2;
continue;
}
{
(*argn) += 2;
continue;
}
}
/* Special modifiers. */
/* End of expression. return to parent. */
{
(*argn)++;
return ret;
}
/* Recursively invoke if parenthesis. */
{
(*argn)++;
continue;
}
{
(*argn)++;
continue;
}
{
/* If current value is 0 second value is to be discarded. */
(*argn)++;
continue;
}
{
/* If current value is 1 second value is to be discarded. */
(*argn)++;
continue;
}
/* No test found. Interpret if as just a string. */
(*argn)++;
}
return ret;
}
static grub_err_t
{
int argn = 0;
argc--;
}
{
}
{
}