home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / sysinfo-1.0 / part01 / os-aix.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-10  |  2.5 KB  |  136 lines

  1. /*
  2.  * Copyright (c) 1992 Michael A. Cooper.
  3.  * This software may be freely distributed provided it is not sold for 
  4.  * profit and the author is credited appropriately.
  5.  */
  6.  
  7. #ifndef lint
  8. static char *RCSid = "$Header: /src/common/usc/bin/sysinfo/RCS/os-aix.c,v 1.5 1992/04/26 23:32:06 mcooper Exp $";
  9. #endif
  10.  
  11. /*
  12.  * $Log: os-aix.c,v $
  13.  * Revision 1.5  1992/04/26  23:32:06  mcooper
  14.  * Add Copyright notice
  15.  *
  16.  * Revision 1.4  1992/04/17  23:27:51  mcooper
  17.  * Add support for ROM Version information (Sun only for now).
  18.  *
  19.  * Revision 1.3  1992/04/17  01:07:59  mcooper
  20.  * More de-linting
  21.  *
  22.  * Revision 1.2  1992/04/15  02:04:16  mcooper
  23.  * Change GetMemoryStr() to GetMemory().
  24.  *
  25.  * Revision 1.1  1992/03/28  23:57:38  mcooper
  26.  * Initial revision
  27.  *
  28.  */
  29.  
  30.  
  31. /*
  32.  * AIX specific functions
  33.  */
  34.  
  35. #include <stdio.h>
  36. #include "system.h"
  37. #include "defs.h"
  38.  
  39. #include <sys/utsname.h>
  40.  
  41. /*
  42.  * Get the system model name.
  43.  */
  44. extern char *GetModelName()
  45. {
  46.     extern NAMETAB        ModelTab[];
  47.     struct utsname        utsname;
  48.     register int        i, type;
  49.     register char           *p;
  50.  
  51.     if (uname(&utsname) == SYSFAIL) {
  52.     if (Debug) Error("uname() failed: %s.", SYSERR);
  53.     return((char *) NULL);
  54.     }
  55.  
  56.     /*
  57.      * XXX HARDCODED value
  58.      *
  59.      * The following assumes that utsname.machine is of format
  60.      *
  61.      *    xxyyyyyyMMss
  62.      *
  63.      *        xx      = 00 (always)
  64.      *        yyyyyy    = unique CPU ID
  65.      *        MM    = model number
  66.      *        ss    = 00 (always)
  67.      */
  68.     if (strlen(utsname.machine) != 12) {
  69.     if (Debug) Error("The format of utsname.machine has changed!");
  70.     return((char *) NULL);
  71.     }
  72.     p = utsname.machine;
  73.     p += 8;
  74.     if (strlen(p) > 2)
  75.     *(p+2) = (char)NULL;
  76.  
  77.     for (i = 0; ModelTab[i].name; ++i)
  78.     if (EQ(p, ModelTab[i].valuestr))
  79.         return(ModelTab[i].name);
  80.  
  81.     if (Debug)
  82.     Error("system model/type %s is unknown.\n", p);
  83.  
  84.     return((char *) NULL);
  85. }
  86.  
  87. /*
  88.  * Get kernel version string from kernel symbol "version".
  89.  */
  90. extern char *GetKernelVersionStr()
  91. {
  92.     return(GetKernelVersionFromVersion());
  93. }
  94.  
  95. /*
  96.  * Get amount of physical memory using kernel symbol "physmem".
  97.  */
  98. extern char *GetMemory()
  99. {
  100.     return(GetMemoryFromPhysmem());
  101. }
  102.  
  103. /*
  104.  * Get system serial number
  105.  */
  106. extern char *GetSerialNoStr()
  107. {
  108.     /* No support */
  109.     return((char *) NULL);
  110. }
  111.  
  112. /*
  113.  * Get name of OS
  114.  */
  115. extern char *GetOSNameStr()
  116. {
  117.     return(GetOSNameFromUname());
  118. }
  119.  
  120. /*
  121.  * Get version of OS
  122.  */
  123. extern char *GetOSVersionStr()
  124. {
  125.     return(GetOSVersionFromUname());
  126. }
  127.  
  128. /*
  129.  * Get ROM Version
  130.  */
  131. extern char *GetRomVer()
  132. {
  133.     /* No support */
  134.     return((char *) NULL);
  135. }
  136.