source: roaraudio/plugins/universal/protocol-daytime.c @ 5579:3887ff7af8e7

Last change on this file since 5579:3887ff7af8e7 was 5579:3887ff7af8e7, checked in by phi, 12 years ago

Converted roard plugins to universal where possible (Closes: #256)

File size: 2.8 KB
Line 
1//daytime.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011-2012
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 * para, ssize_t paralen) {
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)para, (void)paralen;
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 ( *obuffer == NULL ) {
45  *obuffer = buf;
46 } else {
47  if ( roar_buffer_moveinto(*obuffer, &buf) == -1 )
48   return -1;
49 }
50
51 return 0;
52}
53
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
71};
72
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}
78
79ROAR_DL_PLUGIN_START(protocol_daytime) {
80 ROAR_DL_PLUGIN_META_PRODUCT_NIV("protocol-daytime", ROAR_VID_ROARAUDIO, ROAR_VNAME_ROARAUDIO);
81 ROAR_DL_PLUGIN_META_VERSION(ROAR_VERSION_STRING);
82 ROAR_DL_PLUGIN_META_LICENSE_TAG(GPLv3_0);
83 ROAR_DL_PLUGIN_META_CONTACT_FLNE("Philipp", "Schafft", "ph3-der-loewe", "lion@lion.leolix.org");
84 ROAR_DL_PLUGIN_META_DESC("Implementation of the Internet daytime protocol");
85
86 ROAR_DL_PLUGIN_REG(ROAR_DL_FN_PROTO, __reg_proto);
87} ROAR_DL_PLUGIN_END
88
89//ll
Note: See TracBrowser for help on using the repository browser.