66b29968a6f5ecbf0418e14975a4b425e93a4a9e
[babeltrace.git] / plugins / utils / dummy / dummy.c
1 /*
2 * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 #include <babeltrace/plugin/plugin-dev.h>
24 #include <babeltrace/component/component.h>
25 #include <babeltrace/component/component-sink.h>
26 #include <babeltrace/component/notification/iterator.h>
27 #include <babeltrace/component/notification/notification.h>
28 #include <assert.h>
29
30 enum bt_component_status dummy_consume(struct bt_component *component)
31 {
32 enum bt_component_status ret;
33 struct bt_notification *notif = NULL;
34 struct bt_notification_iterator *it = NULL;
35 unsigned int it_count;
36 size_t i;
37 bool got_one = false;
38
39 ret = bt_component_sink_get_input_count(component, &it_count);
40 assert(ret == 0);
41
42 for (i = 0; i < it_count; i++) {
43 enum bt_notification_iterator_status it_ret;
44
45 ret = bt_component_sink_get_input_iterator(component, i, &it);
46 assert(ret == 0);
47 it_ret = bt_notification_iterator_next(it);
48 switch (it_ret) {
49 case BT_NOTIFICATION_ITERATOR_STATUS_ERROR:
50 ret = BT_COMPONENT_STATUS_ERROR;
51 goto end;
52 case BT_NOTIFICATION_ITERATOR_STATUS_END:
53 ret = BT_COMPONENT_STATUS_END;
54 BT_PUT(it);
55 continue;
56 default:
57 break;
58 }
59
60 notif = bt_notification_iterator_get_notification(it);
61 if (!notif) {
62 ret = BT_COMPONENT_STATUS_ERROR;
63 goto end;
64 }
65
66 /*
67 * Dummy! I'm doing nothing with this notification,
68 * NOTHING.
69 */
70 got_one = true;
71 BT_PUT(it);
72 BT_PUT(notif);
73 }
74
75 if (!got_one) {
76 ret = BT_COMPONENT_STATUS_END;
77 }
78
79 end:
80 bt_put(it);
81 bt_put(notif);
82 return ret;
83 }
This page took 0.02993 seconds and 3 git commands to generate.