source: roaraudio/plugins/universal/protocol-daytime.c @ 6052:d48765b2475e

Last change on this file since 6052:d48765b2475e was 6052:d48765b2475e, checked in by phi, 9 years ago

updated copyright headers

File size: 2.9 KB
Line 
1//protocol-daytime.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011-2015
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
26#include <roaraudio.h>
27
28static 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) {
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
35 (void)client, (void)vio, (void)userdata, (void)protopara, (void)protoparalen, (void)pluginpara;
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
44 if ( roar_buffer_moveintoqueue(obuffer, &buf) == -1 )
45  return -1;
46
47 return 0;
48}
49
50static 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;
52
53 roar_err_set(ROAR_ERROR_NODATA);
54 return -1;
55}
56
57static 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
67};
68
69static 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}
74
75ROAR_DL_PLUGIN_START(protocol_daytime) {
76 ROAR_DL_PLUGIN_META_PRODUCT_NIV("protocol-daytime", ROAR_VID_ROARAUDIO, ROAR_VNAME_ROARAUDIO);
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");
81
82 ROAR_DL_PLUGIN_REG(ROAR_DL_FN_PROTO, __reg_proto);
83} ROAR_DL_PLUGIN_END
84
85//ll
Note: See TracBrowser for help on using the repository browser.