Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/commands.c @ 2051:71d84213f850
Add option -e (eval) to say_to
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Wed, 28 Nov 2012 18:13:26 +0100 |
parents | 0771e130f79d |
children | e04b6dfbb054 |
comparison
equal
deleted
inserted
replaced
2050:998feaa54ef0 | 2051:71d84213f850 |
---|---|
1631 } | 1631 } |
1632 | 1632 |
1633 static void do_say_to(char *arg) | 1633 static void do_say_to(char *arg) |
1634 { | 1634 { |
1635 char **paramlst; | 1635 char **paramlst; |
1636 char *fjid, *msg; | 1636 char *fjid, *msg_utf8; |
1637 char *msg; | |
1638 char *unescaped_msg = NULL; | |
1637 char *uncompletedfjid = NULL; | 1639 char *uncompletedfjid = NULL; |
1638 char *file = NULL; | 1640 char *file = NULL; |
1639 LmMessageSubType msg_type = LM_MESSAGE_SUB_TYPE_NOT_SET; | 1641 LmMessageSubType msg_type = LM_MESSAGE_SUB_TYPE_NOT_SET; |
1640 bool quiet = FALSE; | 1642 bool quiet = FALSE; |
1643 bool eval = FALSE; | |
1641 | 1644 |
1642 if (!xmpp_is_online()) { | 1645 if (!xmpp_is_online()) { |
1643 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); | 1646 scr_LogPrint(LPRINT_NORMAL, "You are not connected."); |
1644 return; | 1647 return; |
1645 } | 1648 } |
1658 if (!strcmp(*paramlst, "-q")) { | 1661 if (!strcmp(*paramlst, "-q")) { |
1659 char **oldparamlst = paramlst; | 1662 char **oldparamlst = paramlst; |
1660 paramlst = split_arg(*(oldparamlst+1), 2, 1); // jid, message | 1663 paramlst = split_arg(*(oldparamlst+1), 2, 1); // jid, message |
1661 free_arg_lst(oldparamlst); | 1664 free_arg_lst(oldparamlst); |
1662 quiet = TRUE; | 1665 quiet = TRUE; |
1666 } else if (!strcmp(*paramlst, "-e")) { | |
1667 char **oldparamlst = paramlst; | |
1668 paramlst = split_arg(*(oldparamlst+1), 2, 1); // jid, message | |
1669 free_arg_lst(oldparamlst); | |
1670 eval = TRUE; | |
1663 } else if (!strcmp(*paramlst, "-f")) { | 1671 } else if (!strcmp(*paramlst, "-f")) { |
1664 char **oldparamlst = paramlst; | 1672 char **oldparamlst = paramlst; |
1665 paramlst = split_arg(*(oldparamlst+1), 2, 1); // filename, jid | 1673 paramlst = split_arg(*(oldparamlst+1), 2, 1); // filename, jid |
1666 free_arg_lst(oldparamlst); | 1674 free_arg_lst(oldparamlst); |
1667 if (!*paramlst) { | 1675 if (!*paramlst) { |
1721 g_free(fjid); | 1729 g_free(fjid); |
1722 return; | 1730 return; |
1723 } | 1731 } |
1724 | 1732 |
1725 if (!file) { | 1733 if (!file) { |
1726 msg = to_utf8(msg); | 1734 msg_utf8 = to_utf8(msg); |
1735 if (eval) { | |
1736 unescaped_msg = ut_unescape_tabs_cr(msg_utf8); | |
1737 // We must not free() if the original string was returned | |
1738 if (unescaped_msg == msg_utf8) | |
1739 unescaped_msg = NULL; | |
1740 } | |
1741 msg = (unescaped_msg ? unescaped_msg : msg_utf8); | |
1727 } else { | 1742 } else { |
1728 char *filename_xp; | 1743 char *filename_xp; |
1729 if (msg) | 1744 if (msg) |
1730 scr_LogPrint(LPRINT_NORMAL, "say_to: extra parameter ignored."); | 1745 scr_LogPrint(LPRINT_NORMAL, "say_to: extra parameter ignored."); |
1731 filename_xp = expand_filename(file); | 1746 filename_xp = expand_filename(file); |
1732 msg = load_message_from_file(filename_xp); | 1747 msg = msg_utf8 = load_message_from_file(filename_xp); |
1733 g_free(filename_xp); | 1748 g_free(filename_xp); |
1734 g_free(file); | 1749 g_free(file); |
1735 } | 1750 } |
1736 | 1751 |
1737 send_message_to(fjid, msg, NULL, msg_type, quiet); | 1752 send_message_to(fjid, msg, NULL, msg_type, quiet); |
1738 | 1753 |
1739 g_free(uncompletedfjid); | 1754 g_free(uncompletedfjid); |
1740 g_free(fjid); | 1755 g_free(fjid); |
1741 g_free(msg); | 1756 g_free(msg_utf8); |
1757 g_free(unescaped_msg); | |
1742 free_arg_lst(paramlst); | 1758 free_arg_lst(paramlst); |
1743 } | 1759 } |
1744 | 1760 |
1745 // buffer_updown(updown, nblines) | 1761 // buffer_updown(updown, nblines) |
1746 // updown: -1=up, +1=down | 1762 // updown: -1=up, +1=down |