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

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [libposix/] [env.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Environment accessor functions
3
 *
4
 * Copyright (C) 2008 Bahadir Balban
5
 */
6
#include <string.h>
7
#include <stdlib.h>
8
#include <libposix.h>
9
 
10
char **__environ;
11
 
12
 
13
/*
14
 * Search for given name in name=value string pairs located
15
 * in the environment segment, and return the pointer to value
16
 * string.
17
 */
18
char *getenv(const char *name)
19
{
20
        char **envp = __environ;
21
        int length;
22
 
23
        if (!envp)
24
                return 0;
25
        length = strlen(name);
26
 
27
        while(*envp) {
28
                if (memcmp(name, *envp, length) == 0 &&
29
                    (*envp)[length] == '=')
30
                        return *envp + length + 1;
31
                envp++;
32
        }
33
 
34
        return 0;
35
}
36
 

powered by: WebSVN 2.1.0

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