source: trunk/minix/lib/sysutil/env_prefix.c@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 886 bytes
RevLine 
[9]1#include "sysutil.h"
2#include <stdlib.h>
3#include <string.h>
4
5/*=========================================================================*
6 * env_prefix *
7 *=========================================================================*/
8PUBLIC int env_prefix(env, prefix)
9char *env; /* environment variable to inspect */
10char *prefix; /* prefix to test for */
11{
12/* An environment setting may be prefixed by a word, usually "pci".
13 * Return TRUE if a given prefix is used.
14 */
15 char value[EP_BUF_SIZE];
16 char punct[] = ":,;.";
17 int i, s, keylen;
18 char *val;
19 size_t n;
20
21 if ((s = env_get_param(env, value, sizeof(value))) != 0) {
22 if (s != ESRCH) /* only error allowed */
23 printf("WARNING: get_mon_param() failed in env_prefix(): %d\n", s);
24 }
25 n = strlen(prefix);
26 return(value != NULL
27 && strncmp(value, prefix, n) == 0
28 && strchr(punct, value[n]) != NULL);
29}
30
Note: See TracBrowser for help on using the repository browser.