blob: 6ed86d5bebb09b6797e466f75ba89c26e5fcb1b8 (
plain)
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
|
/* portnm.c
Get the port name of stdin. */
#include "uucp.h"
#include "sysdep.h"
#include "system.h"
#if HAVE_TCP
#if HAVE_SYS_TYPES_TCP_H
#include <sys/types.tcp.h>
#endif
#include <sys/socket.h>
#endif
#ifndef ttyname
extern char *ttyname ();
#endif
/* Get the port name of standard input. I assume that Unix systems
generally support ttyname. If they don't, this function can just
return NULL. It uses getsockname to see whether standard input is
a TCP connection. */
const char *
zsysdep_port_name (ftcp_port)
boolean *ftcp_port;
{
const char *z;
*ftcp_port = FALSE;
#if HAVE_TCP
{
int clen;
struct sockaddr s;
clen = sizeof (struct sockaddr);
if (getsockname (0, &s, &clen) == 0)
*ftcp_port = TRUE;
}
#endif /* HAVE_TCP */
z = ttyname (0);
if (z == NULL)
return NULL;
if (strncmp (z, "/dev/", sizeof "/dev/" - 1) == 0)
return z + sizeof "/dev/" - 1;
else
return z;
}
|