|
Last change
on this file since 2254 was 2254, checked in by bird, 20 years ago |
|
o LIBC_ASSERT*() are for internal libc errors, LIBCLOG_ERROR*() are
for user related error. Big code adjustements.
o Fixed a few smaller issues.
o Started fixing exec() backend.
|
-
Property cvs2svn:cvs-rev
set to
1.4
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | /* getenv.c (emx+gcc) -- Copyright (c) 1990-1995 by Eberhard Mattes */
|
|---|
| 2 |
|
|---|
| 3 | #include "libc-alias.h"
|
|---|
| 4 | #include <stdlib.h>
|
|---|
| 5 | #include <string.h>
|
|---|
| 6 | #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_ENV
|
|---|
| 7 | #include <InnoTekLIBC/logstrict.h>
|
|---|
| 8 |
|
|---|
| 9 | char *_STD(getenv)(const char *name)
|
|---|
| 10 | {
|
|---|
| 11 | LIBCLOG_ENTER("name=%p:{%s}\n", name, name);
|
|---|
| 12 | int len;
|
|---|
| 13 | char **p;
|
|---|
| 14 |
|
|---|
| 15 | if (!name)
|
|---|
| 16 | {
|
|---|
| 17 | LIBCLOG_ERROR("invalid parameter name (NULL)!\n");
|
|---|
| 18 | LIBCLOG_RETURN_P(NULL);
|
|---|
| 19 | }
|
|---|
| 20 | if (environ == NULL)
|
|---|
| 21 | {
|
|---|
| 22 | LIBCLOG_ERROR("environment is not configured!!!\n");
|
|---|
| 23 | LIBCLOG_RETURN_P(NULL);
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | LIBCLOG_ERROR_CHECK(!strchr(name, '='), "name contains '=' ('%s')\n", name);
|
|---|
| 27 | LIBCLOG_ERROR_CHECK(*name, "name is empty\n");
|
|---|
| 28 |
|
|---|
| 29 | len = strlen(name);
|
|---|
| 30 | for (p = environ; *p != NULL; ++p)
|
|---|
| 31 | {
|
|---|
| 32 | if ( strncmp(*p, name, len) == 0
|
|---|
| 33 | && (*p)[len] == '=')
|
|---|
| 34 | {
|
|---|
| 35 | char *pszRet = *p + len + 1;
|
|---|
| 36 | LIBCLOG_RETURN_MSG(pszRet, "ret %p:{%s}\n", pszRet, pszRet);
|
|---|
| 37 | }
|
|---|
| 38 | }
|
|---|
| 39 | LIBCLOG_RETURN_P(NULL);
|
|---|
| 40 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.