Changeset b7fec48


Ignore:
Timestamp:
2016-10-18T06:57:41Z (3 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
c94e208
Parents:
f95e606
Message:

Support motd.txt files bigger than 2048 chars

By using g_file_get_contents()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_send.c

    rf95e606 rb7fec48  
    5454void irc_send_motd(irc_t *irc)
    5555{
    56         char motd[2048];
    57         ssize_t len;
    58         int fd;
    59 
    60         fd = open(global.conf->motdfile, O_RDONLY);
    61         if (fd == -1 || (len = read(fd, motd, sizeof(motd) - 1)) <= 0) {
     56        char *motd;
     57        size_t len;
     58
     59        g_file_get_contents(global.conf->motdfile, &motd, &len, NULL);
     60
     61        if (!motd || !len) {
    6262                irc_send_num(irc, 422, ":We don't need MOTDs.");
    6363        } else {
     
    6666
    6767                in = motd;
    68                 motd[len] = '\0';
    6968                linebuf[79] = len = 0;
    7069                max = sizeof(linebuf) - 1;
     
    101100        }
    102101
    103         if (fd != -1) {
    104                 close(fd);
    105         }
     102        g_free(motd);
     103
    106104}
    107105
Note: See TracChangeset for help on using the changeset viewer.