tizen 2.3.1 release
[external/lsof.git] / lib / ckkv.c
1 /*
2  * cvfs.c -- ckkv() function for lsof library
3  */
4
5
6 /*
7  * Copyright 1998 Purdue Research Foundation, West Lafayette, Indiana
8  * 47907.  All rights reserved.
9  *
10  * Written by Victor A. Abell
11  *
12  * This software is not subject to any license of the American Telephone
13  * and Telegraph Company or the Regents of the University of California.
14  *
15  * Permission is granted to anyone to use this software for any purpose on
16  * any computer system, and to alter it and redistribute it freely, subject
17  * to the following restrictions:
18  *
19  * 1. Neither the authors nor Purdue University are responsible for any
20  *    consequences of the use of this software.
21  *
22  * 2. The origin of this software must not be misrepresented, either by
23  *    explicit claim or by omission.  Credit to the authors and Purdue
24  *    University must appear in documentation and sources.
25  *
26  * 3. Altered versions must be plainly marked as such, and must not be
27  *    misrepresented as being the original software.
28  *
29  * 4. This notice may not be removed or altered.
30  */
31
32
33 #include "../machine.h"
34
35 #if     defined(USE_LIB_CKKV)
36
37 # if    !defined(lint)
38 static char copyright[] =
39 "@(#) Copyright 1998 Purdue Research Foundation.\nAll rights reserved.\n";
40 static char *rcsid = "$Id: ckkv.c,v 1.3 2008/10/21 16:12:36 abe Exp $";
41 # endif /* !defined(lint) */
42
43 #include "../lsof.h"
44 #include <sys/utsname.h>
45
46
47 /*
48  * ckkv() - check kernel version
49  */
50
51 void
52 ckkv(d, er, ev, ea)
53         char *d;                        /* dialect */
54         char *er;                       /* expected revision; NULL, no test */
55         char *ev;                       /* expected version; NULL, no test */
56         char *ea;                       /* expected architecture; NULL, no
57                                          * test */
58 {
59
60 # if    defined(HASKERNIDCK) 
61         struct utsname u;
62
63         if (Fwarn)
64             return;
65 /*
66  * Read the system information via uname(2).
67  */
68         if (uname(&u) < 0) {
69             (void) fprintf(stderr, "%s: uname error: %s\n",
70                 Pn, strerror(errno));
71             Exit(1);
72         }
73         if (er && strcmp(er, u.release)) {
74             (void) fprintf(stderr,
75                 "%s: WARNING: compiled for %s release %s; this is %s.\n",
76                 Pn, d, er, u.release);
77         }
78         if (ev && strcmp(ev, u.version)) {
79             (void) fprintf(stderr,
80                 "%s: WARNING: compiled for %s version %s; this is %s.\n",
81                 Pn, d, ev, u.version);
82         }
83         if (ea && strcmp(ea, u.machine)) {
84             (void) fprintf(stderr,
85                 "%s: WARNING: compiled for %s architecture %s; this is %s.\n",
86                 Pn, d, ea, u.machine);
87         }
88 # endif /* defined(HASKERNIDCK) */
89
90 }
91 #else   /* !defined(USE_LIB_CKKV) */
92 char ckkv_d1[] = "d"; char *ckkv_d2 = ckkv_d1;
93 #endif  /* defined(USE_LIB_CKKV) */