Changeset 8e9e2b7 for irc_send.c
- Timestamp:
- 2010-10-03T02:45:26Z (14 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_send.c
r88de0c9 r8e9e2b7 53 53 void irc_send_motd( irc_t *irc ) 54 54 { 55 char motd[2048]; 56 size_t len; 55 57 int fd; 56 58 57 59 fd = open( global.conf->motdfile, O_RDONLY ); 58 if( fd == -1 )60 if( fd == -1 || ( len = read( fd, motd, sizeof( motd ) - 1 ) ) <= 0 ) 59 61 { 60 62 irc_send_num( irc, 422, ":We don't need MOTDs." ); … … 62 64 else 63 65 { 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'; 68 71 linebuf[79] = len = 0; 69 72 max = sizeof( linebuf ) - 1; 70 73 71 74 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++) ) ) 73 76 { 74 77 if( linebuf[len] == '\n' || len == max ) … … 80 83 else if( linebuf[len] == '%' ) 81 84 { 82 read( fd, linebuf + len, 1);85 linebuf[len] = *(in++); 83 86 if( linebuf[len] == 'h' ) 84 87 add = irc->root->host; … … 87 90 else if( linebuf[len] == 'n' ) 88 91 add = irc->user->nick; 92 else if( linebuf[len] == '\0' ) 93 in --; 89 94 else 90 95 add = "%"; … … 99 104 } 100 105 irc_send_num( irc, 376, ":End of MOTD" ); 106 } 107 108 if( fd != -1 ) 101 109 close( fd ); 102 }103 110 } 104 111 … … 107 114 irc_channel_t *ic = NULL; 108 115 irc_user_t *iu = irc->root; 109 char text[1 024];116 char text[1100]; 110 117 va_list params; 111 118 char *dst;
Note: See TracChangeset
for help on using the changeset viewer.