[5605] | 1 | //protocol-daytime.c: |
---|
[5193] | 2 | |
---|
| 3 | /* |
---|
[5823] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011-2013 |
---|
[5193] | 5 | * |
---|
| 6 | * This file is part of roard a part of RoarAudio, |
---|
| 7 | * a cross-platform sound system for both, home and professional use. |
---|
| 8 | * See README for details. |
---|
| 9 | * |
---|
| 10 | * This file is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * RoarAudio is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
| 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
| 23 | * |
---|
| 24 | */ |
---|
| 25 | |
---|
[5579] | 26 | #include <roaraudio.h> |
---|
[5193] | 27 | |
---|
[5606] | 28 | static int _set_proto(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) { |
---|
[5193] | 29 | struct roar_buffer * buf; |
---|
| 30 | void * data; |
---|
| 31 | ssize_t len; |
---|
| 32 | time_t now = time(NULL); |
---|
| 33 | char * date = asctime(gmtime(&now)); |
---|
| 34 | |
---|
[5606] | 35 | (void)client, (void)vio, (void)userdata, (void)protopara, (void)protoparalen, (void)pluginpara; |
---|
[5193] | 36 | |
---|
| 37 | len = roar_mm_strlen(date) + 1; |
---|
| 38 | |
---|
| 39 | if ( roar_buffer_new_data(&buf, len, &data) == -1 ) |
---|
| 40 | return -1; |
---|
| 41 | |
---|
| 42 | memcpy(data, date, len); |
---|
| 43 | |
---|
[5603] | 44 | if ( roar_buffer_moveintoqueue(obuffer, &buf) == -1 ) |
---|
| 45 | return -1; |
---|
[5193] | 46 | |
---|
| 47 | return 0; |
---|
| 48 | } |
---|
| 49 | |
---|
[5606] | 50 | static int _flushed(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) { |
---|
| 51 | (void)client, (void)vio, (void)obuffer, (void)userdata, (void)protopara, (void)protoparalen, (void)pluginpara; |
---|
[5579] | 52 | |
---|
| 53 | roar_err_set(ROAR_ERROR_NODATA); |
---|
| 54 | return -1; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | static const struct roar_dl_proto proto = { |
---|
| 58 | .proto = ROAR_PROTO_DAYTIME, |
---|
| 59 | .description = "The Internet daytime protocol", |
---|
| 60 | .flags = ROAR_DL_PROTO_FLAGS_NONE, |
---|
| 61 | .set_proto = _set_proto, |
---|
| 62 | .unset_proto = NULL, |
---|
| 63 | .handle = NULL, |
---|
| 64 | .flush = NULL, |
---|
| 65 | .flushed = _flushed, |
---|
| 66 | .status = NULL |
---|
[5193] | 67 | }; |
---|
| 68 | |
---|
[5579] | 69 | static int __reg_proto(struct roar_dl_librarypara * para, struct roar_dl_libraryinst * lib) { |
---|
| 70 | (void)para, (void)lib; |
---|
| 71 | ROAR_DL_PLUGIN_REG_FN(ROAR_DL_PROTO_SUBTYPE, proto, ROAR_DL_PROTO_VERSION); |
---|
| 72 | return 0; |
---|
| 73 | } |
---|
[5193] | 74 | |
---|
[5434] | 75 | ROAR_DL_PLUGIN_START(protocol_daytime) { |
---|
| 76 | ROAR_DL_PLUGIN_META_PRODUCT_NIV("protocol-daytime", ROAR_VID_ROARAUDIO, ROAR_VNAME_ROARAUDIO); |
---|
[5340] | 77 | ROAR_DL_PLUGIN_META_VERSION(ROAR_VERSION_STRING); |
---|
| 78 | ROAR_DL_PLUGIN_META_LICENSE_TAG(GPLv3_0); |
---|
| 79 | ROAR_DL_PLUGIN_META_CONTACT_FLNE("Philipp", "Schafft", "ph3-der-loewe", "lion@lion.leolix.org"); |
---|
| 80 | ROAR_DL_PLUGIN_META_DESC("Implementation of the Internet daytime protocol"); |
---|
[5275] | 81 | |
---|
[5579] | 82 | ROAR_DL_PLUGIN_REG(ROAR_DL_FN_PROTO, __reg_proto); |
---|
[5193] | 83 | } ROAR_DL_PLUGIN_END |
---|
| 84 | |
---|
| 85 | //ll |
---|