chris@163: /** chris@163: * Copyright (c) 2014, 2015, Enzien Audio Ltd. chris@163: * chris@163: * Permission to use, copy, modify, and/or distribute this software for any chris@163: * purpose with or without fee is hereby granted, provided that the above chris@163: * copyright notice and this permission notice appear in all copies. chris@163: * chris@163: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH chris@163: * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY chris@163: * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, chris@163: * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM chris@163: * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR chris@163: * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR chris@163: * PERFORMANCE OF THIS SOFTWARE. chris@163: */ chris@163: chris@163: #include "HvBase.h" chris@163: chris@163: void ctx_setBasePath(HvBase *const _c, const char *basePath) { chris@163: hv_free(_c->basePath); chris@163: if (basePath != NULL) { chris@163: hv_size_t len = (hv_size_t) hv_strlen(basePath); chris@163: _c->basePath = (char *) hv_malloc((len+1)*sizeof(char)); chris@163: hv_strncpy(_c->basePath, basePath, len); chris@163: } chris@163: } chris@163: chris@163: void ctx_cancelMessage(HvBase *_c, HvMessage *m, void (*sendMessage)(HvBase *, int, const HvMessage *)) { chris@163: mq_removeMessage(&_c->mq, m, sendMessage); chris@163: } chris@163: chris@163: void ctx_scheduleMessageForReceiverV(HvBase *const _c, const char *name, chris@163: const hv_uint32_t timestamp, const char *format, ...) { chris@163: va_list ap; chris@163: va_start(ap, format); chris@163: chris@163: const int numElem = (int) hv_strlen(format); chris@163: HvMessage *m = HV_MESSAGE_ON_STACK(numElem); chris@163: msg_init(m, numElem, timestamp); chris@163: for (int i = 0; i < numElem; i++) { chris@163: switch (format[i]) { chris@163: case 'b': msg_setBang(m,i); break; chris@163: case 'f': msg_setFloat(m, i, (float) va_arg(ap, double)); break; chris@163: case 's': msg_setSymbol(m, i, (char *) va_arg(ap, char *)); break; chris@163: default: break; chris@163: } chris@163: } chris@163: _c->f_scheduleMessageForReceiver(_c, name, m); chris@163: chris@163: va_end(ap); chris@163: }