Sun, 09 Oct 2022 00:41:50 -0500
Use the parser on ircv3 messages and handle pings
Testing Done:
Connected to a local Ergo instance and verified ping/pongs were sent via ngrep and saw a whole of unhandled messages in the terminal.
Reviewed at https://reviews.imfreedom.org/r/1911/
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * This program is free software; you can redistribute it and/or modify |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation; either version 2 of the License, or |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | #ifndef PURPLE_IRCV3_PARSER_H |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | #define PURPLE_IRCV3_PARSER_H |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | #include <glib.h> |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include <glib-object.h> |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | #include <purple.h> |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
27 | #include "purpleircv3messagehandlers.h" |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
29 | G_BEGIN_DECLS |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | #define PURPLE_IRCV3_TYPE_PARSER (purple_ircv3_parser_get_type()) |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | G_DECLARE_FINAL_TYPE(PurpleIRCv3Parser, purple_ircv3_parser, PURPLE_IRCV3, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | PARSER, GObject) |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | /** |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | * purple_ircv3_parser_new: |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | * Creates a new instance. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | * Since: 3.0.0 |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | G_GNUC_INTERNAL PurpleIRCv3Parser *purple_ircv3_parser_new(void); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | /** |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | * purple_ircv3_parser_set_fallback_handler: (skip): |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | * @parser: The instance. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | * @handler: A [func@PurpleIRCv3.MessageHandler]. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | * Sets @handler to be called for any messages that @parser doesn't know how to |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | * handle. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | * Since: 3.0.0 |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | G_GNUC_INTERNAL void purple_ircv3_parser_set_fallback_handler(PurpleIRCv3Parser *parser, PurpleIRCv3MessageHandler handler); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | /** |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | * purple_ircv3_parser_parse: |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | * @parser: The instance. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | * @buffer: The buffer to parse. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | * @error: (nullable) (out): A return address for a [boxed@Glib.GError]. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | * @data: (nullable): Optional data to pass to the handler. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | * Parses @buffer with @parser. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | * Returns: %TRUE if the buffer was parsed correctly or %FALSE with @error set. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | * Since: 3.0.0 |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | G_GNUC_INTERNAL gboolean purple_ircv3_parser_parse(PurpleIRCv3Parser *parser, const gchar *buffer, GError **error, gpointer data); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
71 | /** |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
72 | * purple_ircv3_parser_add_default_handlers: |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
73 | * @parser: The instance. |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
74 | * |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
75 | * Adds all of the default handlers to @parser. |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
76 | * |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
77 | * Since: 3.0.0 |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
78 | */ |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
79 | G_GNUC_INTERNAL void purple_ircv3_parser_add_default_handlers(PurpleIRCv3Parser *parser); |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
80 | |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | G_END_DECLS |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | #endif /* PURPLE_IRCV3_PARSER_H */ |