Changeset 4711:5ae94193666e in roaraudio for plugins/roard


Ignore:
Timestamp:
01/09/11 12:54:22 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

wrote new string matching function for selector meatching

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/roard/protocol-gopher.c

    r4708 r4711  
    7070}; 
    7171 
     72static int strselcmp(const char *s1, const char *s2); 
     73 
    7274static int send_menu (int client, struct roar_gopher_menu * menu, struct roar_vio_calls * vio); 
    7375static int send_text (int client, const char * text, struct roar_vio_calls * vio); 
     
    230232} 
    231233 
     234static int strselcmp(const char *s1, const char *s2) { 
     235 register char a, b; 
     236 
     237 if ( s1 == s2 ) 
     238  return 0; 
     239 
     240 if ( s1 == NULL || s2 == NULL ) 
     241  return -1; 
     242 
     243 for (; ; s1++, s2++) { 
     244  a = *s1; 
     245  b = *s2; 
     246 
     247  if ( a == '*' ) { 
     248   s1++; 
     249   a = *s1; 
     250   if ( a == 0 ) { 
     251    if ( b == 0 ) { 
     252     return 1; // no match! ('*' does not mach no-chars) 
     253    } else { 
     254     return 0; // match! (string ends with '*' and something not EOS is in b) 
     255    } 
     256   } else { 
     257    for (; *s2 != 0 && *s2 != a; s2++); 
     258    if ( a != *s2 ) 
     259     return 1; // no match! (did not find correct char) 
     260   } 
     261  } else if ( a == 0 || b == 0 ) { 
     262   if ( a == b ) { 
     263    return 0; // match! 
     264   } else { 
     265    return 1; // no match! (dffrent length) 
     266   } 
     267  } else if ( a != b ) { 
     268   return 1; // no match! (diffrent chars) 
     269  } 
     270 } 
     271 
     272 return -1; 
     273} 
     274 
    232275static int send_menu (int client, struct roar_gopher_menu * menu, struct roar_vio_calls * vio) { 
    233276 struct roar_buffer * buf; 
     
    358401 
    359402 for (i = 0; i < sizeof(g_gopher_items)/sizeof(*g_gopher_items); i++) { 
    360   if ( !strcmp(g_gopher_items[i].selector, inbuf) ) { 
     403  if ( !strselcmp(g_gopher_items[i].selector, inbuf) ) { 
    361404   c = &(g_gopher_items[i]); 
    362405   break; 
Note: See TracChangeset for help on using the changeset viewer.