4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-15 19:09:58 +08:00
newlib-cygwin/newlib/libc/argz/envz_entry.c
Thomas Fitzsimmons 9b022d6db8 * libc/argz/argz_replace.c: Include buf_findstr.h.
* libc/argz/buf_findstr.c: Likewise.
	* libc/argz/envz_entry.c: Include buf_findstr.h.  Cast return
	value to (char *).
	* libc/argz/envz_get.c: Likewise.
	* libc/include/sys/unistd.h: Add getopt and getsubopt declarations.
	* libc/stdlib/Makefile.am (LIB_SOURCES): Add getsubopt.c.
	* libc/stdlib/getsubopt.3: New file.
	* libc/stdlib/getsubopt.c: New file.
	* libc/sys/linux/machine/i386/socketcall.h (__sockcall_base):
	Change esp to ebp.
2002-07-19 20:36:09 +00:00

44 lines
1018 B
C

/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
*
* Permission to use, copy, modify, and distribute this software
* is freely granted, provided that this notice is preserved.
*/
#include <errno.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <envz.h>
#include "buf_findstr.h"
char *
envz_entry (const char *envz, size_t envz_len, const char *name)
{
char *buf_ptr = (char *)envz;
size_t buf_len = envz_len;
while(buf_len)
{
if (_buf_findstr(name, &buf_ptr, &buf_len))
{
if (buf_ptr)
{
if (*buf_ptr == '=' || *buf_ptr == '\0')
{
buf_ptr--;
/* Move buf_ptr back to start of entry. */
while(*buf_ptr != '\0' && buf_ptr != envz) buf_ptr--;
if(*buf_ptr == '\0')
buf_ptr++;
return (char *)buf_ptr;
}
}
}
}
return 0;
}