home *** CD-ROM | disk | FTP | other *** search
- /*
- * UNAME.C
- *
- * uname [-amnprsv]
- *
- * List various information about the system
- *
- * a: all information
- * m: machine hardware name
- * n: nodename
- * p: processor type
- * r: operating system release
- * s: name of the operation system
- * v: operating system version
- *
- * -n is the default.
- *
- * Copyright 1993 by Michael B. Smith. All rights reserved.
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "version.h"
- #include "protos.h"
-
- #include <graphics/gfxbase.h>
-
- struct GfxBase
- *g = NULL;
-
- IDENT (".01");
-
- void usage (const char *name);
-
- void
- usage (const char *name)
- {
- fprintf (stderr, "usage: %s [-amnprsv]\n", name);
- exit (30);
- }
-
- void
- m_opt (void)
- {
- if (!g) {
- printf ("Amiga");
- }
- else {
- ULONG
- r = g->ChipRevBits0;
-
- if ((r & GFXF_AA_LISA) || (r & GFXF_AA_ALICE) || (r & GFXF_AA_MLISA))
- printf ("Amiga/AGA");
- else
- if ((r & GFXF_HR_DENISE) && (r & GFXF_HR_AGNUS))
- printf ("Amiga/ECS");
- else
- if (r & GFXF_HR_DENISE)
- printf ("Amiga/ECS_Denise");
- else
- if (r & GFXF_HR_AGNUS)
- printf ("Amiga/ECS_Agnus");
- else
- printf ("Amiga/OCS");
- }
-
- printf (" ");
- return;
- }
-
- void
- n_opt (void)
- {
- char
- *p;
-
- mountrequest (0);
- p = FindConfig (NODENAME);
- mountrequest (1);
-
- if (!p)
- printf ("<unknown_nodename>");
- else
- printf (p);
-
- printf (" ");
- return;
- }
-
- void
- p_opt (void)
- {
- ULONG
- flag = SysBase->AttnFlags;
-
- printf ("m68");
- if (flag & AFF_68040)
- printf ("040");
- else
- if (flag & AFF_68030)
- printf ("030");
- else
- if (flag & AFF_68020)
- printf ("020");
- else
- if (flag & AFF_68010)
- printf ("010");
- else
- printf ("000");
-
- printf (" ");
- return;
- }
-
- void
- r_opt (void)
- {
- int
- ver = SysBase->LibNode.lib_Version;
-
- switch (ver) {
- case 33:
- printf ("1.2");
- break;
- case 34:
- case 35:
- printf ("1.3");
- break;
- case 36:
- printf ("2.01");
- break;
- case 37:
- printf ("2.04");
- break;
- case 38:
- printf ("2.1");
- break;
- case 39:
- printf ("3.0");
- break;
- case 40:
- printf ("3.1");
- break;
- default:
- printf ("V%ld", ver);
- break;
- }
- printf (" ");
- return;
- }
-
- void
- s_opt (void)
- {
- printf ("AmigaOS ");
- return;
- }
-
- void
- v_opt (void)
- {
- int
- ver = SysBase->LibNode.lib_Version,
- rev = SysBase->SoftVer;
- /*rev = SysBase->LibNode.lib_Revision;*/
-
- printf ("%ld.%ld ", ver, rev);
- return;
- }
-
- int
- main (int argc, char **argv)
- {
- char
- *nm = argv [0],
- *p;
- int
- i,
- got_opt = 0,
- opt_a = 0,
- opt_m = 0,
- opt_n = 0,
- opt_p = 0,
- opt_r = 0,
- opt_s = 0,
- opt_v = 0;
-
-
- for (i = 1; i < argc; i++) {
- got_opt = 1;
- p = argv [i];
- if (*p != '-')
- usage (nm);
- p++;
- switch (*p) {
- case 'a':
- opt_a = 1;
- break;
- case 'm':
- opt_m = 1;
- break;
- case 'n':
- opt_n = 1;
- break;
- case 'p':
- opt_p = 1;
- break;
- case 'r':
- opt_r = 1;
- break;
- case 's':
- opt_s = 1;
- break;
- case 'v':
- opt_v = 1;
- break;
- default:
- usage (nm);
- }
- }
-
- if (got_opt == 0)
- opt_n = 1;
-
- if (opt_a)
- opt_m = opt_n = opt_p = opt_r = opt_s = opt_v = 1;
-
- g = (struct GfxBase *) OpenLibrary ("graphics.library", 0);
-
- if (opt_s)
- s_opt ();
- if (opt_n)
- n_opt ();
- if (opt_r)
- r_opt ();
- if (opt_v)
- v_opt ();
- if (opt_m)
- m_opt ();
- if (opt_p)
- p_opt ();
-
- printf ("\n");
-
- if (g)
- CloseLibrary ((struct Library *) g);
-
- exit (0);
- }
-