uname.c (937d37fc6c80b2171091fc773eb40bab53d84648) uname.c (fb9a985516b495b6713cda4951a58a721d99df71)
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 2002 Juli Mallett.
5 * Copyright (c) 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 53 unchanged lines hidden (view full) ---

62#define NFLAG 0x02
63#define PFLAG 0x04
64#define RFLAG 0x08
65#define SFLAG 0x10
66#define VFLAG 0x20
67#define IFLAG 0x40
68#define UFLAG 0x80
69#define KFLAG 0x100
1/*-
2 * SPDX-License-Identifier: BSD-4-Clause
3 *
4 * Copyright (c) 2002 Juli Mallett.
5 * Copyright (c) 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 53 unchanged lines hidden (view full) ---

62#define NFLAG 0x02
63#define PFLAG 0x04
64#define RFLAG 0x08
65#define SFLAG 0x10
66#define VFLAG 0x20
67#define IFLAG 0x40
68#define UFLAG 0x80
69#define KFLAG 0x100
70#define BFLAG 0x200
70
71typedef void (*get_t)(void);
71
72typedef void (*get_t)(void);
72static get_t get_ident, get_platform, get_hostname, get_arch,
73static get_t get_buildid, get_ident, get_platform, get_hostname, get_arch,
73 get_release, get_sysname, get_kernvers, get_uservers, get_version;
74
75static void native_ident(void);
76static void native_platform(void);
77static void native_hostname(void);
78static void native_arch(void);
79static void native_release(void);
80static void native_sysname(void);
81static void native_version(void);
82static void native_kernvers(void);
83static void native_uservers(void);
74 get_release, get_sysname, get_kernvers, get_uservers, get_version;
75
76static void native_ident(void);
77static void native_platform(void);
78static void native_hostname(void);
79static void native_arch(void);
80static void native_release(void);
81static void native_sysname(void);
82static void native_version(void);
83static void native_kernvers(void);
84static void native_uservers(void);
85static void native_buildid(void);
84static void print_uname(u_int);
85static void setup_get(void);
86static void usage(void);
87
86static void print_uname(u_int);
87static void setup_get(void);
88static void usage(void);
89
88static char *ident, *platform, *hostname, *arch, *release, *sysname, *version, *kernvers, *uservers;
90static char *buildid, *ident, *platform, *hostname, *arch, *release, *sysname,
91 *version, *kernvers, *uservers;
89static int space;
90
91int
92main(int argc, char *argv[])
93{
94 u_int flags;
95 int ch;
96
97 setup_get();
98 flags = 0;
99
92static int space;
93
94int
95main(int argc, char *argv[])
96{
97 u_int flags;
98 int ch;
99
100 setup_get();
101 flags = 0;
102
100 while ((ch = getopt(argc, argv, "aiKmnoprsUv")) != -1)
103 while ((ch = getopt(argc, argv, "abiKmnoprsUv")) != -1)
101 switch(ch) {
102 case 'a':
103 flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG);
104 break;
104 switch(ch) {
105 case 'a':
106 flags |= (MFLAG | NFLAG | RFLAG | SFLAG | VFLAG);
107 break;
108 case 'b':
109 flags |= BFLAG;
110 break;
105 case 'i':
106 flags |= IFLAG;
107 break;
108 case 'K':
109 flags |= KFLAG;
110 break;
111 case 'm':
112 flags |= MFLAG;

--- 51 unchanged lines hidden (view full) ---

164 CHECK_ENV("n", hostname);
165 CHECK_ENV("r", release);
166 CHECK_ENV("v", version);
167 CHECK_ENV("m", platform);
168 CHECK_ENV("p", arch);
169 CHECK_ENV("i", ident);
170 CHECK_ENV("K", kernvers);
171 CHECK_ENV("U", uservers);
111 case 'i':
112 flags |= IFLAG;
113 break;
114 case 'K':
115 flags |= KFLAG;
116 break;
117 case 'm':
118 flags |= MFLAG;

--- 51 unchanged lines hidden (view full) ---

170 CHECK_ENV("n", hostname);
171 CHECK_ENV("r", release);
172 CHECK_ENV("v", version);
173 CHECK_ENV("m", platform);
174 CHECK_ENV("p", arch);
175 CHECK_ENV("i", ident);
176 CHECK_ENV("K", kernvers);
177 CHECK_ENV("U", uservers);
178 CHECK_ENV("b", buildid);
172}
173
174#define PRINT_FLAG(flags,flag,var) \
175 if ((flags & flag) == flag) { \
176 if (space) \
177 printf(" "); \
178 else \
179 space++; \

--- 9 unchanged lines hidden (view full) ---

189 PRINT_FLAG(flags, NFLAG, hostname);
190 PRINT_FLAG(flags, RFLAG, release);
191 PRINT_FLAG(flags, VFLAG, version);
192 PRINT_FLAG(flags, MFLAG, platform);
193 PRINT_FLAG(flags, PFLAG, arch);
194 PRINT_FLAG(flags, IFLAG, ident);
195 PRINT_FLAG(flags, KFLAG, kernvers);
196 PRINT_FLAG(flags, UFLAG, uservers);
179}
180
181#define PRINT_FLAG(flags,flag,var) \
182 if ((flags & flag) == flag) { \
183 if (space) \
184 printf(" "); \
185 else \
186 space++; \

--- 9 unchanged lines hidden (view full) ---

196 PRINT_FLAG(flags, NFLAG, hostname);
197 PRINT_FLAG(flags, RFLAG, release);
198 PRINT_FLAG(flags, VFLAG, version);
199 PRINT_FLAG(flags, MFLAG, platform);
200 PRINT_FLAG(flags, PFLAG, arch);
201 PRINT_FLAG(flags, IFLAG, ident);
202 PRINT_FLAG(flags, KFLAG, kernvers);
203 PRINT_FLAG(flags, UFLAG, uservers);
204 PRINT_FLAG(flags, BFLAG, buildid);
197 printf("\n");
198}
199
200#define NATIVE_SYSCTL2_GET(var,mib0,mib1) \
201static void \
202native_##var(void) \
203{ \
204 int mib[] = { (mib0), (mib1) }; \

--- 51 unchanged lines hidden (view full) ---

256} NATIVE_SET;
257
258NATIVE_SYSCTL2_GET(arch, CTL_HW, HW_MACHINE_ARCH) {
259} NATIVE_SET;
260
261NATIVE_SYSCTLNAME_GET(ident, "kern.ident") {
262} NATIVE_SET;
263
205 printf("\n");
206}
207
208#define NATIVE_SYSCTL2_GET(var,mib0,mib1) \
209static void \
210native_##var(void) \
211{ \
212 int mib[] = { (mib0), (mib1) }; \

--- 51 unchanged lines hidden (view full) ---

264} NATIVE_SET;
265
266NATIVE_SYSCTL2_GET(arch, CTL_HW, HW_MACHINE_ARCH) {
267} NATIVE_SET;
268
269NATIVE_SYSCTLNAME_GET(ident, "kern.ident") {
270} NATIVE_SET;
271
272NATIVE_SYSCTLNAME_GET(buildid, "kern.build_id") {
273} NATIVE_SET;
274
264static void
265native_uservers(void)
266{
267 static char buf[128];
268
269 snprintf(buf, sizeof(buf), "%d", __FreeBSD_version);
270 uservers = buf;
271}

--- 5 unchanged lines hidden (view full) ---

277
278 snprintf(buf, sizeof(buf), "%d", getosreldate());
279 kernvers = buf;
280}
281
282static void
283usage(void)
284{
275static void
276native_uservers(void)
277{
278 static char buf[128];
279
280 snprintf(buf, sizeof(buf), "%d", __FreeBSD_version);
281 uservers = buf;
282}

--- 5 unchanged lines hidden (view full) ---

288
289 snprintf(buf, sizeof(buf), "%d", getosreldate());
290 kernvers = buf;
291}
292
293static void
294usage(void)
295{
285 fprintf(stderr, "usage: uname [-aiKmnoprsUv]\n");
296 fprintf(stderr, "usage: uname [-abiKmnoprsUv]\n");
286 exit(1);
287}
297 exit(1);
298}