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 /*	ttynam3f.c - Implements LIB3F ttynam subprogram.  */
21 
22 #ifndef WINNT
23 
24 /* must include ent3f.h AFTER io3f.h */
25 #include "io3f.h"
26 #include "ent3f.h"
27 #include "utils3f.h"
28 
29 extern char *ttyname();
30 
31 /* ttynam is a character function */
ENT3F(TTYNAM,ttynam)32 void ENT3F(TTYNAM, ttynam)(DCHAR(nm) DCLEN(nm), int *lu)
33 {
34   int u;
35   char *p;
36 
37   switch (*lu) {
38   case 0:
39     u = 2;
40     break;
41   case 5:
42     u = 0;
43     break;
44   case 6:
45     u = 1;
46     break;
47   default:
48     p = 0;
49     goto sk;
50   }
51   p = ttyname(u);
52 sk:
53   __fcp_cstr(CADR(nm), CLEN(nm), p);
54   /*
55   if (p) free(p);
56   */
57 
58   return;
59 }
60 
61 #endif /* !WINNT */
62