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 /*	chdir3f.c - Implements LIB3F chdir subprogram.  */
21 
22 /* must include ent3f.h AFTER io3f.h */
23 #include <unistd.h>
24 #include "io3f.h"
25 #include "ent3f.h"
26 
27 #ifdef WIN32
28 #define chdir _chdir
29 #endif
30 
31 extern char *__fstr2cstr();
32 extern void __cstr_free();
33 
ENT3F(CHDIR,chdir)34 int ENT3F(CHDIR, chdir)(DCHAR(path) DCLEN(path))
35 {
36   char *p;
37   int i;
38 
39   p = __fstr2cstr(CADR(path), CLEN(path));
40   if ((i = chdir(p)))
41     i = __io_errno();
42   __cstr_free(p);
43   return i;
44 }
45