[12029] | 1 | /* |
---|
| 2 | * Machtype: determine machine type & display type |
---|
| 3 | * |
---|
| 4 | * RCS Info |
---|
[12350] | 5 | * $Id: machtype.c,v 1.2 1999-01-22 23:11:35 ghudson Exp $ |
---|
[12029] | 6 | */ |
---|
| 7 | |
---|
| 8 | #include <stdio.h> |
---|
| 9 | #include <string.h> |
---|
| 10 | #include "machtype.h" |
---|
| 11 | |
---|
| 12 | extern char *optarg; |
---|
| 13 | extern int optind; |
---|
| 14 | |
---|
| 15 | void usage(char *name); |
---|
| 16 | |
---|
| 17 | int main(int argc, char *argv[]) |
---|
| 18 | { |
---|
| 19 | int i; |
---|
| 20 | int cpuflg = 0, dpyflg = 0, raflg = 0, memflg = 0; |
---|
| 21 | int doathenaV = 0; |
---|
| 22 | int dosyspV = 0; |
---|
| 23 | int dolocalV = 0; |
---|
| 24 | int dobosN = 0; |
---|
| 25 | int dobosV = 0; |
---|
| 26 | int dosysnam = 0; |
---|
| 27 | int dosyscompatnam = 0; |
---|
| 28 | int verbose = 0; |
---|
| 29 | FILE *f; |
---|
| 30 | char *progname, *cp; |
---|
| 31 | |
---|
| 32 | progname = argv[0]; |
---|
| 33 | cp = strrchr(progname, '/'); |
---|
| 34 | if (cp != NULL) |
---|
| 35 | progname = cp+1; |
---|
| 36 | |
---|
| 37 | while ((i = getopt(argc, argv, "cdrMALPNESCv")) != EOF) |
---|
| 38 | { |
---|
| 39 | switch (i) |
---|
| 40 | { |
---|
| 41 | case 'c': |
---|
| 42 | cpuflg = 1; |
---|
| 43 | break; |
---|
| 44 | case 'd': |
---|
| 45 | dpyflg = 1; |
---|
| 46 | break; |
---|
| 47 | case 'r': |
---|
| 48 | raflg = 1; |
---|
| 49 | break; |
---|
| 50 | case 'M': |
---|
| 51 | memflg = 1; |
---|
| 52 | break; |
---|
| 53 | case 'A': |
---|
| 54 | doathenaV = 1; |
---|
| 55 | break; |
---|
| 56 | case 'L': |
---|
| 57 | dolocalV = 1; |
---|
| 58 | break; |
---|
| 59 | case 'P': |
---|
| 60 | dosyspV = 1; |
---|
| 61 | break; |
---|
| 62 | case 'N': |
---|
| 63 | dobosN = 1; |
---|
| 64 | break; |
---|
| 65 | case 'E': |
---|
| 66 | dobosV = 1; |
---|
| 67 | break; |
---|
| 68 | case 'S': |
---|
| 69 | dosysnam = 1; |
---|
| 70 | break; |
---|
| 71 | case 'C': |
---|
| 72 | dosyscompatnam = 1; |
---|
| 73 | break; |
---|
| 74 | case 'v': |
---|
| 75 | verbose++; |
---|
| 76 | break; |
---|
| 77 | default: |
---|
| 78 | usage(progname); |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | if (argv[optind] != NULL) |
---|
| 82 | usage(progname); |
---|
| 83 | |
---|
| 84 | if (!(cpuflg || dpyflg || raflg || memflg || doathenaV || dolocalV || |
---|
| 85 | dosyspV || dobosN || dobosV || dosysnam || dosyscompatnam)) |
---|
| 86 | { |
---|
| 87 | do_machtype(); |
---|
| 88 | exit(0); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | /* Print out version of Athena machtype compiled against */ |
---|
| 92 | if (doathenaV) |
---|
| 93 | { |
---|
| 94 | if (verbose) |
---|
| 95 | fputs("Machtype version: ", stdout); |
---|
| 96 | printf("%s.%s\n", ATHMAJV, ATHMINV); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | /* Print out version of attached packs */ |
---|
| 100 | if (dosyspV) |
---|
| 101 | { |
---|
| 102 | char buf[256], *rvd_version, *p; |
---|
| 103 | if ((f = fopen("/srvd/.rvdinfo","r")) == NULL) |
---|
| 104 | puts("Syspack information unavailable."); |
---|
| 105 | else |
---|
| 106 | { |
---|
| 107 | fgets(buf, sizeof(buf), f); |
---|
| 108 | fclose(f); |
---|
| 109 | /* If it is verbose, give the whole line, else just the vers # */ |
---|
| 110 | if (verbose) |
---|
| 111 | fputs(buf, stdout); |
---|
| 112 | else |
---|
| 113 | { |
---|
| 114 | p = strchr(buf,' '); /* skip "Athena" */ |
---|
| 115 | p = strchr(p+1,' '); /* skip "RVD" */ |
---|
| 116 | p = strchr(p+1,' '); /* Skip machtype */ |
---|
| 117 | p = strchr(p+1,' '); /* skip "version" */ |
---|
| 118 | rvd_version = p+1; |
---|
| 119 | p = strchr(rvd_version,' '); |
---|
| 120 | *p = '\0'; |
---|
| 121 | puts(rvd_version); |
---|
| 122 | } |
---|
| 123 | } |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | /* Print out local version from /etc/athena/version */ |
---|
| 127 | if (dolocalV) |
---|
| 128 | { |
---|
| 129 | char buf[256], *loc_version, *p; |
---|
| 130 | if ((f = fopen("/etc/athena/version","r")) == NULL) |
---|
| 131 | puts("Local version information unavailable."); |
---|
| 132 | else |
---|
| 133 | { |
---|
| 134 | while (fgets(buf, sizeof(buf), f) != NULL) |
---|
| 135 | ; |
---|
| 136 | fclose(f); |
---|
| 137 | if (verbose) |
---|
| 138 | fputs(buf, stdout); |
---|
| 139 | else |
---|
| 140 | { |
---|
| 141 | p = strchr(buf,' '); /* skip "Athena" */ |
---|
| 142 | p = strchr(p+1,' '); /* skip "Workstation/Server" */ |
---|
| 143 | p = strchr(p+1,' '); /* Skip machtype */ |
---|
| 144 | p = strchr(p+1,' '); /* skip "version" */ |
---|
| 145 | loc_version = p+1; |
---|
| 146 | p = strchr(loc_version,' '); |
---|
| 147 | *p = '\0'; |
---|
| 148 | puts(loc_version); |
---|
| 149 | } |
---|
| 150 | } |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | /* Print out vendor OS name */ |
---|
| 154 | if (dobosN) |
---|
| 155 | if (verbose) |
---|
| 156 | puts(OSNAME " " OSVERS); |
---|
| 157 | else |
---|
| 158 | puts(OSNAME); |
---|
| 159 | |
---|
| 160 | /* Print out vendor OS version */ |
---|
| 161 | if (dobosV) |
---|
| 162 | puts(OSVERS); |
---|
| 163 | |
---|
| 164 | /* Print out Athena System name */ |
---|
| 165 | if (dosysnam) |
---|
| 166 | puts(ATHSYS); |
---|
| 167 | |
---|
| 168 | /* Print out compatible Athena System names */ |
---|
| 169 | if (dosyscompatnam) |
---|
| 170 | puts(ATHSYSCOMPAT); |
---|
| 171 | |
---|
| 172 | if (cpuflg) |
---|
| 173 | do_cpu(verbose); |
---|
| 174 | if (dpyflg) |
---|
| 175 | do_dpy(verbose); |
---|
| 176 | if (raflg) |
---|
| 177 | do_disk(verbose); |
---|
| 178 | if (memflg) |
---|
| 179 | do_memory(verbose); |
---|
| 180 | exit(0); |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | void usage(char *name) |
---|
| 184 | { |
---|
| 185 | fprintf(stderr, "usage: %s [-v] [-c] [-d] [-r] [-E] [-N] [-M]\n", name); |
---|
| 186 | fprintf(stderr, " [-A] [-L] [-P] [-S] [-C]\n"); |
---|
| 187 | exit(1); |
---|
| 188 | } |
---|