Bump copyright date to 2019
[tor.git] / src / lib / process / process_win32.h
blobd79dde157e8d8addfbd28161c3ed3b839400ea54
1 /* Copyright (c) 2003-2004, Roger Dingledine
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
6 /**
7 * \file process_win32.h
8 * \brief Header for process_win32.c
9 **/
11 #ifndef TOR_PROCESS_WIN32_H
12 #define TOR_PROCESS_WIN32_H
14 #ifdef _WIN32
16 #include "orconfig.h"
17 #include "lib/malloc/malloc.h"
18 #include "lib/evloop/compat_libevent.h"
20 #include <windows.h>
22 struct process_t;
24 struct process_win32_t;
25 typedef struct process_win32_t process_win32_t;
27 process_win32_t *process_win32_new(void);
28 void process_win32_free_(process_win32_t *win32_process);
29 #define process_win32_free(s) \
30 FREE_AND_NULL(process_win32_t, process_win32_free_, (s))
32 void process_win32_init(void);
33 void process_win32_deinit(void);
35 process_status_t process_win32_exec(struct process_t *process);
36 bool process_win32_terminate(struct process_t *process);
38 process_pid_t process_win32_get_pid(struct process_t *process);
40 int process_win32_write(struct process_t *process, buf_t *buffer);
41 int process_win32_read_stdout(struct process_t *process, buf_t *buffer);
42 int process_win32_read_stderr(struct process_t *process, buf_t *buffer);
44 void process_win32_trigger_completion_callbacks(void);
46 /* Timer handling. */
47 void process_win32_timer_start(void);
48 void process_win32_timer_stop(void);
49 bool process_win32_timer_running(void);
51 #ifdef PROCESS_WIN32_PRIVATE
52 STATIC void process_win32_timer_callback(periodic_timer_t *, void *);
53 STATIC bool process_win32_timer_test_process(process_t *);
55 /* I/O pipe handling. */
56 struct process_win32_handle_t;
57 typedef struct process_win32_handle_t process_win32_handle_t;
59 typedef enum process_win32_pipe_type_t {
60 /** This pipe is used for reading. */
61 PROCESS_WIN32_PIPE_TYPE_READER,
63 /** This pipe is used for writing. */
64 PROCESS_WIN32_PIPE_TYPE_WRITER
65 } process_win32_pipe_type_t;
67 STATIC bool process_win32_create_pipe(HANDLE *,
68 HANDLE *,
69 SECURITY_ATTRIBUTES *,
70 process_win32_pipe_type_t);
72 STATIC void process_win32_cleanup_handle(process_win32_handle_t *handle);
74 STATIC VOID WINAPI process_win32_stdout_read_done(DWORD,
75 DWORD,
76 LPOVERLAPPED);
77 STATIC VOID WINAPI process_win32_stderr_read_done(DWORD,
78 DWORD,
79 LPOVERLAPPED);
80 STATIC VOID WINAPI process_win32_stdin_write_done(DWORD,
81 DWORD,
82 LPOVERLAPPED);
84 STATIC int process_win32_read_from_handle(process_win32_handle_t *,
85 buf_t *,
86 LPOVERLAPPED_COMPLETION_ROUTINE);
87 STATIC bool process_win32_handle_read_completion(process_win32_handle_t *,
88 DWORD,
89 DWORD);
91 STATIC char *format_win_cmdline_argument(const char *arg);
92 STATIC char *tor_join_win_cmdline(const char *argv[]);
93 #endif /* defined(PROCESS_WIN32_PRIVATE). */
95 #endif /* ! defined(_WIN32). */
97 #endif /* defined(TOR_PROCESS_WIN32_H). */