Commit 148cd52c authored by Niels Möller's avatar Niels Möller

(write_file): New function.

(write_string): Simplified error check, it's no real point in
calling ferror unless we also call fflush.

Rev: src/nettle/examples/io.c:1.5
Rev: src/nettle/examples/io.h:1.3
parent 26cd4968
......@@ -118,10 +118,16 @@ write_file(const char *name, unsigned size, const char *buffer)
res = fwrite(buffer, 1, size, f);
if (res < size || ferror(f))
if (res < size)
res = 0;
fclose(f);
return fclose(f) == 0 && res > 0;
}
int
write_string(FILE *f, unsigned size, const char *buffer)
{
size_t res = fwrite(buffer, 1, size, f);
return res > 0;
}
......
......@@ -49,6 +49,9 @@ read_file(const char *name, unsigned size, char **buffer);
int
write_file(const char *name, unsigned size, const char *buffer);
int
write_string(FILE *f, unsigned size, const char *buffer);
int
simple_random(struct yarrow256_ctx *ctx, const char *name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment