void FarCallback(void *context, int arglen, const void *args, OSCTimeTag when, NetworkReturnAddressPtr returnAddr) { const char *charArgs = args; char *error, *secondArg; printf("Far callback called!\n"); printf(" Context %p, arglen %d, args %p, TT %llx, returnAddr %p\n", context, arglen, args, when, returnAddr); secondArg = OSCDataAfterAlignedString(charArgs, charArgs+arglen, &error); if (secondArg == 0) { printf("OSCDataAfterAlignedString error! %s\n", error); } printf(" Args as strings: %s, %s\n", charArgs, secondArg); printf(" Return address as string: \"%s\"\n", (char *) returnAddr); printf("\n"); }
static Boolean ParseMessage(queuedData *qd) { /* Fill in all the information we'll need to execute the message as quickly as possible when the time comes. This means figuring out where the address ends and the arguments begin, and also pattern matching the address to find the callbacks associated with it. The message may be something we have to invoke now, or it may be some message scheduled for the future that's just waiting on the queue; this procedure doesn't care. */ char *args; /* char * so we can do pointer subtraction */ int messageLen; char *DAAS_errormsg; if (qd->type != MESSAGE) { fatal_error("This can't happen: message isn't a message!"); } args = OSCDataAfterAlignedString(qd->data.message.messageName, qd->data.message.messageName+qd->data.message.length, &DAAS_errormsg); if (args == 0) { OSCProblem("Bad message name string: %s\n", DAAS_errormsg); DropMessage(qd->data.message.messageName, qd->data.message.length, qd->myPacket); return FALSE; } qd->data.message.args = args; messageLen = args - qd->data.message.messageName; qd->data.message.argLength = qd->data.message.length - messageLen; qd->data.message.callbacks = OSCDispatchMessage(qd->data.message.messageName); if (qd->data.message.callbacks == 0) { OSCWarning("Message pattern \"%s\" did not correspond to any address in the synth.", qd->data.message.messageName); return FALSE; } return TRUE; }
Boolean OSCParseStringList(const char *result[], int *numStrings, int maxStrings, const char *args, int numBytes) { int numFound; const char *p; const char *boundary = args + numBytes; char *errorMessage; p = args; for (numFound = 0; numFound < maxStrings; ++numFound) { if (p == boundary) { *numStrings = numFound; return TRUE; } result[numFound] = p; p = OSCDataAfterAlignedString(p, boundary, &errorMessage); if (p == 0) return FALSE; } return FALSE; }