/[debburn]/nonameyet/trunk/cdrecord/misc.c
ViewVC logotype

Contents of /nonameyet/trunk/cdrecord/misc.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download)
Fri Aug 18 17:34:13 2006 UTC (6 years, 9 months ago) by blade
File MIME type: text/plain
File size: 2131 byte(s)
Imported the resorted version a08
1 /* @(#)misc.c 1.4 04/03/02 Copyright 1998, 2001-2004 J. Schilling */
2 #ifndef lint
3 static char sccsid[] =
4 "@(#)misc.c 1.4 04/03/02 Copyright 1998, 2001-2004 J. Schilling";
5 #endif
6 /*
7 * Misc support functions
8 *
9 * Copyright (c) 1998, 2001-2004 J. Schilling
10 */
11 /*
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2
14 * as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along with
22 * this program; see the file COPYING. If not, write to the Free Software
23 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */
25
26 #include <mconfig.h>
27 #include <timedefs.h>
28 #include <stdio.h>
29 #include <standard.h>
30 #include <schily.h>
31
32 EXPORT void timevaldiff __PR((struct timeval *start, struct timeval *stop));
33 EXPORT void prtimediff __PR((const char *fmt,
34 struct timeval *start,
35 struct timeval *stop));
36
37 EXPORT void
38 timevaldiff(start, stop)
39 struct timeval *start;
40 struct timeval *stop;
41 {
42 struct timeval tv;
43
44 tv.tv_sec = stop->tv_sec - start->tv_sec;
45 tv.tv_usec = stop->tv_usec - start->tv_usec;
46 while (tv.tv_usec > 1000000) {
47 tv.tv_usec -= 1000000;
48 tv.tv_sec += 1;
49 }
50 while (tv.tv_usec < 0) {
51 tv.tv_usec += 1000000;
52 tv.tv_sec -= 1;
53 }
54 *stop = tv;
55 }
56
57 EXPORT void
58 prtimediff(fmt, start, stop)
59 const char *fmt;
60 struct timeval *start;
61 struct timeval *stop;
62 {
63 struct timeval tv;
64
65 tv.tv_sec = stop->tv_sec - start->tv_sec;
66 tv.tv_usec = stop->tv_usec - start->tv_usec;
67 while (tv.tv_usec > 1000000) {
68 tv.tv_usec -= 1000000;
69 tv.tv_sec += 1;
70 }
71 while (tv.tv_usec < 0) {
72 tv.tv_usec += 1000000;
73 tv.tv_sec -= 1;
74 }
75 /*
76 * We need to cast timeval->* to long because
77 * of the broken sys/time.h in Linux.
78 */
79 printf("%s%4ld.%03lds\n", fmt, (long)tv.tv_sec, (long)tv.tv_usec/1000);
80 flush();
81 }

  ViewVC Help
Powered by ViewVC 1.1.5