ftime.c revision 50476
148905Srnordier/* 248905Srnordier * Copyright (c) 1994 Christopher G. Demetriou 348905Srnordier * All rights reserved. 448905Srnordier * 548905Srnordier * Redistribution and use in source and binary forms, with or without 648905Srnordier * modification, are permitted provided that the following conditions 748905Srnordier * are met: 848905Srnordier * 1. Redistributions of source code must retain the above copyright 948905Srnordier * notice, this list of conditions and the following disclaimer. 1048905Srnordier * 2. Redistributions in binary form must reproduce the above copyright 1148905Srnordier * notice, this list of conditions and the following disclaimer in the 1248905Srnordier * documentation and/or other materials provided with the distribution. 1348905Srnordier * 3. All advertising materials mentioning features or use of this software 1448905Srnordier * must display the following acknowledgement: 1548905Srnordier * This product includes software developed by Christopher G. Demetriou. 1648905Srnordier * 4. The name of the author may not be used to endorse or promote products 1748905Srnordier * derived from this software without specific prior written permission 1848905Srnordier * 1948905Srnordier * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2048905Srnordier * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2148905Srnordier * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2248905Srnordier * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2348905Srnordier * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2448905Srnordier * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2548905Srnordier * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2650479Speter * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2748905Srnordier * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2848905Srnordier * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2948905Srnordier */ 3048905Srnordier 3168313Srnordier#ifndef lint 3268313Srnordierstatic char rcsid[] = "$FreeBSD: head/lib/libcompat/4.1/ftime.c 50476 1999-08-28 00:22:10Z peter $"; 3368313Srnordier#endif /* not lint */ 3448905Srnordier 3548905Srnordier#include <sys/types.h> 3648905Srnordier#include <sys/time.h> 3748905Srnordier#include <sys/timeb.h> 3848905Srnordier 3948905Srnordierint 4048905Srnordierftime(tbp) 4168313Srnordier struct timeb *tbp; 4248905Srnordier{ 4348905Srnordier struct timezone tz; 4448905Srnordier struct timeval t; 4548905Srnordier 4648905Srnordier if (gettimeofday(&t, &tz) < 0) 4748905Srnordier return (-1); 4848905Srnordier tbp->millitm = t.tv_usec / 1000; 4948905Srnordier tbp->time = t.tv_sec; 5048905Srnordier tbp->timezone = tz.tz_minuteswest; 5148905Srnordier tbp->dstflag = tz.tz_dsttime; 52 53 return (0); 54} 55