I don't know what I was smoking when I wrote these three years ago; the
return value is an error code, hence always an int. While I'm here, add getenv_uint() for completeness.
This commit is contained in:
parent
3dca093960
commit
d302c56d9b
@ -438,14 +438,29 @@ getenv_int(const char *name, int *data)
|
||||
return (rval);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return an unsigned integer value from an environment variable.
|
||||
*/
|
||||
int
|
||||
getenv_uint(const char *name, unsigned int *data)
|
||||
{
|
||||
quad_t tmp;
|
||||
int rval;
|
||||
|
||||
rval = getenv_quad(name, &tmp);
|
||||
if (rval)
|
||||
*data = (unsigned int) tmp;
|
||||
return (rval);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a long value from an environment variable.
|
||||
*/
|
||||
long
|
||||
int
|
||||
getenv_long(const char *name, long *data)
|
||||
{
|
||||
quad_t tmp;
|
||||
long rval;
|
||||
int rval;
|
||||
|
||||
rval = getenv_quad(name, &tmp);
|
||||
if (rval)
|
||||
@ -456,11 +471,11 @@ getenv_long(const char *name, long *data)
|
||||
/*
|
||||
* Return an unsigned long value from an environment variable.
|
||||
*/
|
||||
unsigned long
|
||||
int
|
||||
getenv_ulong(const char *name, unsigned long *data)
|
||||
{
|
||||
quad_t tmp;
|
||||
long rval;
|
||||
int rval;
|
||||
|
||||
rval = getenv_quad(name, &tmp);
|
||||
if (rval)
|
||||
|
@ -239,8 +239,9 @@ int cr_canseesocket(struct ucred *cred, struct socket *so);
|
||||
char *getenv(const char *name);
|
||||
void freeenv(char *env);
|
||||
int getenv_int(const char *name, int *data);
|
||||
long getenv_long(const char *name, long *data);
|
||||
unsigned long getenv_ulong(const char *name, unsigned long *data);
|
||||
int getenv_uint(const char *name, unsigned int *data);
|
||||
int getenv_long(const char *name, long *data);
|
||||
int getenv_ulong(const char *name, unsigned long *data);
|
||||
int getenv_string(const char *name, char *data, int size);
|
||||
int getenv_quad(const char *name, quad_t *data);
|
||||
int setenv(const char *name, const char *value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user