Mirror of git://git.busybox.net/busybox with our patches on top
Source
bb_error_msg_and_die("\"%s\" may be inet %s, but it is not allowed in this context", arg, "address");
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*
* Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
*
* Changes:
*
* Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
*/
unsigned get_hz(void)
{
static unsigned hz_internal;
FILE *fp;
if (hz_internal)
return hz_internal;
fp = fopen_for_read("/proc/net/psched");
if (fp) {
unsigned nom, denom;
if (fscanf(fp, "%*08x%*08x%08x%08x", &nom, &denom) == 2)
if (nom == 1000000)
hz_internal = denom;
fclose(fp);
}
if (!hz_internal)
hz_internal = bb_clk_tck();
return hz_internal;
}
unsigned get_unsigned(char *arg, const char *errmsg)
{
unsigned long res;
char *ptr;
if (*arg) {
res = strtoul(arg, &ptr, 0);
//FIXME: "" will be accepted too, is it correct?!
if (!*ptr && res <= UINT_MAX) {
return res;
}
}
invarg_1_to_2(arg, errmsg); /* does not return */
}
uint32_t get_u32(char *arg, const char *errmsg)
{
unsigned long res;
char *ptr;
if (*arg) {
res = strtoul(arg, &ptr, 0);
//FIXME: "" will be accepted too, is it correct?!
if (!*ptr && res <= 0xFFFFFFFFUL) {
return res;
}