mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
/CAT <file name> [seek position]
If we don't want to print the file from beginning. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@274 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
0e65ba80ca
commit
d2df583801
@ -224,19 +224,26 @@ static void cmd_version(char *data)
|
|||||||
|
|
||||||
static void cmd_cat(const char *data)
|
static void cmd_cat(const char *data)
|
||||||
{
|
{
|
||||||
char tmpbuf[1024], *str, *fname;
|
char *params, *fname, *fposstr;
|
||||||
|
char tmpbuf[1024], *str;
|
||||||
LINEBUF_REC *buffer = NULL;
|
LINEBUF_REC *buffer = NULL;
|
||||||
int f, ret, recvlen;
|
int f, ret, recvlen, fpos;
|
||||||
|
|
||||||
|
params = cmd_get_params(data, 2, &fname, &fposstr);
|
||||||
|
fname = convert_home(fname);
|
||||||
|
fpos = atoi(fposstr);
|
||||||
|
g_free(params);
|
||||||
|
|
||||||
fname = convert_home(data);
|
|
||||||
f = open(fname, O_RDONLY);
|
f = open(fname, O_RDONLY);
|
||||||
g_free(fname);
|
g_free(fname);
|
||||||
|
|
||||||
if (f == -1) {
|
if (f == -1) {
|
||||||
/* file not found */
|
/* file not found */
|
||||||
printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "%s", g_strerror(errno));
|
printtext(NULL, NULL, MSGLEVEL_CLIENTERROR, "%s", g_strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lseek(f, fpos, SEEK_SET);
|
||||||
do {
|
do {
|
||||||
recvlen = read(f, tmpbuf, sizeof(tmpbuf));
|
recvlen = read(f, tmpbuf, sizeof(tmpbuf));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user