psocks.h 868 B

123456789101112131415161718192021222324252627282930
  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 (*found_subcommand)(CmdlineArg *arg);
  18. void (*start_subcommand)(void);
  19. };
  20. psocks_state *psocks_new(const PsocksPlatform *);
  21. void psocks_free(psocks_state *ps);
  22. void psocks_cmdline(psocks_state *ps, CmdlineArgList *arglist);
  23. void psocks_start(psocks_state *ps);