1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

Replace most of the remaining stdio calls by estream calls.

--

We need to use es_fopen on Windows to cope with non-ascii file names.
This is quite a large but fortunately straightforward change.  At a
very few places we keep using stdio (for example due to the use of
popen).

GnuPG-bug-id: 5098
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2020-10-20 11:52:16 +02:00
parent c94ee1386e
commit 390497ea11
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
23 changed files with 220 additions and 216 deletions

View file

@ -41,14 +41,14 @@ static char *
findkey_fname (const char *key, const char *fname)
{
gpg_error_t err = 0;
FILE *fp;
estream_t fp;
int lnr = 0;
int c;
char *p, line[256];
int in_item = 0;
membuf_t mb = MEMBUF_ZERO;
fp = fopen (fname, "r");
fp = es_fopen (fname, "r");
if (!fp)
{
if (errno != ENOENT)
@ -59,14 +59,14 @@ findkey_fname (const char *key, const char *fname)
return NULL;
}
while (fgets (line, DIM(line)-1, fp))
while (es_fgets (line, DIM(line)-1, fp))
{
lnr++;
if (!*line || line[strlen(line)-1] != '\n')
{
/* Eat until end of line. */
while ( (c=getc (fp)) != EOF && c != '\n')
while ((c = es_getc (fp)) != EOF && c != '\n')
;
err = gpg_error (*line? GPG_ERR_LINE_TOO_LONG
: GPG_ERR_INCOMPLETE_LINE);
@ -130,14 +130,14 @@ findkey_fname (const char *key, const char *fname)
}
}
if ( !err && ferror (fp) )
if ( !err && es_ferror (fp) )
{
err = gpg_error_from_syserror ();
log_error (_("error reading '%s', line %d: %s\n"),
fname, lnr, gpg_strerror (err));
}
fclose (fp);
es_fclose (fp);
if (is_membuf_ready (&mb))
{
/* We have collected something. */