/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1992-2011 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* David Korn
* Glenn Fowler
* AT&T Research
*
* uname
*/
static const char usage[] =
"[-?\n@(#)$Id: uname (AT&T Research) 2007-04-19 $\n]"
"[+NAME?uname - identify the current system ]"
"[+DESCRIPTION?By default \buname\b writes the operating system name to"
" standard output. When options are specified, one or more"
" system characteristics are written to standard output, space"
" separated, on a single line. When more than one option is specified"
" the output is in the order specfied by the \b-A\b option below."
" Unsupported option values are listed as \a[option]]\a. If any unknown"
"[+?If any \aname\a operands are specified then the \bsysinfo\b(2) values"
" for each \aname\a are listed, separated by space, on one line."
" \bgetconf\b(1), a pre-existing \astandard\a interface, provides"
" access to the same information; vendors should spend more time"
" using standards than inventing them.]"
"[+?Selected information is printed in the same order as the options below.]"
"[a:all?Equivalent to \b-snrvmpio\b.]"
"[s:system|sysname|kernel-name?The detailed kernel name. This is the default.]"
"[n:nodename?The hostname or nodename.]"
"[r:release|kernel-release?The kernel release level.]"
"[v:version|kernel-version?The kernel version level.]"
"[m:machine?The name of the hardware type the system is running on.]"
"[p:processor?The name of the processor instruction set architecture.]"
"[i:implementation|platform|hardware-platform?The hardware implementation;"
" this is \b--host-id\b on some systems.]"
"[o:operating-system?The generic operating system name.]"
"[h:host-id|id?The host id in hex.]"
"[d:domain?The domain name returned by \agetdomainname\a(2).]"
"[R:extended-release?The extended release name.]"
"[A:everything?Equivalent to \b-snrvmpiohdR\b.]"
"[f:list?List all \bsysinfo\b(2) names and values, one per line.]"
"[S:sethost?Set the hostname or nodename to \aname\a. No output is"
" written to standard output.]:[name]"
"\n"
"\n[ name ... ]\n"
"\n"
"[+SEE ALSO?\bhostname\b(1), \bgetconf\b(1), \buname\b(2),"
" \bsysconf\b(2), \bsysinfo\b(2)]"
;
#if defined(__STDPP__directive) && defined(__STDPP__hide)
#else
#define getdomainname ______getdomainname
#define gethostid ______gethostid
#define gethostname ______gethostname
#define sethostname ______sethostname
#endif
#include <cmd.h>
#include <ctype.h>
#include <proc.h>
#if _lib_uname && _sys_utsname
#endif
#if defined(__STDPP__directive) && defined(__STDPP__hide)
#else
#endif
extern int getdomainname(char*, size_t);
#endif
#if _lib_gethostid
extern long gethostid(void);
#endif
#if _lib_gethostname
extern int gethostname(char*, size_t);
#endif
#if _lib_sethostname
extern int sethostname(const char*, size_t);
#endif
#ifndef HOSTTYPE
#endif
#if !_lib_uname || !_sys_utsname
#if defined(__STDPP__)
#else
#endif
struct utsname
{
char* sysname;
char* release;
char* version;
char* machine;
};
int
{
#ifdef HOSTTYPE
char* sys = 0;
char* arch = 0;
if (*hosttype)
{
{
*arch++ = 0;
if (!*arch)
arch = 0;
}
if (!*sys)
sys = 0;
}
#endif
#ifdef _lib_gethostname
return -1;
#else
#endif
#ifdef HOSTTYPE
#endif
#ifdef HOSTTYPE
#endif
return 0;
}
#endif
#ifndef MACHINE
#if defined(__STDPP__)
#else
#endif
#endif
#ifndef HOSTTYPE
#endif
#define extra(m) do \
{ \
} while(0)
#define output(f,v,u) do \
{ \
if ((flags&(f))&&(*(v)||(flags&(OPT_all|OPT_total))==OPT_all&&((f)&OPT_standard)||!(flags&(OPT_all|OPT_total)))) \
{ \
if (sep) \
else \
sep = 1; \
if (*(v)) \
else \
} \
} while (0)
int
{
register long flags = 0;
register int sep = 0;
register int n;
register char* s;
char* t;
char* e;
char* sethost = 0;
int list = 0;
for (;;)
{
{
case 'a':
continue;
case 'b':
continue;
case 'c':
flags |= OPT_vendor;
continue;
case 'd':
flags |= OPT_domain;
continue;
case 'f':
list = 1;
continue;
case 'h':
flags |= OPT_hostid;
continue;
case 'i':
continue;
case 'm':
flags |= OPT_machine;
continue;
case 'n':
flags |= OPT_nodename;
continue;
case 'o':
continue;
case 'p':
flags |= OPT_processor;
continue;
case 'r':
flags |= OPT_release;
continue;
case 's':
flags |= OPT_system;
continue;
case 't':
continue;
case 'v':
flags |= OPT_version;
continue;
case 'x':
continue;
case 'A':
continue;
case 'R':
continue;
case 'S':
continue;
case ':':
{
argv[0] = s;
}
break;
case '?':
break;
}
break;
}
if (sethost)
{
#if _lib_sethostname
#else
#ifdef ENOSYS
#else
#endif
#endif
}
else if (list)
astconflist(sfstdout, NiL, ASTCONF_base|ASTCONF_defined|ASTCONF_lower|ASTCONF_quote|ASTCONF_matchcall, "CS|SI");
else if (*argv)
{
while (s = *argv++)
{
t = buf;
*t++ = 'C';
*t++ = 'S';
*t++ = '_';
while (t < e && (n = *s++))
*t = 0;
sfprintf(sfstdout, "%s%c", *(t = astconf(buf, NiL, NiL)) ? t : *(t = astconf(buf+3, NiL, NiL)) ? t : "unknown", *argv ? ' ' : '\n');
}
}
else
{
s = buf;
if (!flags)
flags = OPT_system;
if (flags & OPT_nodename)
{
#if !_mem_nodeext_utsname && _lib_gethostname
#endif
}
if (flags & OPT_processor)
{
}
if (flags & OPT_implementation)
{
{
t++;
else
t = (char*)hosttype;
}
}
if (flags & OPT_operating_system)
{
if (!*s)
#ifdef _UNAME_os_DEFAULT
s = _UNAME_os_DEFAULT;
#else
#endif
}
if (flags & OPT_extended_release)
{
}
#else
if (flags & OPT_hostid)
{
#if _lib_gethostid
#else
/*NOP*/;
#endif
}
#endif
if (flags & OPT_vendor)
{
}
if (flags & OPT_domain)
{
getdomainname(s, sizeof(buf));
#else
/*NOP*/;
#endif
}
#else
#endif
#else
#endif
{
#endif
#endif
#endif
{
s = t = last;
while (s < (char*)(&ut + 1))
{
if (!(n = *s++))
{
if ((s - t) > 1)
{
if (sep)
else
sep = 1;
}
t = s;
}
else if (!isprint(n))
break;
}
}
}
if (sep)
}
return error_info.errors;
}