OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [argz/] [envz_entry.c] - Blame information for rev 148

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* Copyright (C) 2002 by  Red Hat, Incorporated. All rights reserved.
2
 *
3
 * Permission to use, copy, modify, and distribute this software
4
 * is freely granted, provided that this notice is preserved.
5
 */
6
 
7
#include <errno.h>
8
#include <sys/types.h>
9
#include <string.h>
10
#include <stdlib.h>
11
#include <envz.h>
12
 
13
#include "buf_findstr.h"
14
 
15
char *
16
_DEFUN (envz_entry, (envz, envz_len, name),
17
       const char *envz _AND
18
       size_t envz_len _AND
19
       const char *name)
20
{
21
  char *buf_ptr = (char *)envz;
22
  size_t buf_len = envz_len;
23
 
24
  while(buf_len)
25
    {
26
      if (_buf_findstr(name, &buf_ptr, &buf_len))
27
        {
28
          if (buf_ptr)
29
            {
30
              if (*buf_ptr == '=' || *buf_ptr == '\0')
31
                {
32
                  buf_ptr--;
33
 
34
                  /* Move buf_ptr back to start of entry. */
35
                  while(*buf_ptr != '\0' && buf_ptr != envz) buf_ptr--;
36
 
37
                  if(*buf_ptr == '\0')
38
                    buf_ptr++;
39
 
40
                  return (char *)buf_ptr;
41
                }
42
            }
43
        }
44
    }
45
  return 0;
46
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.