Add getenv_int(), specifically for retrieving integer values from kernel

environment variables.  This makes it easy to pass tuning parameters
in from the bootloader.
This commit is contained in:
Mike Smith 1999-01-15 17:25:02 +00:00
parent 8664a77199
commit 2084f96c7f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=42706
2 changed files with 22 additions and 2 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: kern_environment.c,v 1.2 1998/10/09 11:03:46 jkh Exp $
* $Id: kern_environment.c,v 1.3 1998/10/09 21:21:34 msmith Exp $
*/
/*
@ -65,6 +65,25 @@ getenv(char *name)
return(NULL);
}
/*
* Return an integer value from an environment variable.
*/
int
getenv_int(char *name, int *data)
{
char *value, *vtp;
quad_t iv;
if ((value = getenv(name)) == NULL)
return(0);
iv = strtoq(value, &vtp, 0);
if ((vtp == value) || (*vtp != 0))
return(0);
*data = (int)iv;
return(1);
}
static int
sysctl_kernenv SYSCTL_HANDLER_ARGS

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)systm.h 8.7 (Berkeley) 3/29/95
* $Id: systm.h,v 1.82 1999/01/10 01:58:27 eivind Exp $
* $Id: systm.h,v 1.83 1999/01/15 00:03:39 msmith Exp $
*/
#ifndef _SYS_SYSTM_H_
@ -163,6 +163,7 @@ void setstatclockrate __P((int hzrate));
void hardpps __P((struct timeval *tvp, long usec));
char *getenv __P((char *name));
int getenv_int __P((char *name, int *data));
extern char *kern_envp;
#ifdef APM_FIXUP_CALLTODO