/* GetXNSid.c -- Copyright Ó 1988 by Xerox Corporation. All rights reserved. * A grand kludge for getting the XNS ID from a standard SUNOS 4.0 kernel; * The problem is that to open the NIT, you have to be SUID root, and we don't * want cedar running that way, so we fork another little program to do the * real work, then read the results from a pipe. */ #include typedef unsigned short BYTE; typedef struct HostNumber_self { BYTE a :8; BYTE b :8; BYTE c :8; BYTE d :8; BYTE e :8; BYTE f :8; } XNSID_HostNumber; typedef struct ProcessorID_self { XNSID_HostNumber anon0; } XNSID_ProcessorID; extern void XR_getxnshostid(pid) XNSID_ProcessorID *pid; { int i, scanresult; int buffer[6]; int errorval = 10; FILE *sh; if (pid == NULL) return; sh = popen("getxnshostid", "r"); /* all 0 return -> error */ pid->anon0.a = 0; pid->anon0.b = 0; pid->anon0.c = 0; pid->anon0.d = 0; pid->anon0.e = 0; pid->anon0.f = 0; if (sh == NULL) return; /* all 0 return -> error */ for (i = 0; i < 6; i++) { scanresult = fscanf(sh, "%x", &buffer[i]); if (scanresult != 1) break; /* all 0 return -> error */ }; pclose(sh); if (i < 6) return; /* all 0 return -> error */ pid->anon0.a = buffer[0]; pid->anon0.b = buffer[1]; pid->anon0.c = buffer[2]; pid->anon0.d = buffer[3]; pid->anon0.e = buffer[4]; pid->anon0.f = buffer[5]; return; }