|
libfossil
|
State for use with the fsl_sc_popen fsl_sc impl. More...
#include "sync.h"
Data Fields | |
| struct { | |
| char * location | |
| Location where the binary was found. More... | |
| char const * name | |
| The name of the program binary, e.g. More... | |
| } | bin |
| Info about the binary. | |
| fsl_buffer | cmd |
| The command line to invoke. | |
| struct { | |
| int(* buildCommandLine )(fsl_sc *ch, fsl_buffer *b, fsl_buffer const *bLoginCard) | |
| Command arguments initializer. More... | |
| void(* cleanup )(fsl_sc_popen_state *st) | |
| May be set for subclasses in order to clean up any dynamic state owned by this object in this->impl.state. More... | |
| int(* init )(fsl_sc *ch) | |
| This optional method gets called as part of the FSL_SC_INIT_INITIAL phase of fsl_sc::init() to give subclasses a way to perform any validation they may need. More... | |
| void * state | |
| Subclass-specific state. More... | |
| } | impl |
| State for "subclasses". | |
| struct { | |
| void * allocStamp | |
| Internal implementation detail. More... | |
| char * tmpfilePrefix | |
| A random prefix for temp file names. More... | |
| } | misc |
| Flag(s). | |
| struct { | |
| int fdStdOut | |
| The external process's stdout, i.e. More... | |
| FILE * fStdIn | |
| The external process's stdin, i.e. More... | |
| int pid | |
| The external process's PID. More... | |
| } | process |
| State for/around fsl__popen2(). | |
| struct { | |
| unsigned count | |
| Number of initiated requests. More... | |
| char * filename | |
| Filename of this->fp. More... | |
| FILE * fp | |
| Request payload temp file. More... | |
| } | request |
| State for the sync request payload. | |
| struct { | |
| fsl_buffer b | |
| Response body when this->mode is fsl_sc_popen_e_membuf. More... | |
| unsigned count | |
| Number of initiated response-reads. More... | |
| int fd | |
| Response input source when this->mode is fsl_sc_popen_e_fd. More... | |
| char * filename | |
| Response temp file when this->response.mode is fsl_sc_popen_e_filebuf or fsl_sc_popen_e_fd. More... | |
| FILE * fp | |
| Response source file when this->mode is fsl_sc_popen_e_filebuf. More... | |
| enum fsl_sc_popen_e mode | |
| How to read the response. More... | |
| } | response |
| State for the sync response payload. | |
State for use with the fsl_sc_popen fsl_sc impl.
fsl_sc_popen requires that its state member point to an instance of this class.
This type acts as a base implemtation for channels which "shell out" to an external binary to provide the transport layer. e.g. curl can be used for HTTP(S) and fossil(1)'s own "test-http" mechanism can be used this way.
| void* fsl_sc_popen_state::allocStamp |
| fsl_buffer fsl_sc_popen_state::b |
| struct { ... } fsl_sc_popen_state::bin |
Info about the binary.
| int(* fsl_sc_popen_state::buildCommandLine) (fsl_sc *ch, fsl_buffer *b, fsl_buffer const *bLoginCard) |
Command arguments initializer.
Must be set by concrete implementations and it gets invoked via fsl_sc::submit(). Implementations must populate b using ((fsl_sc_popen_state*)ch->impl.p)'s state, namely the request.filename and response.filename members, which are names of temporary files which will eventually contain the request payload and response payloads.
Implementations must use fsl_buffer_escape_arg() and friends to append a complete command line to b. They must return 0 on success.
When this is called (early on in the fsl_sc::submit() process):
| void(* fsl_sc_popen_state::cleanup) (fsl_sc_popen_state *st) |
May be set for subclasses in order to clean up any dynamic state owned by this object in this->impl.state.
It will be called early in the fsl_sc::cleanup() step, before st's base class state are cleaned.
Whether or not it must free st is implementation-defined.
| fsl_buffer fsl_sc_popen_state::cmd |
| unsigned fsl_sc_popen_state::count |
| int fsl_sc_popen_state::fd |
| int fsl_sc_popen_state::fdStdOut |
| char* fsl_sc_popen_state::filename |
| FILE* fsl_sc_popen_state::fp |
| FILE* fsl_sc_popen_state::fStdIn |
| struct { ... } fsl_sc_popen_state::impl |
State for "subclasses".
Not really subclasses, but "concrete implementations" gets unwieldy after a while.
| int(* fsl_sc_popen_state::init) (fsl_sc *ch) |
This optional method gets called as part of the FSL_SC_INIT_INITIAL phase of fsl_sc::init() to give subclasses a way to perform any validation they may need.
It may also perform any one-time initialization it may need to do.
If it returns non-0, channel initialization fails.
| char* fsl_sc_popen_state::location |
Location where the binary was found.
If NULL, it defaults to a $PATH search of this->bin.name. Clients may set this before use, but (A) it must be allocated using a libfossil API, e.g. fsl_mprintf(), and (B) this memory is owned by this object.
If the client does not set this, the library will search in the $PATH for this->name and assign that value here.
| struct { ... } fsl_sc_popen_state::misc |
Flag(s).
| enum fsl_sc_popen_e fsl_sc_popen_state::mode |
| char const* fsl_sc_popen_state::name |
| struct { ... } fsl_sc_popen_state::process |
State for/around fsl__popen2().
| struct { ... } fsl_sc_popen_state::request |
State for the sync request payload.
| struct { ... } fsl_sc_popen_state::response |
State for the sync response payload.
| void* fsl_sc_popen_state::state |
| char* fsl_sc_popen_state::tmpfilePrefix |
A random prefix for temp file names.
Memory is owned by this object. All request and response temp files are prefixed with this and get a predictable suffix. We generate a random prefix, rather than a new random name on each call, to simplify grouping of the files for development and debugging purposes.