/[LeafOK_CVS]/pvpgn-1.7.4/src/bnetd/tick.c
ViewVC logotype

Contents of /pvpgn-1.7.4/src/bnetd/tick.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (vendor branch)
Tue Jun 6 03:41:37 2006 UTC (19 years, 9 months ago) by sysadm
Branch: GNU, MAIN
CVS Tags: pvpgn_1-7-4-0_MIL, arelease, HEAD
Changes since 1.1: +0 -0 lines
Content type: text/x-csrc
no message

1 /*
2 * Copyright (C) 1999,2000 Ross Combs (rocombs@cs.nmsu.edu)
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 #include "common/setup_before.h"
19 #ifdef HAVE_STDDEF_H
20 # include <stddef.h>
21 #else
22 # ifndef NULL
23 # define NULL ((void *)0)
24 # endif
25 #endif
26 #ifdef HAVE_STRING_H
27 # include <string.h>
28 #else
29 # ifdef HAVE_STRINGS_H
30 # include <strings.h>
31 # endif
32 #endif
33 #ifdef HAVE_UNISTD_H
34 # include <unistd.h>
35 #endif
36 #include <errno.h>
37 #include "compat/strerror.h"
38 #ifdef TIME_WITH_SYS_TIME
39 # include <sys/time.h>
40 # include <time.h>
41 #else
42 # ifdef HAVE_SYS_TIME_H
43 # include <sys/time.h>
44 # else
45 # include <time.h>
46 # endif
47 #endif
48 #include "compat/gettimeofday.h"
49 #include "common/eventlog.h"
50 #include "tick.h"
51 #include "common/setup_after.h"
52
53
54 /*
55 * This routine returns the number of miliseconds that have passed since one second
56 * before it is first called. This is used for timing fields in some packets.
57 */
58 extern unsigned int get_ticks(void)
59 {
60 static int first=1;
61 static long beginsec;
62 struct timeval tv;
63
64 if (gettimeofday(&tv,NULL)<0)
65 {
66 eventlog(eventlog_level_error,__FUNCTION__,"could not get time (gettimeofday: %s)",pstrerror(errno));
67 return 0;
68 }
69 if (first)
70 {
71 beginsec = tv.tv_sec-1;
72 first = 0;
73 }
74
75 return (unsigned int)((tv.tv_sec-beginsec)*1000+tv.tv_usec/1000);
76 }

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1