/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "grub.h"
#include "timer.h"
#include "nic.h"
/**************************************************************************
RANDOM - compute a random number between 0 and 2147483647L or 2147483562?
**************************************************************************/
{
int32_t q;
if (!seed) /* Initialize linear congruential generator */
/* simplified version of the LCG given in Bruce Schneier's
"Applied Cryptography" */
q = seed/53668;
return seed;
}
/**************************************************************************
POLL INTERRUPTIONS
**************************************************************************/
void poll_interruptions(void)
{
user_abort++;
}
}
/**************************************************************************
SLEEP
**************************************************************************/
{
unsigned long tmo;
}
}
/**************************************************************************
INTERRUPTIBLE SLEEP
**************************************************************************/
{
printf("<sleep>\n");
}
/**************************************************************************
TWIDDLE
**************************************************************************/
void twiddle(void)
{
#ifdef BAR_PROGRESS
static int count=0;
static unsigned long lastticks = 0;
unsigned long ticks;
#endif
#ifdef FREEBSD_PXEEMU
extern char pxeemu_nbp_active;
if(pxeemu_nbp_active != 0)
return;
#endif
#ifdef BAR_PROGRESS
/* Limit the maximum rate at which characters are printed */
return;
putchar('\b');
#else
//putchar('.');
#endif /* BAR_PROGRESS */
}
/* Because Etherboot uses its own formats for the printf family,
define separate definitions from GRUB. */
/**************************************************************************
PRINTF and friends
Formats:
%[#]x - 4 bytes long (8 hex digits, lower case)
%[#]X - 4 bytes long (8 hex digits, upper case)
%[#]hx - 2 bytes int (4 hex digits, lower case)
%[#]hX - 2 bytes int (4 hex digits, upper case)
%[#]hhx - 1 byte int (2 hex digits, lower case)
%[#]hhX - 1 byte int (2 hex digits, upper case)
- optional # prefixes 0x or 0X
%d - decimal int
%c - char
%s - string
%@ - Internet address in ddd.ddd.ddd.ddd notation
%! - Ethernet address in xx:xx:xx:xx:xx:xx notation
Note: width specification not supported
**************************************************************************/
static int
{
char *p, *s;
s = buf;
{
if (*fmt != '%')
{
continue;
}
if (*++fmt == 's')
{
for (p = (char *) *dp++; *p != '\0'; p++)
buf ? *s++ = *p : grub_putchar (*p);
}
else
{
/* Length of item is bounded */
int alt = 0;
if (*fmt == '#')
{
alt = 1;
fmt++;
}
if (*fmt == 'h')
{
shift = 12;
fmt++;
}
if (*fmt == 'h')
{
shift = 4;
fmt++;
}
/*
* Before each format q points to tmp buffer
* After each format q points past end of item
*/
{
/* With x86 gcc, sizeof(long) == sizeof(int) */
long h = *lp++;
if (alt)
{
*q++ = '0';
*q++ = 'X' | ncase;
}
}
else if (*fmt == 'd')
{
int i = *dp++;
char *r;
if (i < 0)
{
*q++ = '-';
i = -i;
}
p = q; /* save beginning of digits */
do
{
*q++ = '0' + (i % 10);
i /= 10;
}
while (i);
/* reverse digits, stop in middle */
r = q; /* don't alter q */
while (--r > p)
{
i = *r;
*r = *p;
*p++ = i;
}
}
else if (*fmt == '@')
{
unsigned char *r;
union
{
long l;
unsigned char c[4];
}
u;
u.l = *lp++;
for (r = &u.c[0]; r < &u.c[4]; ++r)
q += etherboot_sprintf (q, "%d.", *r);
--q;
}
else if (*fmt == '!')
{
char *r;
p = (char *) *dp++;
for (r = p + ETH_ALEN; p < r; ++p)
q += etherboot_sprintf (q, "%hhX:", *p);
--q;
}
else if (*fmt == 'c')
*q++ = *dp++;
else
*q++ = *fmt;
/* now output the saved string */
for (p = tmp; p < q; ++p)
buf ? *s++ = *p : grub_putchar (*p);
}
}
if (buf)
*s = '\0';
return (s - buf);
}
int
{
}
void
{
}
int
{
unsigned long ip = 0;
int val;
int i;
for (i = 0; i < 4; i++)
{
return 0;
if (i != 3 && *p++ != '.')
return 0;
}
return 1;
}
int
{
char *p = *ptr;
int ret = 0;
if (*p < '0' || *p > '9')
return -1;
while (*p >= '0' && *p <= '9')
{
p++;
}
*ptr = p;
return ret;
}