Debian Codegraph @

src/ws/cockpitwebfilter.c

raw
1 /*
2 * Copyright (C) 2015 Red Hat, Inc.
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6 #include "config.h"
7
8 /* This gets logged as part of the (more verbose) protocol logging */
9 #ifdef G_LOG_DOMAIN
10 #undef G_LOG_DOMAIN
11 #endif
12 #define G_LOG_DOMAIN "cockpit-protocol"
13
14 #include "cockpitwebfilter.h"
15
16 /**
17 * CockpitWebFilter
18 *
19 * A filter used to filter the output of a CockpitWebResponse.
20 */
21
22 G_DEFINE_INTERFACE (CockpitWebFilter, cockpit_web_filter, 0);
23
24 static void
25 cockpit_web_filter_default_init (CockpitWebFilterInterface *iface)
26 {
27
28 }
29
30 /**
31 * cockpit_web_filter_push:
32 * @filter: filter to push a block of bytes into
33 * @queue: block of bytes to filter
34 * @function: filter calls this function with bytes generated
35 * @data: value to pass to function
36 *
37 * Called to send data through a filter. The filter should call
38 * the @function with any data it generates. If the filter wants
39 * to pass through the @queue data, then it needs to call @function
40 * with it.
41 */
42 void
43 cockpit_web_filter_push (CockpitWebFilter *filter,
44 GBytes *queue,
45 void (* function) (gpointer, GBytes *),
46 gpointer data)
47 {
48 CockpitWebFilterInterface *iface;
49
50 iface = COCKPIT_WEB_FILTER_GET_IFACE (filter);
51 g_return_if_fail (iface != NULL);
52
53 g_assert (iface->push);
54 (iface->push) (filter, queue, function, data);
55 }