psocks.h 827 B

1234567891011121314151617181920212223242526272829
  1. typedef struct psocks_state psocks_state;
  2. typedef struct PsocksPlatform PsocksPlatform;
  3. typedef struct PsocksDataSink PsocksDataSink;
  4. /* indices into PsocksDataSink arrays */
  5. typedef enum PsocksDirection { UP, DN } PsocksDirection;
  6. struct PsocksDataSink {
  7. void (*free)(PsocksDataSink *);
  8. BinarySink *s[2];
  9. };
  10. static inline void pds_free(PsocksDataSink *pds)
  11. { pds->free(pds); }
  12. PsocksDataSink *pds_stdio(FILE *fp[2]);
  13. struct PsocksPlatform {
  14. PsocksDataSink *(*open_pipes)(
  15. const char *cmd, const char *const *direction_args,
  16. const char *index_arg, char **err);
  17. void (*start_subcommand)(strbuf *args);
  18. };
  19. psocks_state *psocks_new(const PsocksPlatform *);
  20. void psocks_free(psocks_state *ps);
  21. void psocks_cmdline(psocks_state *ps, int argc, char **argv);
  22. void psocks_start(psocks_state *ps);