make vfs & filesystems use failable copying
[minix3.git] / lib / libsys / env_prefix.c
blob5ef297917bd28a5b08cfa8ffa44fd6e4c162a6b4
1 #include "sysutil.h"
2 #include <stdlib.h>
3 #include <string.h>
5 /*=========================================================================*
6 * env_prefix *
7 *=========================================================================*/
8 int env_prefix(env, prefix)
9 char *env; /* environment variable to inspect */
10 char *prefix; /* prefix to test for */
12 /* An environment setting may be prefixed by a word, usually "pci".
13 * Return TRUE if a given prefix is used.
15 char value[EP_BUF_SIZE];
16 char punct[] = ":,;.";
17 int s;
18 size_t n;
20 if ((s = env_get_param(env, value, sizeof(value))) != 0) {
21 if (s != ESRCH) /* only error allowed */
22 printf("WARNING: env_get_param() failed in env_prefix(): %d\n", s);
23 return FALSE;
25 n = strlen(prefix);
26 return(strncmp(value, prefix, n) == 0
27 && strchr(punct, value[n]) != NULL);