mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-17 16:10:46 +01:00
Added example of how to tell various FreeBSD versions apart.
This commit is contained in:
parent
01697c8ddb
commit
652f974539
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=2006
17
share/examples/FreeBSD_version/FreeBSD_version.c
Normal file
17
share/examples/FreeBSD_version/FreeBSD_version.c
Normal file
@ -0,0 +1,17 @@
|
||||
#if __FreeBSD__ == 0 /* 1.0 did not define __FreeBSD__ */
|
||||
#define __FreeBSD_version 199401
|
||||
#elif __FreeBSD__ == 1 /* 1.1 defined it to be 1 */
|
||||
#define __FreeBSD_version 199405
|
||||
#else /* 2.0 and higher define it to be 2 */
|
||||
#include <osreldate.h> /* and this works */
|
||||
#endif
|
||||
|
||||
int main(void) {
|
||||
extern int getosreldate(void);
|
||||
printf("Compilation release date: %d\n", __FreeBSD_version);
|
||||
#if __FreeBSD_version >= 199408
|
||||
printf("Execution environment release date: %d\n", getosreldate());
|
||||
#else
|
||||
printf("Execution environment release date: can't tell\n");
|
||||
#endif
|
||||
}
|
8
share/examples/FreeBSD_version/Makefile
Normal file
8
share/examples/FreeBSD_version/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
# $Id$
|
||||
|
||||
PROG= FreeBSD_version
|
||||
NOMAN=
|
||||
|
||||
install:
|
||||
|
||||
.include <bsd.prog.mk>
|
4
share/examples/FreeBSD_version/README
Normal file
4
share/examples/FreeBSD_version/README
Normal file
@ -0,0 +1,4 @@
|
||||
This is an example of how to determine the version of FreeBSD that
|
||||
a program was compiled on, and maybe running on (if 2.0 or better).
|
||||
|
||||
This program is in the public domain.
|
@ -1,10 +1,10 @@
|
||||
# $Id$
|
||||
# $Id: Makefile,v 1.1 1994/08/09 18:25:36 wollman Exp $
|
||||
#
|
||||
# Doing a make install builds /usr/share/examples
|
||||
#
|
||||
all clean cleandir depend lint tags:
|
||||
|
||||
DIRS=sunrpc etc
|
||||
DIRS=sunrpc etc FreeBSD_version
|
||||
|
||||
# Define SHARED to indicate whether you want symbolic links to the system
|
||||
# source (``symlinks''), or a separate copy (``copies''); (latter useful
|
||||
|
Loading…
Reference in New Issue
Block a user