equal
deleted
inserted
replaced
9 /* |
9 /* |
10 * "Welcome to the Internet Relay Network <nick>!<user>@<host>" |
10 * "Welcome to the Internet Relay Network <nick>!<user>@<host>" |
11 */ |
11 */ |
12 static void on_RPL_WELCOME (struct irc_conn *conn, const struct irc_line *line, void *arg) |
12 static void on_RPL_WELCOME (struct irc_conn *conn, const struct irc_line *line, void *arg) |
13 { |
13 { |
|
14 (void) line; |
|
15 (void) arg; |
|
16 |
14 // update state |
17 // update state |
15 conn->registered = true; |
18 conn->registered = true; |
16 |
19 |
17 log_info("registered"); |
20 log_info("registered"); |
18 } |
21 } |
22 * |
25 * |
23 * Send a 'PONG <server1>` reply right away. |
26 * Send a 'PONG <server1>` reply right away. |
24 */ |
27 */ |
25 static void on_PING (struct irc_conn *conn, const struct irc_line *line, void *arg) |
28 static void on_PING (struct irc_conn *conn, const struct irc_line *line, void *arg) |
26 { |
29 { |
|
30 (void) arg; |
|
31 |
27 // just reply |
32 // just reply |
28 irc_conn_PONG(conn, line->args[0]); |
33 irc_conn_PONG(conn, line->args[0]); |
29 } |
34 } |
30 |
35 |
31 /* |
36 /* |
126 |
131 |
127 err_t irc_conn_send (struct irc_conn *conn, const struct irc_line *line) |
132 err_t irc_conn_send (struct irc_conn *conn, const struct irc_line *line) |
128 { |
133 { |
129 char line_buf[IRC_LINE_MAX + 2]; |
134 char line_buf[IRC_LINE_MAX + 2]; |
130 err_t err; |
135 err_t err; |
|
136 int ret; |
131 |
137 |
132 // format |
138 // format |
133 if ((err = irc_line_build(line, line_buf))) |
139 if ((err = irc_line_build(line, line_buf))) |
134 return err; |
140 return err; |
135 |
141 |
139 // add CRLF |
145 // add CRLF |
140 strcat(line_buf, "\r\n"); |
146 strcat(line_buf, "\r\n"); |
141 |
147 |
142 // send using line_proto |
148 // send using line_proto |
143 // XXX: ignore output-buffering |
149 // XXX: ignore output-buffering |
144 return (err = line_proto_send(conn->lp, line_buf)) < 0 ? err : SUCCESS; |
150 return (ret = line_proto_send(conn->lp, line_buf)) < 0 ? -ret : SUCCESS; |
145 } |
151 } |
146 |
152 |
147 err_t irc_conn_NICK (struct irc_conn *conn, const char *nickname) |
153 err_t irc_conn_NICK (struct irc_conn *conn, const char *nickname) |
148 { |
154 { |
149 // NICK <nickname> |
155 // NICK <nickname> |