2005-07-19 15:21:51 +02:00
|
|
|
#include "sysutil.h"
|
2005-04-21 16:53:53 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/*=========================================================================*
|
|
|
|
* env_prefix *
|
|
|
|
*=========================================================================*/
|
|
|
|
PUBLIC int env_prefix(env, prefix)
|
|
|
|
char *env; /* environment variable to inspect */
|
|
|
|
char *prefix; /* prefix to test for */
|
|
|
|
{
|
|
|
|
/* An environment setting may be prefixed by a word, usually "pci".
|
|
|
|
* Return TRUE if a given prefix is used.
|
|
|
|
*/
|
|
|
|
char value[EP_BUF_SIZE];
|
|
|
|
char punct[] = ":,;.";
|
|
|
|
int s;
|
|
|
|
size_t n;
|
|
|
|
|
2005-06-03 15:55:06 +02:00
|
|
|
if ((s = get_mon_param(env, value, sizeof(value))) != 0) {
|
2005-04-21 16:53:53 +02:00
|
|
|
if (s != ESRCH) /* only error allowed */
|
2005-06-03 15:55:06 +02:00
|
|
|
printf("WARNING: get_mon_param() failed in env_prefix(): %d\n", s);
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
|
|
|
n = strlen(prefix);
|
|
|
|
return(value != NULL
|
|
|
|
&& strncmp(value, prefix, n) == 0
|
|
|
|
&& strchr(punct, value[n]) != NULL);
|
|
|
|
}
|
|
|
|
|