Changeset 5602:6d421545ca98 in roaraudio for plugins
- Timestamp:
- 07/30/12 16:59:54 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/roard/protocol-gopher.c
r5381 r5602 90 90 }; 91 91 92 static int strselcmp(const char *s1, const char *s2);93 static ssize_t strseltok(const char *s1, char *s2, char ** tok, size_t toks);94 95 92 static char * _aprintf(size_t sizehint, const char * format, ...); 96 93 … … 141 138 size_t len; 142 139 143 toks = strseltok(sitem->selector, selector, &tok, 1);140 toks = roar_mm_strseltok(sitem->selector, selector, &tok, 1); 144 141 145 142 if ( toks == -1 ) … … 286 283 memset(items, 0, sizeof(items)); 287 284 288 toks = strseltok(sitem->selector, selector, &tok, 1);285 toks = roar_mm_strseltok(sitem->selector, selector, &tok, 1); 289 286 if ( toks == -1 ) 290 287 return -1; … … 361 358 memset(items, 0, sizeof(items)); 362 359 363 toks = strseltok(sitem->selector, selector, &tok, 1);360 toks = roar_mm_strseltok(sitem->selector, selector, &tok, 1); 364 361 if ( toks == -1 ) 365 362 return -1; … … 475 472 int stream = -1; 476 473 477 toks = strseltok(sitem->selector, selector, tok, 5);474 toks = roar_mm_strseltok(sitem->selector, selector, tok, 5); 478 475 479 476 if ( toks != 5 ) … … 545 542 546 543 return 0; 547 }548 549 static int strselcmp(const char *s1, const char *s2) {550 register char a, b;551 552 if ( s1 == s2 )553 return 0;554 555 if ( s1 == NULL || s2 == NULL )556 return -1;557 558 for (; ; s1++, s2++) {559 a = *s1;560 b = *s2;561 562 if ( a == '*' ) {563 s1++;564 a = *s1;565 if ( a == 0 ) {566 if ( b == 0 ) {567 return 1; // no match! ('*' does not mach no-chars)568 } else {569 return 0; // match! (string ends with '*' and something not EOS is in b)570 }571 } else {572 for (; *s2 != 0 && *s2 != a; s2++);573 if ( a != *s2 )574 return 1; // no match! (did not find correct char)575 }576 } else if ( a == 0 || b == 0 ) {577 if ( a == b ) {578 return 0; // match!579 } else {580 return 1; // no match! (dffrent length)581 }582 } else if ( a != b ) {583 return 1; // no match! (diffrent chars)584 }585 }586 587 return -1;588 }589 590 static ssize_t strseltok(const char *s1, char *s2, char ** tok, size_t toks) {591 register char a, b;592 size_t idx = 0;593 594 if ( s1 == NULL || s2 == NULL )595 return -1;596 597 for (; ; s1++, s2++) {598 a = *s1;599 b = *s2;600 601 if ( a == 0 || b == 0 ) {602 if ( a == b ) {603 return idx;604 } else {605 return -1;606 }607 } else if ( a == '*' ) {608 s1++;609 a = *s1;610 if ( idx == toks )611 return -1;612 613 tok[idx] = s2;614 idx++;615 616 for (; *s2 != 0 && *s2 != a; s2++);617 618 if ( a == 0 )619 return idx;620 621 if ( *s1 == 0 )622 return -1;623 624 *s2 = 0;625 }626 }627 628 return -1;629 544 } 630 545 … … 796 711 797 712 for (i = 0; i < sizeof(g_gopher_items)/sizeof(*g_gopher_items); i++) { 798 // if ( ! strselcmp(g_gopher_items[i].selector, inbuf) ) {799 if ( ! strselcmp(g_gopher_items[i].selector, inbuf) ) {713 // if ( !roar_mm_strselcmp(g_gopher_items[i].selector, inbuf) ) { 714 if ( !roar_mm_strselcmp(g_gopher_items[i].selector, inbuf) ) { 800 715 c = &(g_gopher_items[i]); 801 716 break;
Note: See TracChangeset
for help on using the changeset viewer.