parses out escape chars...like /t,/n
| 595 | |
| 596 | // parses out escape chars...like /t,/n |
| 597 | char *_parse_escape_chars(char *buffer) { |
| 598 | char tempbuffer[MAX_STRING_LENGTH]; |
| 599 | int t_index, b_index; |
| 600 | |
| 601 | t_index = 0; |
| 602 | b_index = 0; |
| 603 | |
| 604 | // search for a / |
| 605 | while (buffer[b_index] != '\0') { |
| 606 | // see if we are at a backslash |
| 607 | if (buffer[b_index] != '\\') { |
| 608 | tempbuffer[t_index] = buffer[b_index]; |
| 609 | t_index++; |
| 610 | b_index++; |
| 611 | } else { |
| 612 | // we are at a backslash, so determine what to do |
| 613 | b_index++; |
| 614 | switch (toupper(buffer[b_index])) { |
| 615 | case 'T': |
| 616 | tempbuffer[t_index] = '\t'; |
| 617 | break; |
| 618 | case 'N': |
| 619 | tempbuffer[t_index] = '\n'; |
| 620 | break; |
| 621 | case 'R': |
| 622 | tempbuffer[t_index] = '\r'; |
| 623 | break; |
| 624 | case '\"': |
| 625 | tempbuffer[t_index] = '\"'; |
| 626 | break; |
| 627 | case '\\': |
| 628 | tempbuffer[t_index] = '\\'; |
| 629 | break; |
| 630 | default: |
| 631 | // see if we have a number |
| 632 | if ((buffer[b_index] >= '0') && (buffer[b_index] <= '9')) { |
| 633 | // we have a number, so parse the value |
| 634 | uint8_t value = 0; |
| 635 | while ((buffer[b_index] >= '0') && (buffer[b_index] <= '9')) { |
| 636 | value = (value * 10) + buffer[b_index] - '0'; |
| 637 | b_index++; |
| 638 | } |
| 639 | // adjust b_index |
| 640 | b_index--; |
| 641 | tempbuffer[t_index] = value; |
| 642 | } |
| 643 | break; |
| 644 | } |
| 645 | b_index++; |
| 646 | t_index++; |
| 647 | } |
| 648 | } |
| 649 | tempbuffer[t_index] = '\0'; |
| 650 | strcpy(buffer, tempbuffer); |
| 651 | return buffer; |
| 652 | } |
| 653 | |
| 654 | GrowString::GrowString() { |
no outgoing calls
no test coverage detected