home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / EFFO / forum16.lzh / SOFTWARE / C / VERSION / oskversion.c < prev    next >
C/C++ Source or Header  |  1991-01-06  |  3KB  |  99 lines

  1. /* ------------------------------------------------------------------- *
  2.  |
  3.  | OS9Lib:  osk_version()
  4.  |
  5.  |
  6.  |     Copyright (c) 1990 by Wolfgang Ocker, Puchheim
  7.  |                           (W-Germany)
  8.  |
  9.  |  This  program  can  be  copied and  distributed freely  for any
  10.  |  non-commercial  purposes.   It can only  be  incorporated  into
  11.  |  commercial software with the written permission of the author.
  12.  |
  13.  |  If you should modify this program, the author  would appreciate
  14.  |  a notice about the changes. Please send a (context) diff or the
  15.  |  complete source to:
  16.  |
  17.  |  address:     reccoware systems
  18.  |               Wolfgang Ocker
  19.  |               Lochhauser Strasse 35a
  20.  |               D-8039 Puchheim
  21.  |               West Germany
  22.  |
  23.  |  e-mail:      weo@chi.sub.org
  24.  |
  25.  * ----------------------------------------------------------------- */
  26.  
  27. #include <stdio.h>
  28. #include <module.h>
  29. #include <setsys.h>
  30. #include <strings.h>
  31. #include "oskversion.h"
  32.  
  33. static struct oskversion v;
  34.  
  35. /*
  36.  * o s k _ v e r s i o n
  37.  *
  38.  * Return version information of OSK
  39.  */
  40. int osk_version(version)
  41.   register struct oskversion *version;
  42. {
  43.   register mod_config *mod;
  44.  
  45.   if ((mod = (mod_config *) modlink("init", mktypelang(MT_SYSTEM, ML_ANY))) ==
  46.       (mod_config *) -1)                /* yep, this tells us the manual! */
  47.     return(-1);                         /* error */
  48.  
  49.   version->level    = mod->_mos9lvl[0];
  50.   version->version  = mod->_mos9lvl[1];
  51.   version->revision = mod->_mos9lvl[2];
  52.   version->edition  = mod->_mos9lvl[3];
  53.  
  54.   version->cpu      = mod->_mcputyp;          /* CPU type of init module */
  55.   version->cpu_run  = _getsys(D_MPUType, sizeof(long));      /* real CPU */
  56.   
  57.   (void) strncpy(version->mainframe, ((char *) mod) + mod->_minstal, 64);
  58.   version->mainframe[63] = '\0';
  59.  
  60.   (void) strncpy(version->os9rev, ((char *) mod) + mod->_mos9rev, 64);
  61.   version->os9rev[63] = '\0';
  62.  
  63.   (void) munlink(mod);
  64.  
  65.   return(0);
  66. }
  67.  
  68.  
  69. /* `Patch` Tyko: */
  70.  
  71. main(argc,argv)
  72. int argc;
  73. char **argv;
  74. {
  75.     if (argc > 1) {
  76.         printf("Syntax:   OSKversion\n");
  77.         printf("Function: prints some useful informations ");
  78.         printf("about the operating system.\n");
  79.         printf("Options:  none\n");
  80.         exit(0);
  81.     }
  82.  
  83.     if (osk_version(&v) != 0) {
  84.         printf("Error due to manual ...\n");
  85.         exit(1);
  86.     }
  87.     printf("OSK level : %d\n",v.level);
  88.     printf("OSK version : %d\n",v.version);
  89.     printf("Revision : %d\n",v.revision);
  90.     printf("Edition : %d\n",v.edition);
  91.     printf("CPU type (from init module) : %d\n",v.cpu);
  92.     printf("CPU type (real CPU, from system globals) : %d\n",v.cpu_run);
  93.     printf("Mainframe : %s\n",v.mainframe);
  94.     printf("OS9 revision string : %s\n",v.os9rev);
  95. }
  96.  
  97.  
  98.  
  99.