File: io_init_name.c

package info (click to toggle)
fis-gtm 7.1-006-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 32,908 kB
  • sloc: ansic: 344,906; asm: 5,184; csh: 4,859; sh: 2,000; awk: 294; makefile: 73; sed: 13
file content (78 lines) | stat: -rwxr-xr-x 1,711 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/****************************************************************
 *								*
 * Copyright (c) 2001-2022 Fidelity National Information	*
 * Services, Inc. and/or its subsidiaries. All rights reserved.	*
 *								*
 *	This source code contains the intellectual property	*
 *	of its copyright holder(s), and is made available	*
 *	under a license.  If you do not know the terms of	*
 *	the license, please stop and do not read further.	*
 *								*
 ****************************************************************/

#include "mdef.h"

#include "gtm_string.h"
#include "gtm_strings.h"

#include "io.h"
#include "gtm_logicals.h"

#include "gtm_unistd.h"
#include "gtm_limits.h"

GBLDEF mstr	sys_input;
GBLDEF mstr	sys_output;
GBLDEF mstr	gtm_principal;

void io_init_name(void)
{
	char    temp[TTY_NAME_MAX + 1], *c;
	int   	i, size;

	if (isatty(0))
	{
		memset(temp, '\0', TTY_NAME_MAX + 1);
		TTYNAME_R(0, temp, TTY_NAME_MAX, i); /* ttyname_r() is MT-Safe */
		if (0 == i)
		{
			size = STRLEN(temp);
			sys_input.addr = (char *) malloc(size);
			memcpy(sys_input.addr, temp, size);
			sys_input.len = size;
		} else
		{
			sys_input.addr = "0";
			sys_input.len = 1;
		}
	}
	else
	{
		sys_input.addr = "0";
		sys_input.len = 1;
	}
	if (isatty(1))
	{
		memset(temp, '\0', TTY_NAME_MAX + 1);
		TTYNAME_R(1, temp, TTY_NAME_MAX, i);
		if (0 == i)
		{
			size = STRLEN(temp);
			sys_output.addr =  (char *) malloc(size);
			memcpy(sys_output.addr, temp, size);
			sys_output.len = size;
		}
		else
		{
			sys_output.addr = "&";
			sys_output.len = 1;
		}
	} else
	{
		sys_output.addr = "&";
		sys_output.len = 1;
	}
	gtm_principal.addr = GTM_PRINCIPAL;
	gtm_principal.len = STR_LIT_LEN(GTM_PRINCIPAL);
	return;
}