Put special pipe-handling code into libwsutil.
Ask, in a comment, why we're doing PeekNamedPipe() when we're trying
to read everyting in the pipe, up to the EOF, into a string.
On UN*X, do the same "read up to an EOF and then NUL-terminate the
result" stuff that we did on Windows; nothing guarantees that, on all
UN*Xes, in all circumstances, until the end of time, world without end,
amen, we can do one read and get the entire string.
Change-Id: I578802b23fec1051139eaefd9a09fe2a6de06a11
Reviewed-on: https://code.wireshark.org/review/24959
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-23 08:05:21 +00:00
|
|
|
/* ws_pipe.h
|
|
|
|
*
|
|
|
|
* Routines for handling pipes.
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-07 11:26:45 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
Put special pipe-handling code into libwsutil.
Ask, in a comment, why we're doing PeekNamedPipe() when we're trying
to read everyting in the pipe, up to the EOF, into a string.
On UN*X, do the same "read up to an EOF and then NUL-terminate the
result" stuff that we did on Windows; nothing guarantees that, on all
UN*Xes, in all circumstances, until the end of time, world without end,
amen, we can do one read and get the entire string.
Change-Id: I578802b23fec1051139eaefd9a09fe2a6de06a11
Reviewed-on: https://code.wireshark.org/review/24959
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-23 08:05:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __WS_PIPE_H__
|
|
|
|
#define __WS_PIPE_H__
|
|
|
|
|
|
|
|
#include "ws_symbol_export.h"
|
|
|
|
|
2018-01-02 12:23:08 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
2018-03-01 23:31:45 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define INVALID_EXTCAP_PID INVALID_HANDLE_VALUE
|
|
|
|
#else
|
|
|
|
#define INVALID_EXTCAP_PID (GPid)-1
|
|
|
|
#endif
|
|
|
|
|
Put special pipe-handling code into libwsutil.
Ask, in a comment, why we're doing PeekNamedPipe() when we're trying
to read everyting in the pipe, up to the EOF, into a string.
On UN*X, do the same "read up to an EOF and then NUL-terminate the
result" stuff that we did on Windows; nothing guarantees that, on all
UN*Xes, in all circumstances, until the end of time, world without end,
amen, we can do one read and get the entire string.
Change-Id: I578802b23fec1051139eaefd9a09fe2a6de06a11
Reviewed-on: https://code.wireshark.org/review/24959
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-23 08:05:21 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#include <io.h>
|
|
|
|
#define ws_pipe_handle HANDLE
|
|
|
|
#define ws_get_pipe_handle(pipe_fd) ((HANDLE)_get_osfhandle(pipe_fd))
|
|
|
|
#else
|
|
|
|
#define ws_pipe_handle int
|
|
|
|
#define ws_get_pipe_handle(pipe_fd) (pipe_fd)
|
|
|
|
#endif
|
|
|
|
|
2018-03-01 23:31:45 +00:00
|
|
|
typedef struct _ws_pipe_t {
|
|
|
|
GPid pid;
|
|
|
|
gchar *stderr_msg;
|
|
|
|
gint exitcode;
|
|
|
|
gint stdin_fd;
|
|
|
|
gint stdout_fd;
|
|
|
|
gint stderr_fd;
|
|
|
|
#ifdef _WIN32
|
|
|
|
HANDLE threadId;
|
|
|
|
#endif
|
|
|
|
} ws_pipe_t;
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC gboolean ws_pipe_spawn_sync ( gchar * dirname, gchar * command, gint argc, gchar ** argv, gchar ** command_output );
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC GPid ws_pipe_spawn_async (ws_pipe_t * ws_pipe, GPtrArray * args );
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
WS_DLL_PUBLIC gboolean ws_pipe_wait_for_pipe(HANDLE * pipe_handles, int num_pipe_handles, HANDLE pid);
|
|
|
|
#endif
|
|
|
|
|
Put special pipe-handling code into libwsutil.
Ask, in a comment, why we're doing PeekNamedPipe() when we're trying
to read everyting in the pipe, up to the EOF, into a string.
On UN*X, do the same "read up to an EOF and then NUL-terminate the
result" stuff that we did on Windows; nothing guarantees that, on all
UN*Xes, in all circumstances, until the end of time, world without end,
amen, we can do one read and get the entire string.
Change-Id: I578802b23fec1051139eaefd9a09fe2a6de06a11
Reviewed-on: https://code.wireshark.org/review/24959
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-23 08:05:21 +00:00
|
|
|
WS_DLL_PUBLIC gboolean ws_pipe_data_available(int pipe_fd);
|
|
|
|
|
|
|
|
WS_DLL_PUBLIC gboolean ws_read_string_from_pipe(ws_pipe_handle read_pipe,
|
|
|
|
gchar *buffer, size_t buffer_size);
|
|
|
|
|
|
|
|
#endif /* __WS_PIPE_H__ */
|
2018-01-02 12:23:08 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|