Changeset 8e9e2b7 for irc_send.c


Ignore:
Timestamp:
2010-10-03T02:45:26Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
04f0c10
Parents:
88de0c9 (diff), 2af3e23 (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:

Merging mainline, which includes a huge msnp13 merge.

Not 100% sure about the OpenSSL merge, should double check that but I'm
currently offline.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_send.c

    r88de0c9 r8e9e2b7  
    5353void irc_send_motd( irc_t *irc )
    5454{
     55        char motd[2048];
     56        size_t len;
    5557        int fd;
    5658       
    5759        fd = open( global.conf->motdfile, O_RDONLY );
    58         if( fd == -1 )
     60        if( fd == -1 || ( len = read( fd, motd, sizeof( motd ) - 1 ) ) <= 0 )
    5961        {
    6062                irc_send_num( irc, 422, ":We don't need MOTDs." );
     
    6264        else
    6365        {
    64                 char linebuf[80];       /* Max. line length for MOTD's is 79 chars. It's what most IRC networks seem to do. */
    65                 char *add, max;
    66                 int len;
    67                
     66                char linebuf[80];
     67                char *add = "", max, *in;
     68               
     69                in = motd;
     70                motd[len] = '\0';
    6871                linebuf[79] = len = 0;
    6972                max = sizeof( linebuf ) - 1;
    7073               
    7174                irc_send_num( irc, 375, ":- %s Message Of The Day - ", irc->root->host );
    72                 while( read( fd, linebuf + len, 1 ) == 1 )
     75                while( ( linebuf[len] = *(in++) ) )
    7376                {
    7477                        if( linebuf[len] == '\n' || len == max )
     
    8083                        else if( linebuf[len] == '%' )
    8184                        {
    82                                 read( fd, linebuf + len, 1 );
     85                                linebuf[len] = *(in++);
    8386                                if( linebuf[len] == 'h' )
    8487                                        add = irc->root->host;
     
    8790                                else if( linebuf[len] == 'n' )
    8891                                        add = irc->user->nick;
     92                                else if( linebuf[len] == '\0' )
     93                                        in --;
    8994                                else
    9095                                        add = "%";
     
    99104                }
    100105                irc_send_num( irc, 376, ":End of MOTD" );
     106        }
     107       
     108        if( fd != -1 )
    101109                close( fd );
    102         }
    103110}
    104111
     
    107114        irc_channel_t *ic = NULL;
    108115        irc_user_t *iu = irc->root;
    109         char text[1024];
     116        char text[1100];
    110117        va_list params;
    111118        char *dst;
Note: See TracChangeset for help on using the changeset viewer.