Ignore:
Timestamp:
07/21/12 19:40:17 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Converted roard plugins to universal where possible (Closes: #256)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/universal/protocol-echo.c

    r5444 r5579  
    2424 */ 
    2525 
    26 #include <roard/include/roard.h> 
     26#include <roaraudio.h> 
    2727 
    28 static int check_client(int client, struct roar_vio_calls * vio) { 
     28static int _handle(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * para, ssize_t paralen) { 
    2929 struct roar_buffer * buf; 
    3030 void * data; 
    3131 ssize_t len; 
    3232 
    33  ROAR_DBG("check_client(client=%i, vio=%p) = ?", client, vio); 
     33 (void)client, (void)userdata, (void)para, (void)paralen; 
     34 
     35 ROAR_DBG("_handle(client=%i, vio=%p) = ?", client, vio); 
    3436 
    3537 if ( roar_buffer_new_data(&buf, 1024, &data) == -1 ) 
     
    3739 
    3840 len = roar_vio_read(vio, data, 1024); 
    39  
    4041 if ( len < 1 ) { 
    41   clients_delete(client); 
     42  ROAR_DBG("_handle(client=%i, vio=%p) = -1 // error=%s(%i)", client, vio, roar_errorstring, roar_error); 
    4243  return -1; 
    4344 } 
    4445 
    4546 if ( roar_buffer_set_len(buf, len) == -1 ) { 
     47  ROAR_DBG("_handle(client=%i, vio=%p) = -1 // error=%s(%i)", client, vio, roar_errorstring, roar_error); 
    4648  roar_buffer_free(buf); 
    47   clients_delete(client); 
    4849  return -1; 
    4950 } 
    5051 
    51  clients_add_output(client, &buf); 
     52 if ( *obuffer == NULL ) { 
     53  *obuffer = buf; 
     54 } else { 
     55  if ( roar_buffer_moveinto(*obuffer, &buf) == -1 ) { 
     56   ROAR_DBG("_handle(client=%i, vio=%p) = -1 // error=%s(%i)", client, vio, roar_errorstring, roar_error); 
     57   return -1; 
     58  } 
     59 } 
    5260 
    53  ROAR_DBG("check_client(client=%i, vio=%p) = 0", client, vio); 
     61 ROAR_DBG("_handle(client=%i, vio=%p) = 0", client, vio); 
    5462 return 0; 
    5563} 
    5664 
    5765 
    58 static struct roard_proto proto[1] = { 
    59  {ROAR_PROTO_ECHO, ROAR_SUBSYS_NONE, "Send all data send to the server back to the client", NULL, NULL, NULL, check_client, NULL, NULL} 
     66static const struct roar_dl_proto proto = { 
     67 .proto = ROAR_PROTO_ECHO, 
     68 .description = "Send all data send to the server back to the client", 
     69 .flags = ROAR_DL_PROTO_FLAGS_NONE, 
     70 .set_proto = NULL, 
     71 .unset_proto = NULL, 
     72 .handle = _handle, 
     73 .flush = NULL, 
     74 .flushed = NULL, 
     75 .status = NULL 
    6076}; 
    6177 
    62 ROARD_DL_REG_PROTO(proto) 
     78static int __reg_proto(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib) { 
     79 (void)para, (void)lib; 
     80 ROAR_DL_PLUGIN_REG_FN(ROAR_DL_PROTO_SUBTYPE, proto, ROAR_DL_PROTO_VERSION); 
     81 return 0; 
     82} 
    6383 
    6484ROAR_DL_PLUGIN_START(protocol_echo) { 
    65  ROARD_DL_CHECK_VERSIONS(); 
    66  
    6785 ROAR_DL_PLUGIN_META_PRODUCT_NIV("protocol-echo", ROAR_VID_ROARAUDIO, ROAR_VNAME_ROARAUDIO); 
    6886 ROAR_DL_PLUGIN_META_VERSION(ROAR_VERSION_STRING); 
     
    7189 ROAR_DL_PLUGIN_META_DESC("Implementation of a dummy protocol sending all data back to the sender"); 
    7290 
    73  ROARD_DL_REGFN_PROTO(); 
     91 ROAR_DL_PLUGIN_REG(ROAR_DL_FN_PROTO, __reg_proto); 
    7492} ROAR_DL_PLUGIN_END 
    7593 
Note: See TracChangeset for help on using the changeset viewer.