Skip to content

Commit

Permalink
lib-program-client: Add URI based constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
cmouse authored and sirainen committed Oct 22, 2016
1 parent 9af3c0b commit 959c2cf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/lib-program-client/program-client.c
Expand Up @@ -571,6 +571,32 @@ void program_client_switch_ioloop(struct program_client *pclient)
pclient->switch_ioloop(pclient);
}

int program_client_create(const char *uri, const char *const *args,
const struct program_client_settings *set,
bool noreply, struct program_client **pc_r,
const char **error_r)
{
if (strncmp(uri, "exec:", 5) == 0) {
*pc_r = program_client_local_create(
uri+5,
args,
set);
return 0;
} else if (strncmp(uri, "unix:", 5) == 0) {
*pc_r = program_client_remote_create(
uri+5,
args,
set, noreply);
return 0;
} else {
*error_r = t_strdup_printf(
"Unsupported program client scheme '%s'",
t_strcut(uri, ':'));
return -1;
}
}


static
void program_client_run_callback(int result, int *context)
{
Expand Down
4 changes: 4 additions & 0 deletions src/lib-program-client/program-client.h
Expand Up @@ -31,6 +31,10 @@ struct program_client *program_client_local_create(const char *bin_path,
struct program_client *program_client_remote_create(const char *socket_path,
const char *const *args,
const struct program_client_settings *set, bool noreply);
int program_client_create(const char *uri, const char *const *args,
const struct program_client_settings *set,
bool noreply, struct program_client **pc_r,
const char **error_r);

void program_client_destroy(struct program_client **_pclient);

Expand Down

0 comments on commit 959c2cf

Please sign in to comment.