Changeset 5579:3887ff7af8e7 in roaraudio for plugins/universal/protocol-daytime.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-daytime.c
r5444 r5579 24 24 */ 25 25 26 #include <roar d/include/roard.h>26 #include <roaraudio.h> 27 27 28 int new_client(int client, struct roar_vio_calls * vio, struct roard_listen * lsock) {28 static int _set_proto(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; … … 33 33 char * date = asctime(gmtime(&now)); 34 34 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; 38 36 39 37 len = roar_mm_strlen(date) + 1; … … 44 42 memcpy(data, date, len); 45 43 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 } 56 50 57 51 return 0; 58 52 } 59 53 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} 54 static 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 61 static 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 62 71 }; 63 72 64 ROARD_DL_REG_PROTO(proto) 73 static 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 } 65 78 66 79 ROAR_DL_PLUGIN_START(protocol_daytime) { 67 ROARD_DL_CHECK_VERSIONS();68 69 80 ROAR_DL_PLUGIN_META_PRODUCT_NIV("protocol-daytime", ROAR_VID_ROARAUDIO, ROAR_VNAME_ROARAUDIO); 70 81 ROAR_DL_PLUGIN_META_VERSION(ROAR_VERSION_STRING); … … 73 84 ROAR_DL_PLUGIN_META_DESC("Implementation of the Internet daytime protocol"); 74 85 75 ROAR D_DL_REGFN_PROTO();86 ROAR_DL_PLUGIN_REG(ROAR_DL_FN_PROTO, __reg_proto); 76 87 } ROAR_DL_PLUGIN_END 77 88
Note: See TracChangeset
for help on using the changeset viewer.