1 #ifndef PROGRAM_CLIENT_PRIVATE_H 2 #define PROGRAM_CLIENT_PRIVATE_H 3 4 #include "program-client.h" 5 6 enum program_client_error { 7 PROGRAM_CLIENT_ERROR_NONE, 8 PROGRAM_CLIENT_ERROR_CONNECT_TIMEOUT, 9 PROGRAM_CLIENT_ERROR_RUN_TIMEOUT, 10 PROGRAM_CLIENT_ERROR_IO, 11 PROGRAM_CLIENT_ERROR_OTHER 12 }; 13 14 struct program_client_extra_fd { 15 struct program_client *pclient; 16 17 int child_fd, parent_fd; 18 struct istream *input; 19 struct io *io; 20 21 program_client_fd_callback_t *callback; 22 void *context; 23 }; 24 25 struct program_client { 26 pool_t pool; 27 struct program_client_settings set; 28 29 const char **args; 30 ARRAY_TYPE(const_string) envs; 31 32 struct event *event; 33 34 int fd_in, fd_out; 35 struct io *io; 36 struct timeout *to; 37 struct timeval start_time; 38 39 struct istream *input, *program_input, *raw_program_input; 40 struct ostream *output, *program_output, *raw_program_output; 41 42 struct iostream_pump *pump_in, *pump_out; 43 44 ARRAY(struct program_client_extra_fd) extra_fds; 45 46 program_client_callback_t *callback; 47 void *context; 48 49 bool other_error; 50 enum program_client_error error; 51 enum program_client_exit_status exit_status; 52 53 int (*connect) (struct program_client * pclient); 54 int (*close_output) (struct program_client * pclient); 55 void (*switch_ioloop) (struct program_client * pclient); 56 void (*disconnect) (struct program_client * pclient, bool force); 57 void (*destroy) (struct program_client * pclient); 58 59 bool debug:1; 60 bool disconnected:1; 61 bool output_seekable:1; 62 bool destroying:1; 63 }; 64 65 void program_client_set_label(struct program_client *pclient, 66 const char *label); 67 68 void program_client_init(struct program_client *pclient, pool_t pool, 69 const char *initial_label, 70 const char *const *args, 71 const struct program_client_settings *set) 72 ATTR_NULL(5); 73 74 void program_client_init_streams(struct program_client *pclient); 75 76 void program_client_connected(struct program_client *pclient); 77 78 void program_client_fail(struct program_client *pclient, 79 enum program_client_error error); 80 81 void program_client_program_input(struct program_client *pclient); 82 83 void program_client_disconnected(struct program_client *pclient); 84 85 #endif 86