irc-encoding.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * ngIRCd -- The Next Generation IRC Daemon
  3. * Copyright (c)2001-2012 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. if (Req->argc != 1)
  43. return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
  44. Client_ID(Client), Req->command);
  45. strlcpy(encoding, Req->argv[0], sizeof(encoding));
  46. ngt_UpperStr(encoding);
  47. if (!Conn_SetEncoding(Client_Conn(Client), encoding))
  48. return IRC_WriteStrClient(Client, ERR_IP_CHARCONV_MSG,
  49. Client_ID(Client), encoding);
  50. return IRC_WriteStrClient(Client, RPL_IP_CHARCONV_MSG,
  51. Client_ID(Client), encoding);
  52. } /* IRC_CHARCONV */
  53. #endif
  54. /* -eof- */