1331722Seadler/* 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 36228492Sru#include <sys/types.h> 372005Swollman#include <sys/sysctl.h> 38228492Sru 39153002Sambrisko#include <stdlib.h> 40228492Sru#include <unistd.h> 412005Swollman 422005Swollmanint 432005Swollmangetosreldate(void) 442005Swollman{ 452005Swollman int mib[2]; 462005Swollman size_t size; 472005Swollman int value; 48153002Sambrisko char *temp; 49153002Sambrisko 50211416Skib if ((temp = getenv("OSVERSION"))) { 51211416Skib value = atoi(temp); 52211416Skib return (value); 53211416Skib } 54211416Skib 552005Swollman mib[0] = CTL_KERN; 562005Swollman mib[1] = KERN_OSRELDATE; 572005Swollman size = sizeof value; 582005Swollman if (sysctl(mib, 2, &value, &size, NULL, 0) == -1) 592005Swollman return (-1); 602005Swollman return (value); 612005Swollman} 62