source: roaraudio/plugins/universal/protocol-echo.c @ 5434:1bbcec2d01e9

Last change on this file since 5434:1bbcec2d01e9 was 5434:1bbcec2d01e9, checked in by phi, 10 years ago

use better plugin names

File size: 2.2 KB
Line 
1//echo.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 <roard/include/roard.h>
27
28static int check_client(int client, struct roar_vio_calls * vio) {
29 struct roar_buffer * buf;
30 void * data;
31 ssize_t len;
32
33 ROAR_DBG("check_client(client=%i, vio=%p) = ?", client, vio);
34
35 if ( roar_buffer_new_data(&buf, 1024, &data) == -1 )
36  return -1;
37
38 len = roar_vio_read(vio, data, 1024);
39
40 if ( len < 1 ) {
41  clients_delete(client);
42  return -1;
43 }
44
45 if ( roar_buffer_set_len(buf, len) == -1 ) {
46  roar_buffer_free(buf);
47  clients_delete(client);
48  return -1;
49 }
50
51 clients_add_output(client, &buf);
52
53 ROAR_DBG("check_client(client=%i, vio=%p) = 0", client, vio);
54 return 0;
55}
56
57
58static 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, check_client, NULL, NULL}
60};
61
62ROARD_DL_REG_PROTO(proto)
63
64ROAR_DL_PLUGIN_START(protocol_echo) {
65 ROARD_DL_CHECK_VERSIONS();
66
67 ROAR_DL_PLUGIN_META_PRODUCT_NIV("protocol-echo", ROAR_VID_ROARAUDIO, ROAR_VNAME_ROARAUDIO);
68 ROAR_DL_PLUGIN_META_VERSION(ROAR_VERSION_STRING);
69 ROAR_DL_PLUGIN_META_LICENSE_TAG(GPLv3_0);
70 ROAR_DL_PLUGIN_META_CONTACT_FLNE("Philipp", "Schafft", "ph3-der-loewe", "lion@lion.leolix.org");
71 ROAR_DL_PLUGIN_META_DESC("Implementation of a dummy protocol sending all data back to the sender");
72
73 ROARD_DL_REGFN_PROTO();
74} ROAR_DL_PLUGIN_END
75
76//ll
Note: See TracBrowser for help on using the repository browser.