Ignore:
Timestamp:
11/09/12 02:51:16 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

commit 1: Moved protocol support into new plugins protocol-esound, protocol-rplay and protocol-gopher (Closes: #311)

File:
1 edited

Legend:

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

    r5739 r5740  
    2424 */ 
    2525 
    26 #include "roard.h" 
     26#include <roard/include/roard.h> 
     27 
     28#ifndef DISTRIBUTION_VERSION_STRING 
     29#define DISTRIBUTION_VERSION_STRING "" 
     30#endif 
     31#ifndef PACKAGE_VERSION 
     32#define PACKAGE_VERSION "" 
     33#endif 
     34#ifndef DEVICE_VENDOR_STRING 
     35#define DEVICE_VENDOR_STRING "" 
     36#endif 
    2737 
    2838#ifndef ROAR_WITHOUT_DCOMP_EMUL_GOPHER 
     
    93103 
    94104static int send_menu (int client, struct roar_gopher_menu * menu, struct roar_vio_calls * vio); 
    95 static int send_text (int client, const char * text, struct roar_vio_calls * vio); 
     105static int send_text (const char * text, struct roar_buffer ** obuffer); 
    96106 
    97107 
     
    100110 const size_t len = 1024; 
    101111 const char * server_version = NULL; 
     112 
     113 (void)client, (void)vio, (void)selector, (void)text, (void)sitem; 
    102114 
    103115 if ( DISTRIBUTION_VERSION_STRING[0] == 0 ) { 
     
    138150 size_t len; 
    139151 
     152 (void)client, (void)vio; 
     153 
    140154 toks = roar_mm_strseltok(sitem->selector, selector, &tok, 1); 
    141155 
     
    169183 size_t i; 
    170184 int ret; 
     185 
     186 (void)selector, (void)text, (void)sitem; 
    171187 
    172188 memset(items, 0, sizeof(items)); 
     
    224240 int ret; 
    225241 
     242 (void)selector, (void)text, (void)sitem; 
     243 
    226244 memset(items, 0, sizeof(items)); 
    227245 
     
    281299 char tmp[80]; 
    282300 
     301 (void)text; 
     302 
    283303 memset(items, 0, sizeof(items)); 
    284304 
     
    356376 int id; 
    357377 
     378 (void)text; 
     379 
    358380 memset(items, 0, sizeof(items)); 
    359381 
     
    391413                            s->info.rate, s->info.bits, s->info.channels, roar_codec2str(s->info.codec)); 
    392414 
    393  if ( ss->codec_orgi != -1 && ss->codec_orgi != s->info.codec ) { 
     415 if ( ss->codec_orgi != ROAR_AUDIO_INFO_INVALID && ss->codec_orgi != s->info.codec ) { 
    394416  item = &(items[menu.items_len++]); 
    395417  item->type = _INFO; 
     
    431453 size_t i; 
    432454 
     455 (void)selector, (void)text, (void)sitem; 
     456 
    433457 memset(items, 0, sizeof(items)); 
    434458 
     
    472496 int stream = -1; 
    473497 
     498 (void)vio, (void)text; 
     499 
    474500 toks = roar_mm_strseltok(sitem->selector, selector, tok, 5); 
    475501 
     
    496522 info.codec    = roar_str2codec(tok[4]); 
    497523 
    498  if ( info.codec == -1 ) 
     524 if ( info.codec == ROAR_AUDIO_INFO_INVALID ) 
    499525  return -1; 
    500526 
     
    593619    break; 
    594620   default: 
    595      host = item->host == NULL ? sockaddr.addr : item->host; 
    596      port = item->port ==    0 ? sockaddr.port : item->port; 
     621     host = item->host == NULL ?               sockaddr.addr : item->host; 
     622     port = item->port ==    0 ? (unsigned int)sockaddr.port : item->port; 
    597623     snprintf(data, len-1, "%c%s\t%s\t%s\t%u\r\n", item->type, item->name, item->selector, host, port); 
    598624    break; 
     
    615641} 
    616642 
    617 static int send_text (int client, const char * text, struct roar_vio_calls * vio) { 
     643static int send_text (const char * text, struct roar_buffer ** obuffer) { 
    618644 struct roar_buffer * buf; 
    619645 void * data; 
     
    626652 //memcpy(data+len, "\r\n.\r\n\0", 6); 
    627653 memcpy(data+len, "\0", 1); 
    628  clients_add_output(client, &buf); 
     654 if ( roar_buffer_moveintoqueue(obuffer, &buf) == -1 ) 
     655  return -1; 
    629656 
    630657 return 0; 
     
    642669 char * text; 
    643670 
     671 (void)obuffer, (void)userdata, (void)protopara, (void)protoparalen, (void)pluginpara; 
     672 
    644673 ROAR_DBG("emul_gopher_check_client(client=%i, vio=%p) = ?", client, vio); 
    645674 
     
    718747 
    719748  if ( funcret == 0 && text != NULL ) 
    720    funcret = send_text(client, text, vio); 
     749   funcret = send_text(text, obuffer); 
    721750 
    722751  if ( text != NULL ) 
     
    728757    break; 
    729758   case _FILE: 
    730      funcret = send_text(client, c->text, vio); 
     759     funcret = send_text(c->text, obuffer); 
    731760    break; 
    732761   default: 
     
    749778 
    750779static int emul_gopher_flushed_client(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * protopara, ssize_t protoparalen, struct roar_dl_librarypara * pluginpara) { 
     780 
     781 (void)client, (void)vio, (void)obuffer, (void)userdata, (void)protopara, (void)protoparalen, (void)pluginpara; 
     782 
    751783 ROAR_DBG("emul_gopher_flushed_client(client=%i, vio=%p) = ?", client, vio); 
    752784 
     
    754786} 
    755787 
    756 struct roar_dl_proto __proto_common_gopher = { 
     788static struct roar_dl_proto __proto_common_gopher = { 
    757789 .proto = ROAR_PROTO_GOPHER, 
    758790 .description = "The Internet Gopher Protocol", 
     
    762794}; 
    763795 
     796static int __reg_proto(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib) { 
     797 (void)para, (void)lib; 
     798 ROAR_DL_PLUGIN_REG_FN(ROAR_DL_PROTO_SUBTYPE, __proto_common_gopher, ROAR_DL_PROTO_VERSION); 
     799 return 0; 
     800} 
     801 
     802ROAR_DL_PLUGIN_START(protocol_gopher) { 
     803 ROARD_DL_CHECK_VERSIONS(); 
     804 
     805 ROAR_DL_PLUGIN_META_PRODUCT_NIV("protocol-gopher", ROAR_VID_ROARAUDIO, ROAR_VNAME_ROARAUDIO); 
     806 ROAR_DL_PLUGIN_META_VERSION(ROAR_VERSION_STRING); 
     807 ROAR_DL_PLUGIN_META_LICENSE_TAG(GPLv3_0); 
     808 ROAR_DL_PLUGIN_META_CONTACT_FLNE("Philipp", "Schafft", "ph3-der-loewe", "lion@lion.leolix.org"); 
     809 ROAR_DL_PLUGIN_META_DESC("Implementation of the Internet Gopher protocol"); 
     810 
     811 ROAR_DL_PLUGIN_REG(ROAR_DL_FN_PROTO, __reg_proto); 
     812} ROAR_DL_PLUGIN_END 
     813 
    764814#endif 
    765815 
Note: See TracChangeset for help on using the changeset viewer.