adding validated services? patching forcad_local.py
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static void extract(const char *json) {
|
||||
char tone_sequences_json[8192] = "[]";
|
||||
const char *ts_pos = strstr(json, "\"toneSequences\":");
|
||||
if (ts_pos)
|
||||
{
|
||||
const char *p = strchr(ts_pos, '[');
|
||||
if (p)
|
||||
{
|
||||
int depth = 0;
|
||||
const char *q = p;
|
||||
while (*q && (q - p) < (int)sizeof(tone_sequences_json) - 2)
|
||||
{
|
||||
if (*q == '[') depth++;
|
||||
else if (*q == ']') { depth--; if (depth == 0) { q++; break; } }
|
||||
q++;
|
||||
}
|
||||
size_t len = (size_t)(q - p);
|
||||
if (len > 0 && len < sizeof(tone_sequences_json))
|
||||
{
|
||||
memcpy(tone_sequences_json, p, len);
|
||||
tone_sequences_json[len] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("tone_sequences=%s\n", tone_sequences_json);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
const char *input =
|
||||
"{\"name\":\"xxxsed\",\"description\":\"\",\"toneSequences\":[{\"id\":1758442926199.0464,\"baseNote\":60,\"intervalType\":\"unison\",\"chordType\":\"none\",\"tempo\":120,\"duration\":4,\"notes\":[60]}]}";
|
||||
extract(input);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user