Merge remote-tracking branch 'IOMultiplexer/v2'
[NextIRCd.git] / src / ircd_client.c
1 /* ircd_client.c - NextIRCd
2  * Copyright (C) 2012-2013  Philipp Kreil (pk910)
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License 
15  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
16  */
17
18 #include "ircd_client.h"
19 #include "ircd_sock.h"
20 #include "struct_connection.h"
21 #include "struct_auth.h"
22 #include "ircd_config.h"
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <stdarg.h>
27 #define CLIENT_MAXLEN 512
28
29 void client_printf(struct Connection *conn, const char *text, ...) {
30     va_list arg_list;
31         char sendBuf[CLIENT_MAXLEN];
32         int pos;
33         sendBuf[0] = '\0';
34         va_start(arg_list, text);
35         pos = vsnprintf(sendBuf, CLIENT_MAXLEN - 2, text, arg_list);
36         va_end(arg_list);
37         if (pos < 0 || pos > (CLIENT_MAXLEN - 2)) pos = CLIENT_MAXLEN - 2;
38         sendBuf[pos] = '\n';
39     sendBuf[pos+1] = '\0';
40         socket_send(conn, sendBuf, pos+1);
41 }
42
43 void client_connected(struct Connection *conn) {
44     struct Auth *auth = auth_new(conn);
45         
46         auth_start_dnsreverse(auth);
47 }
48
49 void client_disconnected(struct Connection *conn) {
50     
51 }