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