equal
deleted
inserted
replaced
1 |
1 |
2 #include "irc_conn.h" |
2 #include "irc_conn.h" |
3 #include "irc_cmd.h" |
3 #include "irc_cmd.h" |
|
4 #include "log.h" |
4 |
5 |
5 #include <stdlib.h> |
6 #include <stdlib.h> |
6 #include <string.h> |
7 #include <string.h> |
7 |
8 |
8 /* |
9 /* |
10 */ |
11 */ |
11 static void on_RPL_WELCOME (struct irc_conn *conn, const struct irc_line *line) |
12 static void on_RPL_WELCOME (struct irc_conn *conn, const struct irc_line *line) |
12 { |
13 { |
13 // update state |
14 // update state |
14 conn->registered = true; |
15 conn->registered = true; |
|
16 |
|
17 log_info("registered"); |
15 } |
18 } |
16 |
19 |
17 /* |
20 /* |
18 * PING <server1> [ <server2> ] |
21 * PING <server1> [ <server2> ] |
19 * |
22 * |
47 struct irc_line line; |
50 struct irc_line line; |
48 struct irc_cmd_handler *handler; |
51 struct irc_cmd_handler *handler; |
49 int err; |
52 int err; |
50 |
53 |
51 // log |
54 // log |
52 printf("<<< %s\n", line_buf); |
55 log_debug("%s", line_buf); |
53 |
56 |
54 // parse |
57 // parse |
55 if ((err = irc_line_parse(&line, line_buf))) { |
58 if ((err = irc_line_parse(&line, line_buf))) { |
56 printf("!!! Invalid line: %s: %s\n", line_buf, error_name(err)); |
59 printf("!!! Invalid line: %s: %s\n", line_buf, error_name(err)); |
57 |
60 |
102 // format |
105 // format |
103 if ((err = irc_line_build(line, line_buf))) |
106 if ((err = irc_line_build(line, line_buf))) |
104 return err; |
107 return err; |
105 |
108 |
106 // log |
109 // log |
107 printf(">>> %s\n", line_buf); |
110 log_debug("%s", line_buf); |
108 |
111 |
109 // add CRLF |
112 // add CRLF |
110 strcat(line_buf, "\r\n"); |
113 strcat(line_buf, "\r\n"); |
111 |
114 |
112 // send using line_proto |
115 // send using line_proto |