Changeset 4712:f3f7ab98b6ac in roaraudio for plugins


Ignore:
Timestamp:
01/09/11 13:40:29 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

some preparement for parameterized selector usage

File:
1 edited

Legend:

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

    r4711 r4712  
    3434#define _SOUND ROAR_GOPHER_TYPE_SOUND 
    3535 
    36 static int scb_status_txt (int client, struct roar_vio_calls * vio, const char * selector, char ** text); 
    37 static int scb_clients    (int client, struct roar_vio_calls * vio, const char * selector, char ** text); 
    38 static int scb_streams    (int client, struct roar_vio_calls * vio, const char * selector, char ** text); 
     36static struct item; 
     37 
     38static int scb_status_txt (int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem); 
     39static int scb_clients    (int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem); 
     40static int scb_streams    (int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem); 
    3941 
    4042static struct roar_gopher_menu_item g_gopher_root_menu[] = { 
     
    5355 int dir; 
    5456 const char * text; 
    55  int (*cb)(int client, struct roar_vio_calls * vio, const char * selector, char ** text); 
     57 int (*cb)(int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem); 
    5658} g_gopher_items[] = { 
    5759 {.selector = "", .type = _DIR, 
     
    7173 
    7274static int strselcmp(const char *s1, const char *s2); 
     75static ssize_t strseltok(const char *s1, char *s2, char ** tok, size_t toks); 
    7376 
    7477static int send_menu (int client, struct roar_gopher_menu * menu, struct roar_vio_calls * vio); 
     
    7780 
    7881// SCBs: 
    79 static int scb_status_txt (int client, struct roar_vio_calls * vio, const char * selector, char ** text) { 
     82static int scb_status_txt (int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem) { 
    8083 const size_t len = 1024; 
    8184 const char * server_version = NULL; 
     
    110113} 
    111114 
    112 static int scb_clients    (int client, struct roar_vio_calls * vio, const char * selector, char ** text) { 
     115static int scb_clients    (int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem) { 
    113116 struct roar_gopher_menu_item items[ROAR_CLIENTS_MAX]; 
    114117 struct roar_gopher_menu menu = {.flags = 0, .items = items, .items_len = 0}; 
     
    164167} 
    165168 
    166 static int scb_streams    (int client, struct roar_vio_calls * vio, const char * selector, char ** text) { 
     169static int scb_streams    (int client, struct roar_vio_calls * vio, const char * selector, char ** text, struct item * sitem) { 
    167170 struct roar_gopher_menu_item items[ROAR_STREAMS_MAX]; 
    168171 struct roar_gopher_menu menu = {.flags = 0, .items = items, .items_len = 0}; 
     
    273276} 
    274277 
     278static ssize_t strseltok(const char *s1, char *s2, char ** tok, size_t toks) { 
     279 register char a, b; 
     280 size_t idx = 0; 
     281 
     282 if ( s1 == NULL || s2 == NULL ) 
     283  return -1; 
     284 
     285 for (; ; s1++, s2++) { 
     286  a = *s1; 
     287  b = *s2; 
     288 
     289  if ( a == 0 || b == 0 ) { 
     290   if ( a == b ) { 
     291    return idx; 
     292   } else { 
     293    return -1; 
     294   } 
     295  } else if ( a == '*' ) { 
     296   s1++; 
     297   a = *s1; 
     298   if ( idx == toks ) 
     299    return -1; 
     300 
     301   tok[idx] = s2; 
     302   idx++; 
     303 
     304   for (; *s2 != 0 && *s2 != a; s2++); 
     305 
     306   if ( a == 0 ) 
     307    return idx; 
     308 
     309   if ( *s1 == 0 ) 
     310    return -1; 
     311 
     312   *s2 = 0; 
     313  } 
     314 } 
     315 
     316 return -1; 
     317} 
     318 
    275319static int send_menu (int client, struct roar_gopher_menu * menu, struct roar_vio_calls * vio) { 
    276320 struct roar_buffer * buf; 
     
    414458 if ( c->cb != NULL ) { 
    415459  text = NULL; 
    416   funcret = c->cb(client, vio, inbuf, &text); 
     460  funcret = c->cb(client, vio, inbuf, &text, c); 
    417461 
    418462  if ( funcret == 0 && text != NULL ) 
Note: See TracChangeset for help on using the changeset viewer.