Skip to content
Snippets Groups Projects
Commit 72ca5b45 authored by Niels Möller's avatar Niels Möller
Browse files

(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 ffa61303
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment