Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
ws_pipe.h
Go to the documentation of this file.
1
12#ifndef __WS_PIPE_H__
13#define __WS_PIPE_H__
14
15#include <stdbool.h>
16
17// ws_symbol_export and WS_INVALID_PID
18#include "wsutil/processes.h"
19
20#include <glib.h>
21
22#ifdef _WIN32
23#include <windows.h>
24#include <io.h>
25#define ws_pipe_handle HANDLE
26#define ws_get_pipe_handle(pipe_fd) ((HANDLE)_get_osfhandle(pipe_fd))
27#else
28#define ws_pipe_handle int
29#define ws_get_pipe_handle(pipe_fd) (pipe_fd)
30#endif
31
32typedef struct _ws_pipe_t {
33 GPid pid;
34 GIOChannel *stdin_io;
35 GIOChannel *stdout_io;
36 GIOChannel *stderr_io;
37} ws_pipe_t;
38
50WS_DLL_PUBLIC bool ws_pipe_spawn_sync(const char * working_directory, const char * command, int argc, char ** args, char ** command_output);
51
56WS_DLL_PUBLIC void ws_pipe_init(ws_pipe_t *ws_pipe);
57
61static inline bool ws_pipe_valid(ws_pipe_t *ws_pipe)
62{
63 return ws_pipe && ws_pipe->pid && ws_pipe->pid != WS_INVALID_PID;
64}
65
72WS_DLL_PUBLIC GPid ws_pipe_spawn_async (ws_pipe_t * ws_pipe, GPtrArray * args );
73
74#ifdef _WIN32
82WS_DLL_PUBLIC bool ws_pipe_wait_for_pipe(HANDLE * pipe_handles, int num_pipe_handles, HANDLE pid);
83#endif
84
90WS_DLL_PUBLIC bool ws_pipe_data_available(int pipe_fd);
91
92#endif /* __WS_PIPE_H__ */
93
94/*
95 * Editor modelines - https://www.wireshark.org/tools/modelines.html
96 *
97 * Local variables:
98 * c-basic-offset: 4
99 * tab-width: 8
100 * indent-tabs-mode: nil
101 * End:
102 *
103 * vi: set shiftwidth=4 tabstop=8 expandtab:
104 * :indentSize=4:tabSize=8:noTabs=true:
105 */
Definition ws_pipe.h:32
WS_DLL_PUBLIC GPid ws_pipe_spawn_async(ws_pipe_t *ws_pipe, GPtrArray *args)
Start a process using g_spawn_sync on UNIX and Linux, and CreateProcess on Windows.
Definition ws_pipe.c:521
WS_DLL_PUBLIC bool ws_pipe_spawn_sync(const char *working_directory, const char *command, int argc, char **args, char **command_output)
Run a process using g_spawn_sync on UNIX and Linux, and CreateProcess on Windows. Wait for it to fini...
Definition ws_pipe.c:229
WS_DLL_PUBLIC void ws_pipe_init(ws_pipe_t *ws_pipe)
Initialize a ws_pipe_t struct. Sets .pid to WS_INVALID_PID and all other members to 0 or NULL.
Definition ws_pipe.c:514
WS_DLL_PUBLIC bool ws_pipe_data_available(int pipe_fd)
Check to see if a file descriptor has data available.
Definition ws_pipe.c:808