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-daytime.c

    r5444 r5579  
    2424 */ 
    2525 
    26 #include <roard/include/roard.h> 
     26#include <roaraudio.h> 
    2727 
    28 int new_client(int client, struct roar_vio_calls * vio, struct roard_listen * lsock) { 
     28static int _set_proto(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; 
     
    3333 char * date = asctime(gmtime(&now)); 
    3434 
    35  (void)vio, (void)lsock; 
    36  
    37  ROAR_DBG("new_client(client=%i, vio=%p, lsock=%p) = ?", client, vio, lsock); 
     35 (void)client, (void)vio, (void)userdata, (void)para, (void)paralen; 
    3836 
    3937 len = roar_mm_strlen(date) + 1; 
     
    4442 memcpy(data, date, len); 
    4543 
    46  clients_add_output(client, &buf); 
    47  
    48  ROAR_DBG("new_client(client=%i, vio=%p, lsock=%p) = 0", client, vio, lsock); 
    49  return 0; 
    50 } 
    51  
    52 static int flushed_client(int client, struct roar_vio_calls * vio) { 
    53  (void)vio; 
    54  
    55  clients_delete(client); 
     44 if ( *obuffer == NULL ) { 
     45  *obuffer = buf; 
     46 } else { 
     47  if ( roar_buffer_moveinto(*obuffer, &buf) == -1 ) 
     48   return -1; 
     49 } 
    5650 
    5751 return 0; 
    5852} 
    5953 
    60 static struct roard_proto proto[1] = { 
    61  {ROAR_PROTO_DAYTIME, ROAR_SUBSYS_NONE, "The Internet daytime protocol", NULL, new_client, NULL, NULL, NULL, flushed_client} 
     54static int _flushed(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * para, ssize_t paralen) { 
     55 (void)client, (void)vio, (void)obuffer, (void)userdata, (void)para, (void)paralen; 
     56 
     57 roar_err_set(ROAR_ERROR_NODATA); 
     58 return -1; 
     59} 
     60 
     61static const struct roar_dl_proto proto = { 
     62 .proto = ROAR_PROTO_DAYTIME, 
     63 .description = "The Internet daytime protocol", 
     64 .flags = ROAR_DL_PROTO_FLAGS_NONE, 
     65 .set_proto = _set_proto, 
     66 .unset_proto = NULL, 
     67 .handle = NULL, 
     68 .flush = NULL, 
     69 .flushed = _flushed, 
     70 .status = NULL 
    6271}; 
    6372 
    64 ROARD_DL_REG_PROTO(proto) 
     73static int __reg_proto(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib) { 
     74 (void)para, (void)lib; 
     75 ROAR_DL_PLUGIN_REG_FN(ROAR_DL_PROTO_SUBTYPE, proto, ROAR_DL_PROTO_VERSION); 
     76 return 0; 
     77} 
    6578 
    6679ROAR_DL_PLUGIN_START(protocol_daytime) { 
    67  ROARD_DL_CHECK_VERSIONS(); 
    68  
    6980 ROAR_DL_PLUGIN_META_PRODUCT_NIV("protocol-daytime", ROAR_VID_ROARAUDIO, ROAR_VNAME_ROARAUDIO); 
    7081 ROAR_DL_PLUGIN_META_VERSION(ROAR_VERSION_STRING); 
     
    7384 ROAR_DL_PLUGIN_META_DESC("Implementation of the Internet daytime protocol"); 
    7485 
    75  ROARD_DL_REGFN_PROTO(); 
     86 ROAR_DL_PLUGIN_REG(ROAR_DL_FN_PROTO, __reg_proto); 
    7687} ROAR_DL_PLUGIN_END 
    7788 
Note: See TracChangeset for help on using the changeset viewer.