
This was a MINIX3-specific header file placed outside of the minix/ header subdirectory, with its definitions duplicated in the more standard minix/sysutil.h header. Also make env_prefix(3) take constant pointers. Change-Id: I243c38eb38e24eb98f0c0dddf7f340e7fec255f4
30 lines
861 B
C
30 lines
861 B
C
#include "sysutil.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
/*=========================================================================*
|
|
* env_prefix *
|
|
*=========================================================================*/
|
|
int env_prefix(const char *env, const char *prefix)
|
|
{
|
|
/* An environment setting may be prefixed by a word, usually "pci".
|
|
* - env: environment variable to inspect
|
|
* - prefix: prefix to test for
|
|
* Return TRUE if a given prefix is used.
|
|
*/
|
|
char value[EP_BUF_SIZE];
|
|
char punct[] = ":,;.";
|
|
int s;
|
|
size_t n;
|
|
|
|
if ((s = env_get_param(env, value, sizeof(value))) != 0) {
|
|
if (s != ESRCH) /* only error allowed */
|
|
printf("WARNING: env_get_param() failed in env_prefix(): %d\n", s);
|
|
return FALSE;
|
|
}
|
|
n = strlen(prefix);
|
|
return(strncmp(value, prefix, n) == 0
|
|
&& strchr(punct, value[n]) != NULL);
|
|
}
|
|
|