irc-encoding.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #include "portab.h"
  12. /**
  13. * @file
  14. * IRC encoding commands
  15. */
  16. #include "imp.h"
  17. #include <assert.h>
  18. #include <string.h>
  19. #include "conn-func.h"
  20. #include "channel.h"
  21. #include "conn-encoding.h"
  22. #include "irc-write.h"
  23. #include "messages.h"
  24. #include "parse.h"
  25. #include "tool.h"
  26. #include "exp.h"
  27. #include "irc-encoding.h"
  28. #ifdef ICONV
  29. /**
  30. * Handler for the IRC+ "CHARCONV" command.
  31. *
  32. * @param Client The client from which this command has been received.
  33. * @param Req Request structure with prefix and all parameters.
  34. * @returns CONNECTED or DISCONNECTED.
  35. */
  36. GLOBAL bool
  37. IRC_CHARCONV(CLIENT *Client, REQUEST *Req)
  38. {
  39. char encoding[20];
  40. assert (Client != NULL);
  41. assert (Req != NULL);
  42. strlcpy(encoding, Req->argv[0], sizeof(encoding));
  43. ngt_UpperStr(encoding);
  44. if (!Conn_SetEncoding(Client_Conn(Client), encoding))
  45. return IRC_WriteErrClient(Client, ERR_IP_CHARCONV_MSG,
  46. Client_ID(Client), encoding);
  47. return IRC_WriteStrClient(Client, RPL_IP_CHARCONV_MSG,
  48. Client_ID(Client), encoding);
  49. } /* IRC_CHARCONV */
  50. #endif
  51. /* -eof- */