| 505 | } |
| 506 | |
| 507 | void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf, |
| 508 | void *context) |
| 509 | { |
| 510 | const char *ptr = str; |
| 511 | |
| 512 | /* Parse key=value pairs. */ |
| 513 | for (;;) { |
| 514 | const char *key; |
| 515 | char *dest = NULL, *dest_end; |
| 516 | int key_len, dest_len = 0; |
| 517 | |
| 518 | /* Skip whitespace and potential commas. */ |
| 519 | while (*ptr && (av_isspace(*ptr) || *ptr == ',')) |
| 520 | ptr++; |
| 521 | if (!*ptr) |
| 522 | break; |
| 523 | |
| 524 | key = ptr; |
| 525 | |
| 526 | if (!(ptr = strchr(key, '='))) |
| 527 | break; |
| 528 | ptr++; |
| 529 | key_len = ptr - key; |
| 530 | |
| 531 | callback_get_buf(context, key, key_len, &dest, &dest_len); |
| 532 | dest_end = dest ? dest + dest_len - 1 : NULL; |
| 533 | |
| 534 | if (*ptr == '\"') { |
| 535 | ptr++; |
| 536 | while (*ptr && *ptr != '\"') { |
| 537 | if (*ptr == '\\') { |
| 538 | if (!ptr[1]) |
| 539 | break; |
| 540 | if (dest && dest < dest_end) |
| 541 | *dest++ = ptr[1]; |
| 542 | ptr += 2; |
| 543 | } else { |
| 544 | if (dest && dest < dest_end) |
| 545 | *dest++ = *ptr; |
| 546 | ptr++; |
| 547 | } |
| 548 | } |
| 549 | if (*ptr == '\"') |
| 550 | ptr++; |
| 551 | } else { |
| 552 | for (; *ptr && !(av_isspace(*ptr) || *ptr == ','); ptr++) |
| 553 | if (dest && dest < dest_end) |
| 554 | *dest++ = *ptr; |
| 555 | } |
| 556 | if (dest) |
| 557 | *dest = 0; |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | int avformat_network_init(void) |
| 562 | { |
no test coverage detected