blob: 3cf3ed51345c8e46f5324216ee7b3162caf5fdaa (
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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*@@
@file Network.c
@date Fri 19 Jan 2001
@author Thomas Radke
@desc
Network related routines
@enddesc
@version $Header$
@@*/
#include "cctk.h"
#include "util_Network.h"
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_NETDB_H
#include <netdb.h>
#elif defined HAVE_WINSOCK2_H
#include <winsock2.h>
#endif /* HAVE_WINSOCK2_H */
static const char *rcsid = "$Header$";
CCTK_FILEVERSION(util_Network_c);
/********************************************************************
********************* Local Data Types ***********************
********************************************************************/
/********************************************************************
********************* Local Routine Prototypes *********************
********************************************************************/
/********************************************************************
********************* Other Routine Prototypes *********************
********************************************************************/
/********************************************************************
********************* Local Data *****************************
********************************************************************/
/********************************************************************
********************* External Routines **********************
********************************************************************/
/*@@
@routine Util_GetHostName
@date Fri Oct 20 12:12:34 2000
@author Tom Goodale
@desc
Gets the fully qualified name of this host if possible.
@enddesc
@calls
@history
just copied from thorn HTTPD
@endhistory
@var name
@vdesc character buffer to store name in
@vtype char *
@vio out
@vcomment
@endvar
@var length
@vdesc length of the character buffer
@vtype int
@vio in
@vcomment
@endvar
@@*/
void Util_GetHostName (char *name, int length)
{
gethostname (name, length);
/* Does the name include the domain. */
if (! strchr (name, '.'))
{
#ifdef HAVE_GETHOSTBYNAME
struct hostent *thishostent;
thishostent = gethostbyname (name);
if (thishostent)
{
strncpy (name, thishostent->h_name, length);
name[length - 1] = 0;
}
#endif
}
}
|