irc-encoding.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * ngIRCd -- The Next Generation IRC Daemon
  3. * Copyright (c)2001-2014 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. #ifdef ICONV
  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 "irc-encoding.h"
  27. /**
  28. * Handler for the IRC+ "CHARCONV" command.
  29. *
  30. * @param Client The client from which this command has been received.
  31. * @param Req Request structure with prefix and all parameters.
  32. * @returns CONNECTED or DISCONNECTED.
  33. */
  34. GLOBAL bool
  35. IRC_CHARCONV(CLIENT *Client, REQUEST *Req)
  36. {
  37. char encoding[20];
  38. assert (Client != NULL);
  39. assert (Req != NULL);
  40. strlcpy(encoding, Req->argv[0], sizeof(encoding));
  41. ngt_UpperStr(encoding);
  42. if (!Conn_SetEncoding(Client_Conn(Client), encoding))
  43. return IRC_WriteErrClient(Client, ERR_IP_CHARCONV_MSG,
  44. Client_ID(Client), encoding);
  45. return IRC_WriteStrClient(Client, RPL_IP_CHARCONV_MSG,
  46. Client_ID(Client), encoding);
  47. } /* IRC_CHARCONV */
  48. #endif
  49. /* -eof- */