BInputProcess.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * @file BInputProcess.h
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * This file is part of BadVPN.
  8. *
  9. * BadVPN is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * BadVPN is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. */
  22. #ifndef BADVPN_INPUTPROCESS_BINPUTPROCESS_H
  23. #define BADVPN_INPUTPROCESS_BINPUTPROCESS_H
  24. #include <misc/debug.h>
  25. #include <base/DebugObject.h>
  26. #include <system/BSocket.h>
  27. #include <process/BProcess.h>
  28. #include <flowextra/StreamSocketSource.h>
  29. typedef void (*BInputProcess_handler_terminated) (void *user, int normally, uint8_t normally_exit_status);
  30. typedef void (*BInputProcess_handler_closed) (void *user, int is_error);
  31. typedef struct {
  32. BReactor *reactor;
  33. BProcessManager *manager;
  34. void *user;
  35. BInputProcess_handler_terminated handler_terminated;
  36. BInputProcess_handler_closed handler_closed;
  37. int pipe_write_fd;
  38. int started;
  39. int have_process;
  40. BProcess process;
  41. int pipe_fd;
  42. BSocket pipe_sock;
  43. FlowErrorDomain pipe_domain;
  44. StreamSocketSource pipe_source;
  45. DebugObject d_obj;
  46. } BInputProcess;
  47. int BInputProcess_Init (BInputProcess *o, BReactor *reactor, BProcessManager *manager, void *user,
  48. BInputProcess_handler_terminated handler_terminated,
  49. BInputProcess_handler_closed handler_closed) WARN_UNUSED;
  50. void BInputProcess_Free (BInputProcess *o);
  51. int BInputProcess_Start (BInputProcess *o, const char *file, char *const argv[], const char *username);
  52. int BInputProcess_Terminate (BInputProcess *o);
  53. int BInputProcess_Kill (BInputProcess *o);
  54. StreamRecvInterface * BInputProcess_GetInput (BInputProcess *o);
  55. #endif