]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/irc-encoding.c
0b8e9d4b9b0e9d84561f3dbf7a5e42bdf4572d2f
[ngircd-alex.git] / src / ngircd / irc-encoding.c
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * Please read the file COPYING, README and AUTHORS for more information.
10  */
11
12 #include "portab.h"
13
14 /**
15  * @file
16  * IRC encoding commands
17  */
18
19 #ifdef ICONV
20
21 #include <assert.h>
22 #include <string.h>
23
24 #include "conn-func.h"
25 #include "channel.h"
26 #include "conn-encoding.h"
27 #include "irc-write.h"
28 #include "messages.h"
29 #include "parse.h"
30 #include "tool.h"
31
32 /**
33  * Handler for the IRC+ "CHARCONV" command.
34  *
35  * @param Client The client from which this command has been received.
36  * @param Req Request structure with prefix and all parameters.
37  * @returns CONNECTED or DISCONNECTED.
38  */
39 GLOBAL bool
40 IRC_CHARCONV(CLIENT *Client, REQUEST *Req)
41 {
42         char encoding[20];
43
44         assert (Client != NULL);
45         assert (Req != NULL);
46
47         strlcpy(encoding, Req->argv[0], sizeof(encoding));
48         ngt_UpperStr(encoding);
49
50         if (!Conn_SetEncoding(Client_Conn(Client), encoding))
51                 return IRC_WriteErrClient(Client, ERR_IP_CHARCONV_MSG,
52                                           Client_ID(Client), encoding);
53
54         return IRC_WriteStrClient(Client, RPL_IP_CHARCONV_MSG,
55                                   Client_ID(Client), encoding);
56 } /* IRC_CHARCONV */
57
58 #endif
59
60 /* -eof- */