12005Swollman/* 22005Swollman * Copyright (c) 1989, 1993 32005Swollman * The Regents of the University of California. All rights reserved. 42005Swollman * 52005Swollman * Redistribution and use in source and binary forms, with or without 62005Swollman * modification, are permitted provided that the following conditions 72005Swollman * are met: 82005Swollman * 1. Redistributions of source code must retain the above copyright 92005Swollman * notice, this list of conditions and the following disclaimer. 102005Swollman * 2. Redistributions in binary form must reproduce the above copyright 112005Swollman * notice, this list of conditions and the following disclaimer in the 122005Swollman * documentation and/or other materials provided with the distribution. 132005Swollman * 4. Neither the name of the University nor the names of its contributors 142005Swollman * may be used to endorse or promote products derived from this software 152005Swollman * without specific prior written permission. 162005Swollman * 172005Swollman * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 182005Swollman * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 192005Swollman * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 202005Swollman * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 212005Swollman * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 222005Swollman * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 232005Swollman * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 242005Swollman * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 252005Swollman * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 262005Swollman * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 272005Swollman * SUCH DAMAGE. 282005Swollman */ 292005Swollman 302005Swollman#if defined(LIBC_SCCS) && !defined(lint) 312005Swollmanstatic char sccsid[] = "@(#)gethostid.c 8.1 (Berkeley) 6/2/93"; 322005Swollman#endif /* LIBC_SCCS and not lint */ 3390039Sobrien#include <sys/cdefs.h> 3490039Sobrien__FBSDID("$FreeBSD$"); 352005Swollman 362005Swollman#include <sys/param.h> 372005Swollman#include <sys/sysctl.h> 38211416Skib#include <errno.h> 39153002Sambrisko#include <stdlib.h> 402005Swollman 41150065Sstefanf#include <osreldate.h> 42150065Sstefanf 432005Swollmanint 442005Swollmangetosreldate(void) 452005Swollman{ 462005Swollman int mib[2]; 472005Swollman size_t size; 482005Swollman int value; 49153002Sambrisko char *temp; 50153002Sambrisko 51211416Skib if ((temp = getenv("OSVERSION"))) { 52211416Skib value = atoi(temp); 53211416Skib return (value); 54211416Skib } 55211416Skib 562005Swollman mib[0] = CTL_KERN; 572005Swollman mib[1] = KERN_OSRELDATE; 582005Swollman size = sizeof value; 592005Swollman if (sysctl(mib, 2, &value, &size, NULL, 0) == -1) 602005Swollman return (-1); 612005Swollman return (value); 622005Swollman} 63