Mercurial > dovecot > core-2.2
changeset 20938:16902941b3da
lib-program-client: Add URI based constructor
author | Aki Tuomi <aki.tuomi@dovecot.fi> |
---|---|
date | Fri, 21 Oct 2016 14:34:51 +0300 |
parents | 8fdca7a268e0 |
children | 153d870c27ab |
files | src/lib-program-client/program-client.c src/lib-program-client/program-client.h |
diffstat | 2 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-program-client/program-client.c Thu Oct 20 22:59:10 2016 +0300 +++ b/src/lib-program-client/program-client.c Fri Oct 21 14:34:51 2016 +0300 @@ -571,6 +571,32 @@ 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) {
--- a/src/lib-program-client/program-client.h Thu Oct 20 22:59:10 2016 +0300 +++ b/src/lib-program-client/program-client.h Fri Oct 21 14:34:51 2016 +0300 @@ -31,6 +31,10 @@ 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);