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