X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=liblttngctl%2Flttngctl.c;h=51f5f6572e1a87da43400a439701efef1ca1d333;hp=14055ed48451b652b06db40e72e7b1de013e3bff;hb=8e0dbb653e6872725775d640e2a64d4b08cceb3a;hpb=cd80958d00fddabced5fbd60641978516a01e29e diff --git a/liblttngctl/lttngctl.c b/liblttngctl/lttngctl.c index 14055ed48..51f5f6572 100644 --- a/liblttngctl/lttngctl.c +++ b/liblttngctl/lttngctl.c @@ -47,7 +47,7 @@ static int connected; */ static void copy_string(char *dst, const char *src, size_t len) { - if (src) { + if (src && dst) { strncpy(dst, src, len); /* Enforce the NULL terminated byte */ dst[len - 1] = '\0'; @@ -333,6 +333,24 @@ void lttng_destroy_handle(struct lttng_handle *handle) } } +/* + * Register an outside consumer. + */ +int lttng_register_consumer(struct lttng_handle *handle, + const char *socket_path) +{ + struct lttcomm_session_msg lsm; + + lsm.cmd_type = LTTNG_REGISTER_CONSUMER; + copy_string(lsm.session.name, handle->session_name, + sizeof(lsm.session.name)); + copy_lttng_domain(&lsm.domain, &handle->domain); + + copy_string(lsm.u.reg.path, socket_path, sizeof(lsm.u.reg.path)); + + return ask_sessiond(&lsm, NULL); +} + /* * Start tracing for all trace of the session. */