mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
tools: Use platform abstraction for I/O.
* tools/gpg-connect-agent.c (main): Use a gpgrt_stream_t for 'script_fp'. Adapt accordingly. -- Werner asked me to make gpgconf use the platform abstractions that were introduced after gpgconf's inception. After doing that, I realized that 'read_line' is only used in two more places, one of which this patch takes care of. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
77b8aff4e1
commit
73d6572bd0
@ -1155,7 +1155,7 @@ main (int argc, char **argv)
|
|||||||
int rc;
|
int rc;
|
||||||
int cmderr;
|
int cmderr;
|
||||||
const char *opt_run = NULL;
|
const char *opt_run = NULL;
|
||||||
FILE *script_fp = NULL;
|
gpgrt_stream_t script_fp = NULL;
|
||||||
int use_tty, keep_line;
|
int use_tty, keep_line;
|
||||||
struct {
|
struct {
|
||||||
int collecting;
|
int collecting;
|
||||||
@ -1271,7 +1271,7 @@ main (int argc, char **argv)
|
|||||||
"--tcp-socket", "--raw-socket");
|
"--tcp-socket", "--raw-socket");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_run && !(script_fp = fopen (opt_run, "r")))
|
if (opt_run && !(script_fp = gpgrt_fopen (opt_run, "r")))
|
||||||
{
|
{
|
||||||
log_error ("cannot open run file '%s': %s\n",
|
log_error ("cannot open run file '%s': %s\n",
|
||||||
opt_run, strerror (errno));
|
opt_run, strerror (errno));
|
||||||
@ -1425,7 +1425,7 @@ main (int argc, char **argv)
|
|||||||
linesize = 0;
|
linesize = 0;
|
||||||
keep_line = 1;
|
keep_line = 1;
|
||||||
}
|
}
|
||||||
n = read_line (script_fp? script_fp:stdin,
|
n = gpgrt_read_line (script_fp ? script_fp : gpgrt_stdin,
|
||||||
&line, &linesize, &maxlength);
|
&line, &linesize, &maxlength);
|
||||||
}
|
}
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
@ -1433,7 +1433,7 @@ main (int argc, char **argv)
|
|||||||
log_error (_("error reading input: %s\n"), strerror (errno));
|
log_error (_("error reading input: %s\n"), strerror (errno));
|
||||||
if (script_fp)
|
if (script_fp)
|
||||||
{
|
{
|
||||||
fclose (script_fp);
|
gpgrt_fclose (script_fp);
|
||||||
script_fp = NULL;
|
script_fp = NULL;
|
||||||
log_error ("stopping script execution\n");
|
log_error ("stopping script execution\n");
|
||||||
continue;
|
continue;
|
||||||
@ -1445,7 +1445,7 @@ main (int argc, char **argv)
|
|||||||
/* EOF */
|
/* EOF */
|
||||||
if (script_fp)
|
if (script_fp)
|
||||||
{
|
{
|
||||||
fclose (script_fp);
|
gpgrt_fclose (script_fp);
|
||||||
script_fp = NULL;
|
script_fp = NULL;
|
||||||
if (opt.verbose)
|
if (opt.verbose)
|
||||||
log_info ("end of script\n");
|
log_info ("end of script\n");
|
||||||
@ -1683,17 +1683,17 @@ main (int argc, char **argv)
|
|||||||
log_error ("syntax error in run command\n");
|
log_error ("syntax error in run command\n");
|
||||||
if (script_fp)
|
if (script_fp)
|
||||||
{
|
{
|
||||||
fclose (script_fp);
|
gpgrt_fclose (script_fp);
|
||||||
script_fp = NULL;
|
script_fp = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (script_fp)
|
else if (script_fp)
|
||||||
{
|
{
|
||||||
log_error ("cannot nest run commands - stop\n");
|
log_error ("cannot nest run commands - stop\n");
|
||||||
fclose (script_fp);
|
gpgrt_fclose (script_fp);
|
||||||
script_fp = NULL;
|
script_fp = NULL;
|
||||||
}
|
}
|
||||||
else if (!(script_fp = fopen (p, "r")))
|
else if (!(script_fp = gpgrt_fopen (p, "r")))
|
||||||
{
|
{
|
||||||
log_error ("cannot open run file '%s': %s\n",
|
log_error ("cannot open run file '%s': %s\n",
|
||||||
p, strerror (errno));
|
p, strerror (errno));
|
||||||
@ -1864,7 +1864,7 @@ main (int argc, char **argv)
|
|||||||
if ((rc || cmderr) && script_fp)
|
if ((rc || cmderr) && script_fp)
|
||||||
{
|
{
|
||||||
log_error ("stopping script execution\n");
|
log_error ("stopping script execution\n");
|
||||||
fclose (script_fp);
|
gpgrt_fclose (script_fp);
|
||||||
script_fp = NULL;
|
script_fp = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user