Welcome to mirror list, hosted at ThFree Co, Russian Federation.

read_file_into.c « utils - github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 595694845524cd35417fb3821786d03328d3abcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Read an entire file into a BinarySink.
 */

#include <stdio.h>

#include "defs.h"
#include "misc.h"

bool read_file_into(BinarySink *bs, FILE *fp)
{
    char buf[4096];
    while (1) {
        size_t retd = fread(buf, 1, sizeof(buf), fp);
        if (retd == 0)
            return !ferror(fp);
        put_data(bs, buf, retd);
    }
}