1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +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>
Backported-from-master: 390497ea11
This commit is contained in:
Werner Koch 2020-10-20 11:52:16 +02:00
parent dd5fd4a760
commit 5c6e9b44cc
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
20 changed files with 208 additions and 197 deletions

View file

@ -35,7 +35,7 @@
NULL indicates that this module has been initialized and if the
LISTFP is also NULL, no list of qualified signatures exists. */
static char *listname;
static FILE *listfp;
static estream_t listfp;
/* Read the trustlist and return entry by entry. KEY must point to a
@ -59,7 +59,7 @@ read_list (char *key, char *country, int *lnr)
if (!listname)
{
listname = make_filename (gnupg_datadir (), "qualified.txt", NULL);
listfp = fopen (listname, "r");
listfp = es_fopen (listname, "r");
if (!listfp && errno != ENOENT)
{
err = gpg_error_from_syserror ();
@ -73,9 +73,9 @@ read_list (char *key, char *country, int *lnr)
do
{
if (!fgets (line, DIM(line)-1, listfp) )
if (!es_fgets (line, DIM(line)-1, listfp) )
{
if (feof (listfp))
if (es_feof (listfp))
return gpg_error (GPG_ERR_EOF);
return gpg_error_from_syserror ();
}
@ -83,7 +83,7 @@ read_list (char *key, char *country, int *lnr)
if (!*line || line[strlen(line)-1] != '\n')
{
/* Eat until end of line. */
while ( (c=getc (listfp)) != EOF && c != '\n')
while ((c = es_getc (listfp)) != EOF && c != '\n')
;
return gpg_error (*line? GPG_ERR_LINE_TOO_LONG
: GPG_ERR_INCOMPLETE_LINE);
@ -163,8 +163,8 @@ gpgsm_is_in_qualified_list (ctrl_t ctrl, ksba_cert_t cert, char *country)
if (listfp)
{
/* W32ce has no rewind, thus we use the equivalent code. */
fseek (listfp, 0, SEEK_SET);
clearerr (listfp);
es_fseek (listfp, 0, SEEK_SET);
es_clearerr (listfp);
}
while (!(err = read_list (key, mycountry, &lnr)))
{