1 #ifndef utsname_hxx
2 #define utsname_hxx
3 
4 #if defined(__VMS) && __VMS_VER < 70000000
5 
6 //  provide uname functionality (note: only nodename is returned) for OpenVMS
7 //  systems older than 7.0
8 
9 #include <errno.h>
10 #include <descrip.h>
11 #include <lib$routines.h>
12 #include <syidef.h>
13 
14 struct utsname {
15     char nodename[1024+1];   /*  DECnet node name                    */
16 };
17 
uname(utsname * name)18 static int uname (utsname* name) {
19 
20     const int nodeNameCode(SYI$_NODENAME);
21 
22     dsc$descriptor_s dx;
23     dx.dsc$w_length = 1024;
24     dx.dsc$b_dtype = DSC$K_DTYPE_T;
25     dx.dsc$b_class = DSC$K_CLASS_S;
26     dx.dsc$a_pointer = name->nodename;
27 
28     unsigned short length(0);
29 
30     vaxc$errno = lib$getsyi(
31 	&nodeNameCode,		// item-code
32 	0,			// resultant-value (ignored)
33 	&dx,			// resultant-string
34 	&length,		// resultant-length
35 	0,			// cluster-system-id
36 	0			// node-name
37     );
38     name->nodename[length]=0;
39 
40     int result = (vaxc$errno & 1) ? 0 : -1;
41     if (result == -1) {
42 	errno = EVMSERR;
43     }
44     return result;
45 }
46 
47 #else
48 
49 #include <sys/utsname.h>
50 
51 #endif
52 
53 #endif
54