aboutsummaryrefslogtreecommitdiffstats
path: root/agent/protect-tool.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-11-11 14:22:51 +0000
committerWerner Koch <[email protected]>2020-11-11 14:23:22 +0000
commitd574213ce21c495d9432eeb5956e8857826876c6 (patch)
treee5ca4539906ac55975683f6163853f1bd6b5c2c0 /agent/protect-tool.c
parentgpg: Fix the previous commit. (diff)
downloadgnupg-d574213ce21c495d9432eeb5956e8857826876c6.tar.gz
gnupg-d574213ce21c495d9432eeb5956e8857826876c6.zip
w32: Replace some fopen by es_fopen.
* agent/protect-tool.c (read_file): Replace fopen by es_fopen. * dirmngr/dirmngr-client.c (read_pem_certificate): Ditto. (read_certificate): Ditto. * g10/keydb.c (rt_from_file): Ditto. * kbx/kbxutil.c (read_file): Ditto. * g10/plaintext.c (get_output_file) [__riscos__]: Remove code. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'agent/protect-tool.c')
-rw-r--r--agent/protect-tool.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/agent/protect-tool.c b/agent/protect-tool.c
index 8325f2564..1fcbd119f 100644
--- a/agent/protect-tool.c
+++ b/agent/protect-tool.c
@@ -237,7 +237,7 @@ make_advanced (const unsigned char *buf, size_t buflen)
static char *
read_file (const char *fname, size_t *r_length)
{
- FILE *fp;
+ estream_t fp;
char *buf;
size_t buflen;
@@ -245,10 +245,8 @@ read_file (const char *fname, size_t *r_length)
{
size_t nread, bufsize = 0;
- fp = stdin;
-#ifdef HAVE_DOSISH_SYSTEM
- setmode ( fileno(fp) , O_BINARY );
-#endif
+ fp = es_stdin;
+ es_set_binary (fp);
buf = NULL;
buflen = 0;
#define NCHUNK 8192
@@ -260,8 +258,8 @@ read_file (const char *fname, size_t *r_length)
else
buf = xrealloc (buf, bufsize);
- nread = fread (buf+buflen, 1, NCHUNK, fp);
- if (nread < NCHUNK && ferror (fp))
+ nread = es_fread (buf+buflen, 1, NCHUNK, fp);
+ if (nread < NCHUNK && es_ferror (fp))
{
log_error ("error reading '[stdin]': %s\n", strerror (errno));
xfree (buf);
@@ -277,30 +275,30 @@ read_file (const char *fname, size_t *r_length)
{
struct stat st;
- fp = fopen (fname, "rb");
+ fp = es_fopen (fname, "rb");
if (!fp)
{
log_error ("can't open '%s': %s\n", fname, strerror (errno));
return NULL;
}
- if (fstat (fileno(fp), &st))
+ if (fstat (es_fileno (fp), &st))
{
log_error ("can't stat '%s': %s\n", fname, strerror (errno));
- fclose (fp);
+ es_fclose (fp);
return NULL;
}
buflen = st.st_size;
buf = xmalloc (buflen+1);
- if (fread (buf, buflen, 1, fp) != 1)
+ if (es_fread (buf, buflen, 1, fp) != 1)
{
log_error ("error reading '%s': %s\n", fname, strerror (errno));
- fclose (fp);
+ es_fclose (fp);
xfree (buf);
return NULL;
}
- fclose (fp);
+ es_fclose (fp);
}
*r_length = buflen;