24 nargs += (*args ==
']' || *args ==
'[') ? 0 : 1;
72 if(*
arg ==
'[' || *
arg ==
']')
74 else if(!nargument || !*
arg)
86 const uint8_t *aligned_ptr = args-1;
91 arg_pos += 4-(arg_pos-aligned_ptr)%4;
116 arg_pos += 4-(arg_pos-arg_mem)%4;
117 return arg_pos-arg_mem;
119 blob_length |= (*arg_pos++ << 24);
120 blob_length |= (*arg_pos++ << 16);
121 blob_length |= (*arg_pos++ << 8);
122 blob_length |= (*arg_pos++);
124 blob_length += 4-blob_length%4;
125 arg_pos += blob_length;
126 return arg_pos-arg_mem;
140 const uint8_t *aligned_ptr = args-1;
145 arg_pos += 4-(arg_pos-((
uint8_t*)aligned_ptr))%4;
148 while(*args ==
'[' || *args ==
']')
164 const char *arguments,
168 va_start(va, arguments);
176 const char *arguments,
180 pos += strlen(address);
182 pos += 1+strlen(arguments);
186 unsigned arg_pos = 0;
191 char arg = *arguments++;
214 s = args[arg_pos++].
s;
215 assert(
s &&
"Input strings CANNOT be NULL");
221 i = args[arg_pos++].
b.
len;
238 size_t lsize,
size_t rsize,
241#define mfabs(val) (((val) >= 0) ? (val) : -(val))
249 for(
size_t i = 0;
i < lsize && rval; ++
i, ++lhs, ++rhs)
284 rval = 0 == memcmp(lhs->
val.
m, rhs->
val.
m, 4);
290 : (0 == strcmp(lhs->
val.
s, rhs->
val.
s));
312 size_t lsize,
size_t rsize,
315#define cmp_3way(val1,val2) (((val1) == (val2)) \
317 : (((val1) > (val2)) ? 1 : -1))
318#define mfabs(val) (((val) >= 0) ? (val) : -(val))
324 size_t min = lsize > rsize ? rsize : lsize;
325 for(
size_t i = 0;
i <
min && !rval; ++
i, ++lhs, ++rhs)
347 : ((lhs->
val.
f > rhs->
val.
f) ? 1 : -1);
355 : ((lhs->
val.
d > rhs->
val.
d) ? 1 : -1);
366 rval = (lhs->
val.
t == 1)
375 rval = memcmp(lhs->
val.
m, rhs->
val.
m, 4);
387 int32_t minlen = (lbs < rbs) ? lbs : rbs;
389 if(lbs != rbs && !rval)
404 rval = (lhs->
type > rhs->
type) ? 1 : -1;
408 if(rval == 0 && lsize != rsize)
410 return (lsize > rsize) ? 1 : -1;
421 unsigned arg_pos = 0;
424 while(arg_pos < nargs)
429 args[arg_pos++].
h = va_arg(ap->
a, int64_t);
432 args[arg_pos++].
d = va_arg(ap->
a,
double);
437 args[arg_pos++].
i = va_arg(ap->
a,
int);
440 midi_tmp = va_arg(ap->
a,
uint8_t *);
441 args[arg_pos].
m[0] = midi_tmp[0];
442 args[arg_pos].
m[1] = midi_tmp[1];
443 args[arg_pos].
m[2] = midi_tmp[2];
444 args[arg_pos++].
m[3] = midi_tmp[3];
448 args[arg_pos++].
s = va_arg(ap->
a,
const char *);
451 args[arg_pos].
b.
len = va_arg(ap->
a,
int);
452 args[arg_pos].
b.
data = va_arg(ap->
a,
unsigned char *);
456 args[arg_pos++].
f = va_arg(ap->
a,
double);
462 args[arg_pos++].
T = arg_str[-1];
473 va_start(va.
a, arg_str);
482 for(
size_t i=0;
i<nargs; ++
i, ++arg_str, ++args)
484 args->
type = *arg_str;
492 va_start(va, arg_str);
500 const char *arguments,
503 const unsigned nargs =
nreserved(arguments);
518 const char *arguments,
521 const size_t total_len =
vsosc_null(address, arguments, args);
528 memset(buffer, 0, len);
532 memset(buffer, 0, total_len);
536 buffer[pos++] = *address++;
543 const char *arg_str = arguments;
545 buffer[pos++] = *arg_str++;
550 unsigned arg_pos = 0;
553 char arg = *arguments++;
559 const unsigned char *
u;
565 d = args[arg_pos++].
t;
566 buffer[pos++] = ((
d>>56) & 0xff);
567 buffer[pos++] = ((
d>>48) & 0xff);
568 buffer[pos++] = ((
d>>40) & 0xff);
569 buffer[pos++] = ((
d>>32) & 0xff);
570 buffer[pos++] = ((
d>>24) & 0xff);
571 buffer[pos++] = ((
d>>16) & 0xff);
572 buffer[pos++] = ((
d>>8) & 0xff);
573 buffer[pos++] = (
d & 0xff);
580 i = args[arg_pos++].
i;
581 buffer[pos++] = ((
i>>24) & 0xff);
582 buffer[pos++] = ((
i>>16) & 0xff);
583 buffer[pos++] = ((
i>>8) & 0xff);
584 buffer[pos++] = (
i & 0xff);
589 m = args[arg_pos++].
m;
590 buffer[pos++] =
m[0];
591 buffer[pos++] =
m[1];
592 buffer[pos++] =
m[2];
593 buffer[pos++] =
m[3];
598 s = args[arg_pos++].
s;
600 buffer[pos++] = *
s++;
605 b = args[arg_pos++].
b;
607 buffer[pos++] = ((
i>>24) & 0xff);
608 buffer[pos++] = ((
i>>16) & 0xff);
609 buffer[pos++] = ((
i>>8) & 0xff);
610 buffer[pos++] = (
i & 0xff);
614 buffer[pos++] = *
u++;
652 result.t |= (((uint64_t)*arg_pos++) << 56);
653 result.t |= (((uint64_t)*arg_pos++) << 48);
654 result.t |= (((uint64_t)*arg_pos++) << 40);
655 result.t |= (((uint64_t)*arg_pos++) << 32);
656 result.t |= (((uint64_t)*arg_pos++) << 24);
657 result.t |= (((uint64_t)*arg_pos++) << 16);
658 result.t |= (((uint64_t)*arg_pos++) << 8);
659 result.t |= (((uint64_t)*arg_pos++));
665 result.i |= (*arg_pos++ << 24);
666 result.i |= (*arg_pos++ << 16);
667 result.i |= (*arg_pos++ << 8);
677 result.b.len |= (*arg_pos++ << 24);
678 result.b.len |= (*arg_pos++ << 16);
679 result.b.len |= (*arg_pos++ << 8);
680 result.b.len |= (*arg_pos++);
681 result.b.data = (
unsigned char *)arg_pos;
685 result.s = (
char *)arg_pos;
695 while(*args ==
'[' || *args ==
']')
741 return pos<ring[0].
len ? ring[0].
data[pos] :
742 ((pos-ring[0].
len)<ring[1].
len ? ring[1].
data[pos-ring[0].
len] : 0x00);
750 advance =
deref(pos+0, ring) << (8*3) |
751 deref(pos+1, ring) << (8*2) |
752 deref(pos+2, ring) << (8*1) |
753 deref(pos+3, ring) << (8*0);
758 return pos <= (ring[0].
len+ring[1].
len) ? pos : 0;
765 if(
deref(0,ring) ==
'#' &&
766 deref(1,ring) ==
'b' &&
767 deref(2,ring) ==
'u' &&
768 deref(3,ring) ==
'n' &&
769 deref(4,ring) ==
'd' &&
770 deref(5,ring) ==
'l' &&
771 deref(6,ring) ==
'e' &&
772 deref(7,ring) ==
'\0')
778 while(
deref(pos++,ring));
782 for(
int i=0;
i<4; ++
i)
783 if(
deref(++pos, ring))
786 if(
deref(pos, ring) !=
',')
789 unsigned aligned_pos = pos;
790 int arguments = pos+1;
791 while(
deref(++pos,ring));
792 pos += 4-(pos-aligned_pos)%4;
794 unsigned toparse = 0;
796 int arg = arguments-1;
824 while(
deref(++pos,ring));
825 pos += 4-(pos-aligned_pos)%4;
830 i |= (
deref(pos++,ring) << 24);
831 i |= (
deref(pos++,ring) << 16);
832 i |= (
deref(pos++,ring) << 8);
835 if((pos-aligned_pos)%4)
836 pos += 4-(pos-aligned_pos)%4;
845 return pos <= (ring[0].
len+ring[1].
len) ? pos : 0;
859 const char *tmp =
msg;
860 for(
unsigned i=0;
i<len; ++
i) {
869 const size_t offset1 = tmp-
msg;
870 size_t offset2 = tmp-
msg;
871 for(; offset2<len; offset2++) {
878 if(offset2-offset1 > 4)
881 if((offset2 % 4) != 0)
885 return observed_length == len;
890 arg |= (((uint64_t)*arg_pos++) << 56);
891 arg |= (((uint64_t)*arg_pos++) << 48);
892 arg |= (((uint64_t)*arg_pos++) << 40);
893 arg |= (((uint64_t)*arg_pos++) << 32);
894 arg |= (((uint64_t)*arg_pos++) << 24);
895 arg |= (((uint64_t)*arg_pos++) << 16);
896 arg |= (((uint64_t)*arg_pos++) << 8);
897 arg |= (((uint64_t)*arg_pos++));
913 buffer[0] = ((
d>>56) & 0xff);
914 buffer[1] = ((
d>>48) & 0xff);
915 buffer[2] = ((
d>>40) & 0xff);
916 buffer[3] = ((
d>>32) & 0xff);
917 buffer[4] = ((
d>>24) & 0xff);
918 buffer[5] = ((
d>>16) & 0xff);
919 buffer[6] = ((
d>>8) & 0xff);
920 buffer[7] = ((
d>>0) & 0xff);
925 buffer[0] = ((
d>>24) & 0xff);
926 buffer[1] = ((
d>>16) & 0xff);
927 buffer[2] = ((
d>>8) & 0xff);
928 buffer[3] = ((
d>>0) & 0xff);
931size_t rtosc_bundle(
char *buffer,
size_t len, uint64_t tt,
int elms, ...)
933 char *_buffer = buffer;
934 memset(buffer, 0, len);
935 strcpy(buffer,
"#bundle");
941 for(
int i=0;
i<elms; ++
i) {
942 const char *
msg = va_arg(va,
const char*);
952 return buffer-_buffer;
956#define POS ((size_t)(((const char *)lengths) - buffer))
981 return (
const char*) (elm==elm_pos?lengths+1:
NULL);
999 return !strcmp(
msg,
"#bundle");
float arg(const fft_t *freqs, off_t x)
Definition OscilGen.cpp:58
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
unsigned * m
Definition inflate.c:1559
unsigned d
Definition inflate.c:940
struct huft * u[BMAX]
Definition inflate.c:1583
register unsigned i
Definition inflate.c:1575
unsigned s
Definition inflate.c:1555
int int32_t
Definition mid.cpp:97
unsigned int uint32_t
Definition mid.cpp:100
unsigned char uint8_t
Definition mid.cpp:98
const char * msg
Definition missing_descriptor.c:20
#define min(x, y)
Definition os.h:74
size_t rtosc_message_length(const char *msg, size_t len)
Definition rtosc.c:848
size_t rtosc_vmessage(char *buffer, size_t len, const char *address, const char *arguments, va_list ap)
Definition rtosc.c:497
void rtosc_v2args(rtosc_arg_t *args, size_t nargs, const char *arg_str, rtosc_va_list_t *ap)
Definition rtosc.c:418
size_t rtosc_bundle(char *buffer, size_t len, uint64_t tt, int elms,...)
Definition rtosc.c:931
static void emplace_uint64(uint8_t *buffer, uint64_t d)
Definition rtosc.c:911
static unsigned arg_start(const char *msg_)
Definition rtosc.c:81
unsigned rtosc_narguments(const char *msg)
Definition rtosc.c:19
static unsigned arg_size(const uint8_t *arg_mem, char type)
Definition rtosc.c:95
size_t rtosc_amessage(char *buffer, size_t len, const char *address, const char *arguments, const rtosc_arg_t *args)
Definition rtosc.c:515
size_t rtosc_message_ring_length(ring_t *ring)
Definition rtosc.c:762
const char * rtosc_argument_string(const char *msg)
Definition rtosc.c:11
static const char * advance_past_dummy_args(const char *args)
Definition rtosc.c:693
static rtosc_arg_t extract_arg(const uint8_t *arg_pos, char type)
Definition rtosc.c:630
const char * rtosc_bundle_fetch(const char *buffer, unsigned elm)
Definition rtosc.c:972
size_t rtosc_message(char *buffer, size_t len, const char *address, const char *arguments,...)
Definition rtosc.c:161
size_t rtosc_bundle_size(const char *buffer, unsigned elm)
Definition rtosc.c:984
rtosc_arg_itr_t rtosc_itr_begin(const char *msg)
Definition rtosc.c:700
size_t rtosc_bundle_elements(const char *buffer, size_t len)
Definition rtosc.c:957
#define POS
Definition rtosc.c:956
static uint32_t extract_uint32(const uint8_t *arg_pos)
Definition rtosc.c:901
int rtosc_arg_vals_eq(rtosc_arg_val_t *lhs, rtosc_arg_val_t *rhs, size_t lsize, size_t rsize, const rtosc_cmp_options *opt)
Definition rtosc.c:237
char rtosc_type(const char *msg, unsigned nargument)
Definition rtosc.c:67
static int has_reserved(char type)
Definition rtosc.c:28
void rtosc_v2argvals(rtosc_arg_val_t *args, size_t nargs, const char *arg_str, va_list ap)
Definition rtosc.c:478
static uint64_t extract_uint64(const uint8_t *arg_pos)
Definition rtosc.c:887
int rtosc_itr_end(rtosc_arg_itr_t itr)
Definition rtosc.c:727
int rtosc_arg_vals_cmp(rtosc_arg_val_t *lhs, rtosc_arg_val_t *rhs, size_t lsize, size_t rsize, const rtosc_cmp_options *opt)
Definition rtosc.c:311
rtosc_arg_val_t rtosc_itr_next(rtosc_arg_itr_t *itr)
Definition rtosc.c:709
static unsigned nreserved(const char *args)
Definition rtosc.c:58
uint64_t rtosc_bundle_timetag(const char *msg)
Definition rtosc.c:1002
void rtosc_2argvals(rtosc_arg_val_t *args, size_t nargs, const char *arg_str,...)
Definition rtosc.c:489
static const rtosc_cmp_options default_cmp_options
Definition rtosc.c:235
void rtosc_2args(rtosc_arg_t *args, size_t nargs, const char *arg_str,...)
Definition rtosc.c:470
int rtosc_bundle_p(const char *msg)
Definition rtosc.c:997
rtosc_arg_t rtosc_argument(const char *msg, unsigned idx)
Definition rtosc.c:732
static void emplace_uint32(uint8_t *buffer, uint32_t d)
Definition rtosc.c:923
static unsigned arg_off(const char *msg, unsigned idx)
Definition rtosc.c:133
static size_t bundle_ring_length(ring_t *ring)
Definition rtosc.c:745
static unsigned char deref(unsigned pos, ring_t *ring)
Definition rtosc.c:739
bool rtosc_valid_message_p(const char *msg, size_t len)
Definition rtosc.c:854
static size_t vsosc_null(const char *address, const char *arguments, const rtosc_arg_t *args)
Definition rtosc.c:175
#define cmp_3way(val1, val2)
char * data
Definition rtosc.h:230
size_t len
Definition rtosc.h:231
const uint8_t * value_pos
Definition rtosc.h:124
const char * type_pos
Definition rtosc.h:123
rtosc_arg_t val
Definition rtosc.h:129
char type
Definition rtosc.h:128
uint8_t * data
Definition rtosc.h:43
int32_t len
Definition rtosc.h:42
double float_tolerance
< tolerance to when two floats or doubles are equal
Definition rtosc.h:135
va_list container, required for passing va_list as pointers to functions
Definition rtosc.h:166
va_list a
Definition rtosc.h:166
int32_t i
Definition rtosc.h:47
rtosc_blob_t b
Definition rtosc.h:55
float f
Definition rtosc.h:49
char T
Definition rtosc.h:48
uint64_t t
Definition rtosc.h:52
uint8_t m[4]
Definition rtosc.h:53
const char * s
Definition rtosc.h:54
int64_t h
Definition rtosc.h:51
double d
Definition rtosc.h:50
memcpy(hh, h, RAND_HEAD_LEN)
int result
Definition process.c:1455