Updated with Tizen:Base source codes
[external/procps.git] / proc / version.c
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, ????-2003
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[] = "procps version " VERSION "." SUBVERSION "." MINORVERSION;
19 #else
20 const char procps_version[] = "procps version " VERSION "." SUBVERSION;
21 #endif
22
23 void display_version(void) {
24     fprintf(stdout, "%s\n", procps_version);
25 }
26
27 /* Linux kernel version information for procps utilities
28  * Copyright (c) 1996 Charles Blake <cblake@bbn.com>
29  */
30 #include <sys/utsname.h>
31
32 #define LINUX_VERSION(x,y,z)   (0x10000*(x) + 0x100*(y) + z)
33
34 int linux_version_code;
35
36 static void init_Linux_version(void) __attribute__((constructor));
37 static void init_Linux_version(void) {
38     static struct utsname uts;
39     int x = 0, y = 0, z = 0;    /* cleared in case sscanf() < 3 */
40     
41     if (uname(&uts) == -1)      /* failure implies impending death */
42         exit(1);
43     if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3)
44         fprintf(stderr,         /* *very* unlikely to happen by accident */
45                 "Non-standard uts for running kernel:\n"
46                 "release %s=%d.%d.%d gives version code %d\n",
47                 uts.release, x, y, z, LINUX_VERSION(x,y,z));
48     linux_version_code = LINUX_VERSION(x, y, z);
49 }