Changeset 3864c08 for irc_send.c


Ignore:
Timestamp:
2011-10-21T03:00:54Z (13 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
e6b41b1
Parents:
6a45181 (diff), aea22cd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Big merge from pesco, closing some OTR issues: #759, #824, #839, #830.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_send.c

    r6a45181 r3864c08  
    110110}
    111111
    112 void irc_usermsg( irc_t *irc, char *format, ... )
    113 {
     112/* Used by some funcs that generate PRIVMSGs to figure out if we're talking to
     113   this person in /query or in a control channel. WARNING: callers rely on
     114   this returning a pointer at irc->user_nick, not a copy of it. */
     115const char *irc_user_msgdest( irc_user_t *iu )
     116{
     117        irc_t *irc = iu->irc;
    114118        irc_channel_t *ic = NULL;
    115         irc_user_t *iu = irc->root;
    116         char text[2048];
    117         va_list params;
    118         char *dst;
    119        
    120         va_start( params, format );
    121         g_vsnprintf( text, sizeof( text ), format, params );
    122         va_end( params );
    123        
    124         /* Too similar to bee_irc_user_msg()... */
     119
    125120        if( iu->last_channel )
    126121        {
     
    128123                        ic = iu->last_channel;
    129124                else
    130                         ic = irc_channel_with_user( irc, irc->root );
     125                        ic = irc_channel_with_user( irc, iu );
    131126        }
    132127       
    133128        if( ic )
    134                 dst = ic->name;
     129                return ic->name;
    135130        else
    136                 dst = irc->user->nick;
    137        
    138         irc_send_msg( irc->root, "PRIVMSG", dst, text, NULL );
     131                return irc->user->nick;
     132}
     133
     134/* cmd = "PRIVMSG" or "NOTICE" */
     135static void irc_usermsg_( const char *cmd, irc_user_t *iu, const char *format, va_list params )
     136{
     137        char text[2048];
     138        const char *dst;
     139       
     140        g_vsnprintf( text, sizeof( text ), format, params );
     141       
     142        dst = irc_user_msgdest( iu );
     143        irc_send_msg( iu, cmd, dst, text, NULL );
     144}
     145
     146void irc_usermsg(irc_user_t *iu, char *format, ... )
     147{
     148        va_list params;
     149        va_start( params, format );
     150        irc_usermsg_( "PRIVMSG", iu, format, params );
     151        va_end( params );
     152}
     153
     154void irc_usernotice(irc_user_t *iu, char *format, ... )
     155{
     156        va_list params;
     157        va_start( params, format );
     158        irc_usermsg_( "NOTICE", iu, format, params );
     159        va_end( params );
     160}
     161
     162void irc_rootmsg( irc_t *irc, char *format, ... )
     163{
     164        va_list params;
     165        va_start( params, format );
     166        irc_usermsg_( "PRIVMSG", irc->root, format, params );
     167        va_end( params );
    139168}
    140169
Note: See TracChangeset for help on using the changeset viewer.