Handle lines ending in \r\n.
[metze/wireshark/wip.git] / sync_pipe.h
1 /* sync_pipe.h
2  * Low-level synchronization pipe routines for use by Wireshark/TShark
3  * and dumpcap
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
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
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26
27 /** @file
28  *  
29  *  Low-level sync pipe interfaces.
30  */
31
32 #ifndef __SYNC_PIPE_H__
33 #define __SYNC_PIPE_H__
34
35
36 /*
37  * Maximum length of sync pipe message data.  Must be < 2^24, as the
38  * message length is 3 bytes.
39  * XXX - this must be large enough to handle a Really Big Filter
40  * Expression, as the error message for an incorrect filter expression
41  * is a bit larger than the filter expression.
42  */
43 #define SP_MAX_MSG_LEN  4096
44
45
46 /* Size of buffer to hold decimal representation of
47    signed/unsigned 64-bit int */
48 #define SP_DECISIZE 20
49
50 /*
51  * Indications sent out on the sync pipe (from child to parent).
52  */
53 #define SP_FILE         'F'     /* the name of the recently opened file */
54 #define SP_ERROR_MSG    'E'     /* error message */
55 #define SP_BAD_FILTER   'B'     /* error message for bad capture filter */
56 #define SP_PACKET_COUNT 'P'     /* count of packets captured since last message */
57 #define SP_DROPS        'D'     /* count of packets dropped in capture */
58 #define SP_SUCCESS      'S'     /* success indication, no extra data */
59 /*
60  * Win32 only: Indications sent out on the signal pipe (from parent to child)
61  * (UNIX-like sends signals for this)
62  */
63 #define SP_QUIT         'Q'     /* "gracefully" capture quit message (SIGUSR1) */
64
65 /* write a single message header to the recipient pipe */
66 extern int
67 pipe_write_header(int pipe_fd, char indicator, int length);
68
69 /* write a message to the recipient pipe in the standard format 
70    (3 digit message length (excluding length and indicator field), 
71    1 byte message indicator and the rest is the message).
72    If msg is NULL, the message has only a length and indicator. */
73 extern void
74 pipe_write_block(int pipe_fd, char indicator, const char *msg);
75
76 /** the child encountered an error, notify the parent */
77 extern void 
78 sync_pipe_errmsg_to_parent(int pipe_fd, const char *error_msg,
79                            const char *secondary_error_msg);
80
81 #endif /* sync_pipe.h */