Changeset 4705:109ee6f17831 in roaraudio for plugins/roard


Ignore:
Timestamp:
01/06/11 02:37:55 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

got gopher finally working, now moving myself into sleepingbag device...

File:
1 edited

Legend:

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

    r4704 r4705  
    7171} 
    7272 
    73 static int send_menu (int client, struct roar_gopher_menu * menu) { 
     73static int send_menu (int client, struct roar_gopher_menu * menu, struct roar_vio_calls * vio) { 
    7474 struct roar_buffer * buf; 
    7575 struct roar_gopher_menu_item * item; 
     
    7878 void * data; 
    7979 char * chardata; 
    80  char * host; 
     80 const char * host; 
    8181 unsigned int port; 
     82 struct roar_sockname sockaddr; 
     83 
     84 if ( roar_vio_ctl(vio, ROAR_VIO_CTL_GET_SOCKNAME, &sockaddr) == -1 ) { 
     85  memset(&sockaddr, 0, sizeof(sockaddr)); 
     86 } 
    8287 
    8388 for (i = 0; i < menu->items_len; i++) { 
    8489  item = &(menu->items[i]); 
    85   if ( roar_buffer_new_data(&buf, len, &data) == -1 ) 
    86    return -1; 
     90  if ( roar_buffer_new_data(&buf, len, &data) == -1 ) { 
     91   if ( sockaddr.addr != NULL ) 
     92    roar_mm_free(sockaddr.addr); 
     93   return -1; 
     94  }  
    8795 
    8896  chardata = data; 
     
    93101    break; 
    94102   default: 
    95      host = item->host; 
    96      port = item->port; 
     103     host = item->host == NULL ? sockaddr.addr : item->host; 
     104     port = item->port ==    0 ? sockaddr.port : item->port; 
    97105     snprintf(data, len-1, "%c%s\t%s\t%s\t%u\r\n", item->type, item->name, item->selector, host, port); 
    98106    break; 
     
    106114 } 
    107115 
    108  return 0; 
    109 } 
    110  
    111 static int send_text (int client, const char * text) { 
     116 if ( sockaddr.addr != NULL ) 
     117  roar_mm_free(sockaddr.addr); 
     118 
     119 return 0; 
     120} 
     121 
     122static int send_text (int client, const char * text, struct roar_vio_calls * vio) { 
    112123 struct roar_buffer * buf; 
    113124 void * data; 
     
    199210 switch (c->type) { 
    200211  case _DIR: 
    201     funcret = send_menu(client, &(c->menu)); 
     212    funcret = send_menu(client, &(c->menu), vio); 
    202213   break; 
    203214  case _FILE: 
    204     funcret = send_text(client, c->text); 
     215    funcret = send_text(client, c->text, vio); 
    205216   break; 
    206217  default: 
Note: See TracChangeset for help on using the changeset viewer.