xref: /dflybsd-src/lib/libcompat/4.1/ftime.c (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino /*
286d7f5d3SJohn Marino  * Copyright (c) 1994 Christopher G. Demetriou
386d7f5d3SJohn Marino  * All rights reserved.
486d7f5d3SJohn Marino  *
586d7f5d3SJohn Marino  * Redistribution and use in source and binary forms, with or without
686d7f5d3SJohn Marino  * modification, are permitted provided that the following conditions
786d7f5d3SJohn Marino  * are met:
886d7f5d3SJohn Marino  * 1. Redistributions of source code must retain the above copyright
986d7f5d3SJohn Marino  *    notice, this list of conditions and the following disclaimer.
1086d7f5d3SJohn Marino  * 2. Redistributions in binary form must reproduce the above copyright
1186d7f5d3SJohn Marino  *    notice, this list of conditions and the following disclaimer in the
1286d7f5d3SJohn Marino  *    documentation and/or other materials provided with the distribution.
1386d7f5d3SJohn Marino  * 3. All advertising materials mentioning features or use of this software
1486d7f5d3SJohn Marino  *    must display the following acknowledgement:
1586d7f5d3SJohn Marino  *      This product includes software developed by Christopher G. Demetriou.
1686d7f5d3SJohn Marino  * 4. The name of the author may not be used to endorse or promote products
1786d7f5d3SJohn Marino  *    derived from this software without specific prior written permission
1886d7f5d3SJohn Marino  *
1986d7f5d3SJohn Marino  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2086d7f5d3SJohn Marino  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2186d7f5d3SJohn Marino  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2286d7f5d3SJohn Marino  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2386d7f5d3SJohn Marino  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2486d7f5d3SJohn Marino  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2586d7f5d3SJohn Marino  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2686d7f5d3SJohn Marino  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2786d7f5d3SJohn Marino  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2886d7f5d3SJohn Marino  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2986d7f5d3SJohn Marino  *
3086d7f5d3SJohn Marino  * $FreeBSD: src/lib/libcompat/4.1/ftime.c,v 1.5 1999/08/28 00:04:12 peter Exp $
3186d7f5d3SJohn Marino  * $DragonFly: src/lib/libcompat/4.1/ftime.c,v 1.3 2008/09/30 16:57:04 swildner Exp $
3286d7f5d3SJohn Marino  */
3386d7f5d3SJohn Marino 
3486d7f5d3SJohn Marino #include <sys/types.h>
3586d7f5d3SJohn Marino #include <sys/time.h>
3686d7f5d3SJohn Marino #include <sys/timeb.h>
3786d7f5d3SJohn Marino 
3886d7f5d3SJohn Marino int
ftime(struct timeb * tbp)3986d7f5d3SJohn Marino ftime(struct timeb *tbp)
4086d7f5d3SJohn Marino {
4186d7f5d3SJohn Marino         struct timezone tz;
4286d7f5d3SJohn Marino         struct timeval t;
4386d7f5d3SJohn Marino 
4486d7f5d3SJohn Marino         if (gettimeofday(&t, &tz) < 0)
4586d7f5d3SJohn Marino                 return (-1);
4686d7f5d3SJohn Marino         tbp->millitm = t.tv_usec / 1000;
4786d7f5d3SJohn Marino         tbp->time = t.tv_sec;
4886d7f5d3SJohn Marino         tbp->timezone = tz.tz_minuteswest;
4986d7f5d3SJohn Marino         tbp->dstflag = tz.tz_dsttime;
5086d7f5d3SJohn Marino 
5186d7f5d3SJohn Marino 	return (0);
5286d7f5d3SJohn Marino }
53