mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-13 01:00:19 +00:00
add wdk changes to named branch
This commit is contained in:
@@ -19,13 +19,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "xchat.h"
|
||||
#include <glib/ghash.h>
|
||||
@@ -271,9 +269,6 @@ scrollback_load (session *sess)
|
||||
char *text;
|
||||
time_t stamp;
|
||||
int lines;
|
||||
char *map, *end_map;
|
||||
struct stat statbuf;
|
||||
const char *begin, *eol;
|
||||
|
||||
if (sess->text_scrollback == SET_DEFAULT)
|
||||
{
|
||||
@@ -293,32 +288,9 @@ scrollback_load (session *sess)
|
||||
if (fh == -1)
|
||||
return;
|
||||
|
||||
if (fstat (fh, &statbuf) < 0)
|
||||
return;
|
||||
|
||||
map = mmap (NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, fh, 0);
|
||||
if (map == MAP_FAILED)
|
||||
return;
|
||||
|
||||
end_map = map + statbuf.st_size;
|
||||
|
||||
lines = 0;
|
||||
begin = map;
|
||||
while (begin < end_map)
|
||||
while (waitline (fh, buf, sizeof buf, FALSE) != -1)
|
||||
{
|
||||
int n_bytes;
|
||||
|
||||
eol = memchr (begin, '\n', end_map - begin);
|
||||
|
||||
if (!eol)
|
||||
eol = end_map;
|
||||
|
||||
n_bytes = MIN (eol - begin, sizeof (buf) - 1);
|
||||
|
||||
strncpy (buf, begin, n_bytes);
|
||||
|
||||
buf[n_bytes] = 0;
|
||||
|
||||
if (buf[0] == 'T')
|
||||
{
|
||||
if (sizeof (time_t) == 4)
|
||||
@@ -334,8 +306,6 @@ scrollback_load (session *sess)
|
||||
}
|
||||
lines++;
|
||||
}
|
||||
|
||||
begin = eol + 1;
|
||||
}
|
||||
|
||||
sess->scrollwritten = lines;
|
||||
@@ -349,7 +319,6 @@ scrollback_load (session *sess)
|
||||
/*EMIT_SIGNAL (XP_TE_GENMSG, sess, "*", buf, NULL, NULL, NULL, 0);*/
|
||||
}
|
||||
|
||||
munmap (map, statbuf.st_size);
|
||||
close (fh);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user