GRASS 8 Programmer's Manual
8.6.0dev(2026)-f6f2c534ea
Loading...
Searching...
No Matches
mach_name.c
Go to the documentation of this file.
1
#include <
unistd.h
>
2
#include <
grass/gis.h
>
3
#include <
grass/config.h
>
4
#ifdef HAVE_SYS_UTSNAME_H
5
#include <sys/utsname.h>
6
#endif
7
8
/* this routine returns a name for the machine
9
* it returns the empty string, if this info
10
* not available (it never returns a NULL pointer)
11
*
12
* the name is stored in a static array and the pointer to this
13
* array is returned.
14
*
15
*/
16
const
char
*
G__machine_name
(
void
)
17
{
18
static
int
initialized;
19
static
char
name
[128];
20
21
if
(
G_is_initialized
(&initialized))
22
return
name
;
23
24
#if defined(HAVE_GETHOSTNAME)
25
gethostname
(
name
,
sizeof
(
name
));
26
name
[
sizeof
(
name
) - 1] = 0;
/* make sure NUL terminated */
27
#elif defined(HAVE_SYS_UTSNAME_H)
28
{
29
struct
utsname
attname
;
30
31
uname
(&
attname
);
32
strcpy
(
name
,
attname
.nodename);
33
}
34
#else
35
strcpy
(
name
,
"unknown"
);
36
#endif
37
38
G_initialize_done
(&initialized);
39
return
name
;
40
}
AMI_STREAM
Definition
ami_stream.h:153
AMI_STREAM::AMI_STREAM
AMI_STREAM()
Definition
ami_stream.h:227
config.h
G_is_initialized
int G_is_initialized(int *)
Definition
counter.c:60
G_initialize_done
void G_initialize_done(int *)
Definition
counter.c:77
gis.h
G__machine_name
const char * G__machine_name(void)
Definition
mach_name.c:16
name
const char * name
Definition
named_colr.c:6
strcpy
#define strcpy
Definition
parson.c:66
unistd.h
lib
gis
mach_name.c
Generated on Sun Apr 12 2026 06:59:15 for GRASS 8 Programmer's Manual by
1.9.8