1 /*
2  * Copyright (c) 2017, NVIDIA CORPORATION.  All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 /* clang-format off */
19 
20 /*	getenvqq3f.c - Implements DFLIB getenvqq subprogram.  */
21 
22 #include <string.h>
23 #include "ent3f.h"
24 #include "utils3f.h"
25 
26 extern char *getenv();
27 extern char *__fstr2cstr();
28 extern void __cstr_free();
29 
ENT3F(GETENVQQ,getenvqq)30 int ENT3F(GETENVQQ, getenvqq)(DCHAR(en), DCHAR(ev) DCLEN(en) DCLEN(ev))
31 {
32   char *p, *q;
33   char ch;
34   int i;
35 
36   q = __fstr2cstr(CADR(en), CLEN(en));
37   p = getenv(q);
38   if (p == NULL)
39     i = 0;
40   else
41     i = strlen(p);
42   __fcp_cstr(CADR(ev), CLEN(ev), p);
43   __cstr_free(q);
44   return i;
45 }
46