xref: /freebsd/contrib/ntp/libparse/gpstolfp.c (revision 2aaf9152a852aba9eb2036b95f4948ee77988826)
1ea906c41SOllivier Robert /*
2ea906c41SOllivier Robert  * /src/NTP/ntp4-dev/libntp/gpstolfp.c,v 4.8 2005/04/16 17:32:10 kardel RELEASE_20050508_A
3ea906c41SOllivier Robert  *
4ea906c41SOllivier Robert  * gpstolfp.c,v 4.8 2005/04/16 17:32:10 kardel RELEASE_20050508_A
5ea906c41SOllivier Robert  *
6ea906c41SOllivier Robert  * $Created: Sun Jun 28 16:30:38 1998 $
7ea906c41SOllivier Robert  *
8ea906c41SOllivier Robert  * Copyright (c) 1998-2005 by Frank Kardel <kardel <AT> ntp.org>
9ea906c41SOllivier Robert  *
10ea906c41SOllivier Robert  * Redistribution and use in source and binary forms, with or without
11ea906c41SOllivier Robert  * modification, are permitted provided that the following conditions
12ea906c41SOllivier Robert  * are met:
13ea906c41SOllivier Robert  * 1. Redistributions of source code must retain the above copyright
14ea906c41SOllivier Robert  *    notice, this list of conditions and the following disclaimer.
15ea906c41SOllivier Robert  * 2. Redistributions in binary form must reproduce the above copyright
16ea906c41SOllivier Robert  *    notice, this list of conditions and the following disclaimer in the
17ea906c41SOllivier Robert  *    documentation and/or other materials provided with the distribution.
18ea906c41SOllivier Robert  * 3. Neither the name of the author nor the names of its contributors
19ea906c41SOllivier Robert  *    may be used to endorse or promote products derived from this software
20ea906c41SOllivier Robert  *    without specific prior written permission.
21ea906c41SOllivier Robert  *
22ea906c41SOllivier Robert  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
23ea906c41SOllivier Robert  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24ea906c41SOllivier Robert  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25ea906c41SOllivier Robert  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
26ea906c41SOllivier Robert  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27ea906c41SOllivier Robert  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28ea906c41SOllivier Robert  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29ea906c41SOllivier Robert  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30ea906c41SOllivier Robert  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31ea906c41SOllivier Robert  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32ea906c41SOllivier Robert  * SUCH DAMAGE.
33ea906c41SOllivier Robert  *
34ea906c41SOllivier Robert  */
352b15cb3dSCy Schubert #include <config.h>
36ea906c41SOllivier Robert #include "ntp_fp.h"
37a25439b6SCy Schubert #include "ntp_calendar.h"
38a25439b6SCy Schubert #include "parse.h"
39ea906c41SOllivier Robert 
40ea906c41SOllivier Robert void
gpstolfp(u_int weeks,u_int days,unsigned long seconds,l_fp * lfp)41ea906c41SOllivier Robert gpstolfp(
42*f0574f5cSXin LI 	 u_int weeks,
43*f0574f5cSXin LI 	 u_int days,
44ea906c41SOllivier Robert 	 unsigned long  seconds,
45ea906c41SOllivier Robert 	 l_fp * lfp
46ea906c41SOllivier Robert 	 )
47ea906c41SOllivier Robert {
48a25439b6SCy Schubert   lfp->l_ui = (uint32_t)(weeks * SECSPERWEEK + days * SECSPERDAY + seconds + GPSORIGIN); /* convert to NTP time */
49ea906c41SOllivier Robert   lfp->l_uf = 0;
50ea906c41SOllivier Robert }
51ea906c41SOllivier Robert 
52ea906c41SOllivier Robert /*
53ea906c41SOllivier Robert  * History:
54ea906c41SOllivier Robert  *
55ea906c41SOllivier Robert  * gpstolfp.c,v
56ea906c41SOllivier Robert  * Revision 4.8  2005/04/16 17:32:10  kardel
57ea906c41SOllivier Robert  * update copyright
58ea906c41SOllivier Robert  *
59ea906c41SOllivier Robert  * Revision 4.7  2004/11/14 15:29:41  kardel
60ea906c41SOllivier Robert  * support PPSAPI, upgrade Copyright to Berkeley style
61ea906c41SOllivier Robert  *
62ea906c41SOllivier Robert  * Revision 4.3  1999/02/28 11:42:44  kardel
63ea906c41SOllivier Robert  * (GPSWRAP): update GPS rollover to 990 weeks
64ea906c41SOllivier Robert  *
65ea906c41SOllivier Robert  * Revision 4.2  1998/07/11 10:05:25  kardel
66ea906c41SOllivier Robert  * Release 4.0.73d reconcilation
67ea906c41SOllivier Robert  *
68ea906c41SOllivier Robert  * Revision 4.1  1998/06/28 16:47:15  kardel
69ea906c41SOllivier Robert  * added gpstolfp() function
70ea906c41SOllivier Robert  */
71