-
Notifications
You must be signed in to change notification settings - Fork 0
/
chost.c
50 lines (37 loc) · 995 Bytes
/
chost.c
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
/*
-------------------------------------------------------------------------
OBJECT NAME: chost.c
FULL NAME: Compute Host
ENTRY POINTS: SetComputeHost()
GetComputeHost()
DESCRIPTION:
COPYRIGHT: University Corporation for Atmospheric Research, 1995
-------------------------------------------------------------------------
*/
#include <stdio.h>
#include <string.h>
#include <sys/utsname.h>
#include "constants.h"
static char ComputeHost[65]; /* name of host running WINDS */
/* -------------------------------------------------------------------- */
int SetComputeHost()
{
int rc;
struct utsname name;
ComputeHost[0] = '\0';
if ((rc = uname(&name)) == ERROR)
perror("uname");
else
{
strcpy(ComputeHost, name.nodename);
if (strchr(ComputeHost, '.'))
*(strchr(ComputeHost, '.')) = '\0';
}
return rc;
}
/* -------------------------------------------------------------------- */
char *GetComputeHost()
{
return ComputeHost;
}
/* END CHOST.C */