- Change getenv_quad() to return an int instead of a quad_t since it

returns an success/failure code rather than the actual value.
- Add getenv_string() which copies a string from the environment to another
  string and returns true on success.
This commit is contained in:
John Baldwin
2001-10-23 22:34:36 +00:00
parent a33cbf355e
commit 21cbf0cc8b
2 changed files with 23 additions and 2 deletions
+21 -1
View File
@@ -46,6 +46,9 @@ char *kern_envp;
static char *kernenv_next(char *cp);
/*
* Look up an environment variable by name.
*/
char *
getenv(const char *name)
{
@@ -64,6 +67,23 @@ getenv(const char *name)
return(NULL);
}
/*
* Return a string value from an environment variable.
*/
int
getenv_string(const char *name, char *data, int size)
{
char *tmp;
tmp = getenv(name);
if (tmp == NULL) {
strncpy(data, tmp, size);
data[size - 1] = 0;
return (1);
} else
return (0);
}
/*
* Return an integer value from an environment variable.
*/
@@ -83,7 +103,7 @@ getenv_int(const char *name, int *data)
/*
* Return a quad_t value from an environment variable.
*/
quad_t
int
getenv_quad(const char *name, quad_t *data)
{
const char *value;
+2 -1
View File
@@ -192,7 +192,8 @@ int cr_cansee __P((struct ucred *u1, struct ucred *u2));
char *getenv __P((const char *name));
int getenv_int __P((const char *name, int *data));
quad_t getenv_quad __P((const char *name, quad_t *data));
int getenv_string __P((const char *name, char *data, int size));
int getenv_quad __P((const char *name, quad_t *data));
#ifdef APM_FIXUP_CALLTODO
struct timeval;