282f1e9d465c88496af9b5a5deed66c1ce3f9934
[metze/wireshark/wip.git] / ui / time_shift.h
1 /* time_shift.h
2  * Submitted by Edwin Groothuis <wireshark@mavetju.org>
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 #ifndef __TIME_SHIFT_H__
24 #define __TIME_SHIFT_H__
25
26 #include "cfile.h"
27 #include <wsutil/nstime.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32
33 /*
34  * XXX - We might want to move all of this somewhere more accessible to
35  * editcap so that we can make its time adjustments more versatile.
36  */
37
38 /**
39  * Parse a time string and fill in each component.
40  *
41  * If year, month, and day are non-NULL a full time format "[YYYY-MM-DD] hh:mm:ss[.decimals]"
42  * is allowed. Otherwise an offset format "[-][[hh:]mm:]ss[.decimals]" is allowed.
43  *
44  * @param time_text Time string
45  * @param year Year. May be NULL
46  * @param month Month. May be NULL
47  * @param day Day. May be NULL.
48  * @param negative Time offset is negative. May be NULL if year, month, and day are not NULL.
49  * @param hour Hours. Must not be NULL.
50  * @param minute Minutes. Must not be NULL.
51  * @param second Seconds. Must not be NULL.
52  *
53  * @return NULL on success or an error description on failure.
54  */
55
56 const gchar * time_string_parse(const gchar *time_text, int *year, int *month, int *day, gboolean *negative, int *hour, int *minute, long double *second);
57
58 /** Shift all packets by an offset
59  *
60  * @param cf Capture file to shift
61  * @param offset_text String representation of the offset.
62  *
63  * @return NULL on success or an error description on failure.
64  */
65 const gchar * time_shift_all(capture_file *cf, const gchar *offset_text);
66
67 /* Set the time for a single packet
68  *
69  * @param cf Capture file to set
70  * @param packet_num Packet to set
71  * @param time_text String representation of the time
72  *
73  * @return NULL on success or an error description on failure.
74  */
75 const gchar * time_shift_settime(capture_file *cf, guint packet_num, const gchar *time_text);
76
77 /* Set the time for two packets and extrapolate the rest
78  *
79  * @param cf Capture file to set
80  * @param packet1_num First packet to set
81  * @param time1_text String representation of the first packet time
82  * @param packet2_num Second packet to set
83  * @param time2_text String representation of the second packet time
84  *
85  * @return NULL on success or an error description on failure.
86  */
87 const gchar * time_shift_adjtime(capture_file *cf, guint packet1_num, const gchar *time1_text, guint packet2_num, const gchar *time2_text);
88
89 /* Reset the times for all packets
90  *
91  * @param cf Capture file to set
92  *
93  * @return NULL on success or an error description on failure.
94  */
95 const gchar * time_shift_undo(capture_file *cf);
96
97 #ifdef __cplusplus
98 }
99 #endif /* __cplusplus */
100
101 #endif /* __TIME_SHIFT_H__ */