Changeset 5579:3887ff7af8e7 in roaraudio for plugins/universal/protocol-echo.c
- Timestamp:
- 07/21/12 19:40:17 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/universal/protocol-echo.c
r5444 r5579 24 24 */ 25 25 26 #include <roar d/include/roard.h>26 #include <roaraudio.h> 27 27 28 static int check_client(int client, struct roar_vio_calls * vio) {28 static int _handle(int client, struct roar_vio_calls * vio, struct roar_buffer ** obuffer, void ** userdata, const struct roar_keyval * para, ssize_t paralen) { 29 29 struct roar_buffer * buf; 30 30 void * data; 31 31 ssize_t len; 32 32 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); 34 36 35 37 if ( roar_buffer_new_data(&buf, 1024, &data) == -1 ) … … 37 39 38 40 len = roar_vio_read(vio, data, 1024); 39 40 41 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); 42 43 return -1; 43 44 } 44 45 45 46 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); 46 48 roar_buffer_free(buf); 47 clients_delete(client);48 49 return -1; 49 50 } 50 51 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 } 52 60 53 ROAR_DBG(" check_client(client=%i, vio=%p) = 0", client, vio);61 ROAR_DBG("_handle(client=%i, vio=%p) = 0", client, vio); 54 62 return 0; 55 63 } 56 64 57 65 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} 66 static 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 60 76 }; 61 77 62 ROARD_DL_REG_PROTO(proto) 78 static 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 } 63 83 64 84 ROAR_DL_PLUGIN_START(protocol_echo) { 65 ROARD_DL_CHECK_VERSIONS();66 67 85 ROAR_DL_PLUGIN_META_PRODUCT_NIV("protocol-echo", ROAR_VID_ROARAUDIO, ROAR_VNAME_ROARAUDIO); 68 86 ROAR_DL_PLUGIN_META_VERSION(ROAR_VERSION_STRING); … … 71 89 ROAR_DL_PLUGIN_META_DESC("Implementation of a dummy protocol sending all data back to the sender"); 72 90 73 ROAR D_DL_REGFN_PROTO();91 ROAR_DL_PLUGIN_REG(ROAR_DL_FN_PROTO, __reg_proto); 74 92 } ROAR_DL_PLUGIN_END 75 93
Note: See TracChangeset
for help on using the changeset viewer.