Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / argz / envz_entry.c
blob869c332ad09418b5f9e99c0adae2b46ca9cf93f7
1 /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
3 * Permission to use, copy, modify, and distribute this software
4 * is freely granted, provided that this notice is preserved.
5 */
7 #include <errno.h>
8 #include <sys/types.h>
9 #include <string.h>
10 #include <stdlib.h>
11 #include <envz.h>
13 #include "buf_findstr.h"
15 char *
16 envz_entry (const char *envz,
17 size_t envz_len,
18 const char *name)
20 char *buf_ptr = (char *)envz;
21 size_t buf_len = envz_len;
23 while(buf_len)
25 if (_buf_findstr(name, &buf_ptr, &buf_len))
27 if (buf_ptr)
29 if (*buf_ptr == '=' || *buf_ptr == '\0')
31 buf_ptr--;
33 /* Move buf_ptr back to start of entry. */
34 while(*buf_ptr != '\0' && buf_ptr != envz) buf_ptr--;
36 if(*buf_ptr == '\0')
37 buf_ptr++;
39 return (char *)buf_ptr;
44 return 0;