ftime.c revision 1581
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 321581Srgrimesstatic char rcsid[] = "$Id: ftime.c,v 1.3 1994/05/06 06:42:21 cgd Exp $"; 331581Srgrimes#endif /* not lint */ 341581Srgrimes 351581Srgrimes#include <sys/types.h> 361581Srgrimes#include <sys/time.h> 371581Srgrimes#include <sys/timeb.h> 381581Srgrimes 391581Srgrimesftime(tbp) 401581Srgrimes struct timeb *tbp; 411581Srgrimes{ 421581Srgrimes struct timezone tz; 431581Srgrimes struct timeval t; 441581Srgrimes 451581Srgrimes if (gettimeofday(&t, &tz) < 0) 461581Srgrimes return (-1); 471581Srgrimes tbp->millitm = t.tv_usec / 1000; 481581Srgrimes tbp->time = t.tv_sec; 491581Srgrimes tbp->timezone = tz.tz_minuteswest; 501581Srgrimes tbp->dstflag = tz.tz_dsttime; 511581Srgrimes 521581Srgrimes return (0); 531581Srgrimes} 54