Wireshark 4.7.3
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
ws_pipe.h
Go to the documentation of this file.
1
11
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
35typedef struct _ws_pipe_t {
36 GPid pid;
37 GIOChannel *stdin_io;
38 GIOChannel *stdout_io;
39 GIOChannel *stderr_io;
40 GSList *other_sources;
42
54WS_DLL_PUBLIC bool ws_pipe_spawn_sync(const char * working_directory, const char * command, unsigned argc, char ** args, char ** command_output);
55
60WS_DLL_PUBLIC void ws_pipe_init(ws_pipe_t *ws_pipe);
61
65static inline bool ws_pipe_valid(ws_pipe_t *ws_pipe)
66{
67 return ws_pipe && ws_pipe->pid && ws_pipe->pid != WS_INVALID_PID;
68}
69
76WS_DLL_PUBLIC GPid ws_pipe_spawn_async (ws_pipe_t * ws_pipe, GPtrArray * args );
77
78#ifdef _WIN32
86WS_DLL_PUBLIC bool ws_pipe_wait_for_pipe(HANDLE * pipe_handles, int num_pipe_handles, HANDLE pid);
87#endif
88
94WS_DLL_PUBLIC bool ws_pipe_data_available(int pipe_fd);
95
96#endif /* __WS_PIPE_H__ */
97
98/*
99 * Editor modelines - https://www.wireshark.org/tools/modelines.html
100 *
101 * Local variables:
102 * c-basic-offset: 4
103 * tab-width: 8
104 * indent-tabs-mode: nil
105 * End:
106 *
107 * vi: set shiftwidth=4 tabstop=8 expandtab:
108 * :indentSize=4:tabSize=8:noTabs=true:
109 */
Represents a spawned child process and its associated I/O channels for inter-process communication.
Definition ws_pipe.h:35
GPid pid
Definition ws_pipe.h:36
GIOChannel * stdout_io
Definition ws_pipe.h:38
GIOChannel * stderr_io
Definition ws_pipe.h:39
GIOChannel * stdin_io
Definition ws_pipe.h:37
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
struct _ws_pipe_t ws_pipe_t
Represents a spawned child process and its associated I/O channels for inter-process communication.
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:818
WS_DLL_PUBLIC bool ws_pipe_spawn_sync(const char *working_directory, const char *command, unsigned 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