ftime.c revision 50476
11581Srgrimes/* 21581Srgrimes * Copyright (c) 1994 Christopher G. Demetriou 31581Srgrimes * All rights reserved. 41581Srgrimes * 51581Srgrimes * Redistribution and use in source and binary forms, with or without 61581Srgrimes * modification, are permitted provided that the following conditions 71581Srgrimes * are met: 81581Srgrimes * 1. Redistributions of source code must retain the above copyright 91581Srgrimes * notice, this list of conditions and the following disclaimer. 101581Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111581Srgrimes * notice, this list of conditions and the following disclaimer in the 121581Srgrimes * documentation and/or other materials provided with the distribution. 131581Srgrimes * 3. All advertising materials mentioning features or use of this software 141581Srgrimes * must display the following acknowledgement: 151581Srgrimes * This product includes software developed by Christopher G. Demetriou. 161581Srgrimes * 4. The name of the author may not be used to endorse or promote products 171581Srgrimes * derived from this software without specific prior written permission 181581Srgrimes * 191581Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 201581Srgrimes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 211581Srgrimes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 221581Srgrimes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 231581Srgrimes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 241581Srgrimes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 251581Srgrimes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 261581Srgrimes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 271581Srgrimes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 281581Srgrimes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 291581Srgrimes */ 301581Srgrimes 311581Srgrimes#ifndef lint 3250476Speterstatic char rcsid[] = "$FreeBSD: head/lib/libcompat/4.1/ftime.c 50476 1999-08-28 00:22:10Z peter $"; 331581Srgrimes#endif /* not lint */ 341581Srgrimes 351581Srgrimes#include <sys/types.h> 361581Srgrimes#include <sys/time.h> 371581Srgrimes#include <sys/timeb.h> 381581Srgrimes 3917141Sjkhint 401581Srgrimesftime(tbp) 411581Srgrimes struct timeb *tbp; 421581Srgrimes{ 431581Srgrimes struct timezone tz; 441581Srgrimes struct timeval t; 451581Srgrimes 461581Srgrimes if (gettimeofday(&t, &tz) < 0) 471581Srgrimes return (-1); 481581Srgrimes tbp->millitm = t.tv_usec / 1000; 491581Srgrimes tbp->time = t.tv_sec; 501581Srgrimes tbp->timezone = tz.tz_minuteswest; 511581Srgrimes tbp->dstflag = tz.tz_dsttime; 521581Srgrimes 531581Srgrimes return (0); 541581Srgrimes} 55