1 /* Suite version information for procps utilities
2 * Copyright (c) 1995 Martin Schulze <joey@infodrom.north.de>
3 * Ammended by cblake to only export the function symbol.
4 *
5 * Modified by Albert Cahalan
6 *
7 * Redistributable under the terms of the
8 * GNU Library General Public License; see COPYING
9 */
10 #ifdef HAVE_CONFIG_H
11 #include <config.h>
12 #endif
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include "version.h"
16
17 #ifdef MINORVERSION
18 const char procps_version[] =
19 "procps version " VERSION "." SUBVERSION "." MINORVERSION;
20 #else
21 const char procps_version[] = "procps version " VERSION "." SUBVERSION;
22 #endif
23
display_version(void)24 void display_version(void)
25 {
26 fprintf(stdout, "%s\n", procps_version);
27 }
28
29 /* Linux kernel version information for procps utilities
30 * Copyright (c) 1996 Charles Blake <cblake@bbn.com>
31 */
32 #include <sys/utsname.h>
33
34 #define LINUX_VERSION(x,y,z) (0x10000*(x) + 0x100*(y) + z)
35
36 int linux_version_code = 0;
37
38 static void init_Linux_version(void) __attribute__ ((constructor));
init_Linux_version(void)39 static void init_Linux_version(void)
40 {
41 static struct utsname uts;
42 int x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
43
44 if (linux_version_code)
45 return;
46 if (uname(&uts) == -1) /* failure implies impending death */
47 exit(1);
48 if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3)
49 fprintf(stderr, /* *very* unlikely to happen by accident */
50 "Non-standard uts for running kernel:\n"
51 "release %s=%d.%d.%d gives version code %d\n",
52 uts.release, x, y, z, LINUX_VERSION(x, y, z));
53 linux_version_code = LINUX_VERSION(x, y, z);
54 }
55