[svn] GnuPG - r5397 - in trunk: agent common doc g10 scd sm tools
svn author wk
cvs at cvs.gnupg.org
Wed Aug 18 21:25:18 CEST 2010
Author: wk
Date: 2010-08-18 21:25:15 +0200 (Wed, 18 Aug 2010)
New Revision: 5397
Modified:
trunk/agent/ChangeLog
trunk/agent/gpg-agent.c
trunk/common/ChangeLog
trunk/common/estream.c
trunk/common/estream.h
trunk/common/logging.c
trunk/common/logging.h
trunk/doc/ChangeLog
trunk/doc/tools.texi
trunk/g10/ChangeLog
trunk/g10/gpg.c
trunk/scd/ChangeLog
trunk/scd/scdaemon.c
trunk/sm/ChangeLog
trunk/sm/gpgsm.c
trunk/tools/ChangeLog
trunk/tools/gpg-connect-agent.c
trunk/tools/gpgconf-comp.c
trunk/tools/gpgconf.c
trunk/tools/gpgconf.h
Log:
Fix regression in logging.
Add a registry key to enable catch-all remote debugging for W32.
Replace more stdio stuff by estream.
Modified: trunk/agent/ChangeLog
===================================================================
--- trunk/agent/ChangeLog 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/agent/ChangeLog 2010-08-18 19:25:15 UTC (rev 5397)
@@ -1,3 +1,7 @@
+2010-08-16 Werner Koch <wk at g10code.com>
+
+ * gpg-agent.c: Repalce remaining printf by es_printf.
+
2010-08-11 Werner Koch <wk at g10code.com>
* call-pinentry.c (agent_get_passphrase, agent_askpin): Fix
Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/common/ChangeLog 2010-08-18 19:25:15 UTC (rev 5397)
@@ -1,5 +1,16 @@
+2010-08-18 Werner Koch <wk at g10code.com>
+
+ * logging.c (writen): Add arg IS_SOCKET.
+ (fun_writer): Pass the is_socket flag.
+ (do_logv) [W32]: Allow for a default log stream
+
+ * estream.c (struct estream_internal): Remove obsolete fields
+ PRINT_FP, PRINT_ERRNO, PRINT_ERR and all remaining code cruft.
+
2010-08-16 Werner Koch <wk at g10code.com>
+ * estream.c (es_printf_unlocked, es_printf): New.
+
* asshelp.c (lock_agent_t): Rename to lock_spawn_t.
(lock_agent_spawning, unlock_agent_spawning): Factor code out to ...
(lock_spawning, unlock_spawning): .. new.
Modified: trunk/doc/ChangeLog
===================================================================
--- trunk/doc/ChangeLog 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/doc/ChangeLog 2010-08-18 19:25:15 UTC (rev 5397)
@@ -1,3 +1,7 @@
+2010-08-18 Werner Koch <wk at g10code.com>
+
+ * tools.texi (watchgnupg): Add examples section.
+
2010-06-10 Werner Koch <wk at g10code.com>
* Makefile.am (gnupg_TEXINFOS): Add dirmngr.texi.
Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/g10/ChangeLog 2010-08-18 19:25:15 UTC (rev 5397)
@@ -1,3 +1,9 @@
+2010-08-16 Werner Koch <wk at g10code.com>
+
+ * gpg.c (list_config, gpgconf_list): Use es_printf.
+ (print_hex, print_hashline, print_algo_numbers)
+ (print_algo_names): Use es_printf.
+
2010-07-20 Werner Koch <wk at g10code.com>
* mainproc.c (print_pkenc_list): Write a STATUS_ERROR. Fixes
Modified: trunk/scd/ChangeLog
===================================================================
--- trunk/scd/ChangeLog 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/scd/ChangeLog 2010-08-18 19:25:15 UTC (rev 5397)
@@ -1,3 +1,7 @@
+2010-08-16 Werner Koch <wk at g10code.com>
+
+ * scdaemon.c: Replace remaining printf by es_printf.
+
2010-06-09 Werner Koch <wk at g10code.com>
* scdaemon.c (main): s/log_set_get_tid_callback/log_set_pid_suffix_cb/.
Modified: trunk/sm/ChangeLog
===================================================================
--- trunk/sm/ChangeLog 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/sm/ChangeLog 2010-08-18 19:25:15 UTC (rev 5397)
@@ -1,5 +1,7 @@
2010-08-16 Werner Koch <wk at g10code.com>
+ * gpgsm.c (main) <aGPGConfList>: Use es_printf.
+
* call-dirmngr.c (start_dirmngr_ext): Use new start_new_dirmngr
function.
Modified: trunk/tools/ChangeLog
===================================================================
--- trunk/tools/ChangeLog 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/tools/ChangeLog 2010-08-18 19:25:15 UTC (rev 5397)
@@ -1,3 +1,13 @@
+2010-08-16 Werner Koch <wk at g10code.com>
+
+ * gpgconf.c (get_outfp): Change to use estream.
+ (main): Replace fprintf by es_fprintf.
+ * gpgconf-comp.c (gc_component_list_components)
+ (gc_check_programs, gc_component_list_options)
+ (gc_component_change_options, gc_component_check_options)
+ (list_one_option, gc_process_gpgconf_conf): Replace FILE* args by
+ estream_t.
+
2010-08-13 Werner Koch <wk at g10code.com>
* Makefile.am (gpgkey2ssh_LDADD): Add NETLIBS.
Modified: trunk/agent/gpg-agent.c
===================================================================
--- trunk/agent/gpg-agent.c 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/agent/gpg-agent.c 2010-08-18 19:25:15 UTC (rev 5397)
@@ -823,9 +823,9 @@
if (greeting)
{
- fprintf (stderr, "%s %s; %s\n",
- strusage(11), strusage(13), strusage(14) );
- fprintf (stderr, "%s\n", strusage(15) );
+ es_fprintf (es_stderr, "%s %s; %s\n",
+ strusage(11), strusage(13), strusage(14) );
+ es_fprintf (es_stderr, "%s\n", strusage(15) );
}
#ifdef IS_DEVELOPMENT_VERSION
/* We don't want to print it here because gpg-agent is useful of its
@@ -874,12 +874,12 @@
filename = make_filename (opt.homedir, "gpg-agent.conf", NULL );
filename_esc = percent_escape (filename, NULL);
- printf ("gpgconf-gpg-agent.conf:%lu:\"%s\n",
+ es_printf ("gpgconf-gpg-agent.conf:%lu:\"%s\n",
GC_OPT_FLAG_DEFAULT, filename_esc);
xfree (filename);
xfree (filename_esc);
- printf ("verbose:%lu:\n"
+ es_printf ("verbose:%lu:\n"
"quiet:%lu:\n"
"debug-level:%lu:\"none:\n"
"log-file:%lu:\n",
@@ -887,35 +887,35 @@
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME,
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME,
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME );
- printf ("default-cache-ttl:%lu:%d:\n",
+ es_printf ("default-cache-ttl:%lu:%d:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, DEFAULT_CACHE_TTL );
- printf ("default-cache-ttl-ssh:%lu:%d:\n",
+ es_printf ("default-cache-ttl-ssh:%lu:%d:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, DEFAULT_CACHE_TTL_SSH );
- printf ("max-cache-ttl:%lu:%d:\n",
+ es_printf ("max-cache-ttl:%lu:%d:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MAX_CACHE_TTL );
- printf ("max-cache-ttl-ssh:%lu:%d:\n",
+ es_printf ("max-cache-ttl-ssh:%lu:%d:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MAX_CACHE_TTL_SSH );
- printf ("enforce-passphrase-constraints:%lu:\n",
+ es_printf ("enforce-passphrase-constraints:%lu:\n",
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
- printf ("min-passphrase-len:%lu:%d:\n",
+ es_printf ("min-passphrase-len:%lu:%d:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MIN_PASSPHRASE_LEN );
- printf ("min-passphrase-nonalpha:%lu:%d:\n",
+ es_printf ("min-passphrase-nonalpha:%lu:%d:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME,
MIN_PASSPHRASE_NONALPHA);
- printf ("check-passphrase-pattern:%lu:\n",
+ es_printf ("check-passphrase-pattern:%lu:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME);
- printf ("max-passphrase-days:%lu:%d:\n",
+ es_printf ("max-passphrase-days:%lu:%d:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME,
MAX_PASSPHRASE_DAYS);
- printf ("enable-passphrase-history:%lu:\n",
+ es_printf ("enable-passphrase-history:%lu:\n",
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
- printf ("no-grab:%lu:\n",
+ es_printf ("no-grab:%lu:\n",
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
- printf ("ignore-cache-for-signing:%lu:\n",
+ es_printf ("ignore-cache-for-signing:%lu:\n",
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
- printf ("allow-mark-trusted:%lu:\n",
+ es_printf ("allow-mark-trusted:%lu:\n",
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
- printf ("disable-scdaemon:%lu:\n",
+ es_printf ("disable-scdaemon:%lu:\n",
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
agent_exit (0);
@@ -1026,7 +1026,7 @@
fflush (NULL);
#ifdef HAVE_W32_SYSTEM
pid = getpid ();
- printf ("set GPG_AGENT_INFO=%s;%lu;1\n", socket_name, (ulong)pid);
+ es_printf ("set GPG_AGENT_INFO=%s;%lu;1\n", socket_name, (ulong)pid);
#else /*!HAVE_W32_SYSTEM*/
pid = fork ();
if (pid == (pid_t)-1)
@@ -1098,24 +1098,24 @@
if (env_file_name)
{
- FILE *fp;
+ estream_t fp;
- fp = fopen (env_file_name, "w");
+ fp = es_fopen (env_file_name, "w");
if (!fp)
log_error (_("error creating `%s': %s\n"),
env_file_name, strerror (errno));
else
{
- fputs (infostr, fp);
- putc ('\n', fp);
+ es_fputs (infostr, fp);
+ es_putc ('\n', fp);
if (opt.ssh_support)
{
- fputs (infostr_ssh_sock, fp);
- putc ('\n', fp);
- fputs (infostr_ssh_pid, fp);
- putc ('\n', fp);
+ es_fputs (infostr_ssh_sock, fp);
+ es_putc ('\n', fp);
+ es_fputs (infostr_ssh_pid, fp);
+ es_putc ('\n', fp);
}
- fclose (fp);
+ es_fclose (fp);
}
}
@@ -1163,22 +1163,24 @@
if (csh_style)
{
*strchr (infostr, '=') = ' ';
- printf ("setenv %s\n", infostr);
+ es_printf ("setenv %s\n", infostr);
if (opt.ssh_support)
{
*strchr (infostr_ssh_sock, '=') = ' ';
- printf ("setenv %s\n", infostr_ssh_sock);
+ es_printf ("setenv %s\n", infostr_ssh_sock);
*strchr (infostr_ssh_pid, '=') = ' ';
- printf ("setenv %s\n", infostr_ssh_pid);
+ es_printf ("setenv %s\n", infostr_ssh_pid);
}
}
else
{
- printf ( "%s; export GPG_AGENT_INFO;\n", infostr);
+ es_printf ( "%s; export GPG_AGENT_INFO;\n", infostr);
if (opt.ssh_support)
{
- printf ("%s; export SSH_AUTH_SOCK;\n", infostr_ssh_sock);
- printf ("%s; export SSH_AGENT_PID;\n", infostr_ssh_pid);
+ es_printf ("%s; export SSH_AUTH_SOCK;\n",
+ infostr_ssh_sock);
+ es_printf ("%s; export SSH_AGENT_PID;\n",
+ infostr_ssh_pid);
}
}
xfree (infostr);
Modified: trunk/common/estream.c
===================================================================
--- trunk/common/estream.c 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/common/estream.c 2010-08-18 19:25:15 UTC (rev 5397)
@@ -218,7 +218,7 @@
es_cookie_seek_function_t func_seek;
es_cookie_close_function_t func_close;
int strategy;
- int fd;
+ int fd; /* Value to return by es_fileno(). */
struct
{
unsigned int err: 1;
@@ -227,11 +227,8 @@
unsigned int deallocate_buffer: 1;
unsigned int is_stdstream:1; /* This is a standard stream. */
unsigned int stdstream_fd:2; /* 0, 1 or 2 for a standard stream. */
- unsigned int print_err: 1; /* Error in print_fun_writer. */
unsigned int printable_fname_inuse: 1; /* es_fname_get has been used. */
- int print_errno; /* Errno from print_fun_writer. */
- size_t print_ntotal; /* Bytes written from in print_fun_writer. */
- FILE *print_fp; /* Stdio stream used by print_fun_writer. */
+ size_t print_ntotal; /* Bytes written from in print_writer. */
};
@@ -899,7 +896,8 @@
int no_close; /* If set we won't close the file pointer. */
} *estream_cookie_fp_t;
-/* Create function for fd objects. */
+
+/* Create function for FILE objects. */
static int
es_func_fp_create (void **cookie, FILE *fp,
unsigned int modeflags, int no_close)
@@ -924,7 +922,7 @@
*cookie = fp_cookie;
err = 0;
}
-
+
return err;
}
@@ -948,12 +946,10 @@
/* Write function for FILE* objects. */
static ssize_t
es_func_fp_write (void *cookie, const void *buffer, size_t size)
-
{
estream_cookie_fp_t file_cookie = cookie;
size_t bytes_written;
-
if (file_cookie->fp)
{
#ifdef HAVE_W32_SYSTEM
@@ -1285,10 +1281,7 @@
stream->intern->func_close = functions.func_close;
stream->intern->strategy = _IOFBF;
stream->intern->fd = fd;
- stream->intern->print_err = 0;
- stream->intern->print_errno = 0;
stream->intern->print_ntotal = 0;
- stream->intern->print_fp = NULL;
stream->intern->indicators.err = 0;
stream->intern->indicators.eof = 0;
stream->intern->is_stdstream = 0;
@@ -1319,14 +1312,6 @@
es_cookie_close_function_t func_close;
int err, tmp_err;
- if (stream->intern->print_fp)
- {
- int save_errno = errno;
- fclose (stream->intern->print_fp);
- stream->intern->print_fp = NULL;
- _set_errno (save_errno);
- }
-
func_close = stream->intern->func_close;
err = 0;
@@ -3205,6 +3190,38 @@
return ret;
}
+
+int
+es_printf_unlocked (const char *ES__RESTRICT format, ...)
+{
+ int ret;
+
+ va_list ap;
+ va_start (ap, format);
+ ret = es_print (es_stdout, format, ap);
+ va_end (ap);
+
+ return ret;
+}
+
+
+int
+es_printf (const char *ES__RESTRICT format, ...)
+{
+ int ret;
+ estream_t stream = es_stdout;
+
+ va_list ap;
+ va_start (ap, format);
+ ESTREAM_LOCK (stream);
+ ret = es_print (stream, format, ap);
+ ESTREAM_UNLOCK (stream);
+ va_end (ap);
+
+ return ret;
+}
+
+
/* A variant of asprintf. The function returns the allocated buffer
or NULL on error; ERRNO is set in the error case. The caller
should use es_free to release the buffer. This function actually
Modified: trunk/common/estream.h
===================================================================
--- trunk/common/estream.h 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/common/estream.h 2010-08-18 19:25:15 UTC (rev 5397)
@@ -121,6 +121,8 @@
#define es_free _ESTREAM_PREFIX(es_free)
#define es_fprintf _ESTREAM_PREFIX(es_fprintf)
#define es_fprintf_unlocked _ESTREAM_PREFIX(es_fprintf_unlocked)
+#define es_printf _ESTREAM_PREFIX(es_printf)
+#define es_printf_unlocked _ESTREAM_PREFIX(es_printf_unlocked)
#define es_vfprintf _ESTREAM_PREFIX(es_vfprint)
#define es_vfprintf_unlocked _ESTREAM_PREFIX(es_vfprint_unlocked)
#define es_setvbuf _ESTREAM_PREFIX(es_setvbuf)
@@ -345,6 +347,11 @@
const char *ES__RESTRICT format, ...)
_ESTREAM_GCC_A_PRINTF(2,3);
+int es_printf (const char *ES__RESTRICT format, ...)
+ _ESTREAM_GCC_A_PRINTF(1,2);
+int es_printf_unlocked (const char *ES__RESTRICT format, ...)
+ _ESTREAM_GCC_A_PRINTF(1,2);
+
int es_vfprintf (estream_t ES__RESTRICT stream,
const char *ES__RESTRICT format, va_list ap)
_ESTREAM_GCC_A_PRINTF(2,0);
Modified: trunk/common/logging.c
===================================================================
--- trunk/common/logging.c 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/common/logging.c 2010-08-18 19:25:15 UTC (rev 5397)
@@ -120,19 +120,24 @@
/* Write NBYTES of BUFFER to file descriptor FD. */
static int
-writen (int fd, const void *buffer, size_t nbytes)
+writen (int fd, const void *buffer, size_t nbytes, int is_socket)
{
const char *buf = buffer;
size_t nleft = nbytes;
int nwritten;
+#ifndef HAVE_W32_SYSTEM
+ (void)is_socket; /* Not required. */
+#endif
while (nleft > 0)
{
#ifdef HAVE_W32_SYSTEM
- nwritten = send (fd, buf, nleft, 0);
-#else
- nwritten = write (fd, buf, nleft);
+ if (is_socket)
+ nwritten = send (fd, buf, nleft, 0);
+ else
#endif
+ nwritten = write (fd, buf, nleft);
+
if (nwritten < 0 && errno == EINTR)
continue;
if (nwritten < 0)
@@ -171,6 +176,9 @@
{
struct fun_cookie_s *cookie = cookie_arg;
+ /* FIXME: Use only estream with a callback for socket writing. This
+ avoids the ugly mix of fd and estream code. */
+
/* Note that we always try to reconnect to the socket but print
error messages only the first time an error occured. If
RUNNING_DETACHED is set we don't fall back to stderr and even do
@@ -345,7 +353,7 @@
}
log_socket = cookie->fd;
- if (cookie->fd != -1 && !writen (cookie->fd, buffer, size))
+ if (cookie->fd != -1 && !writen (cookie->fd, buffer, size, cookie->is_socket))
return (ssize_t)size; /* Okay. */
if (!running_detached && cookie->fd != -1
@@ -561,7 +569,16 @@
{
if (!logstream)
{
+#ifdef HAVE_W32_SYSTEM
+ char *tmp;
+
+ tmp = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG",
+ "DefaultLogFile");
+ log_set_file (tmp);
+ jnlib_free (tmp);
+#else
log_set_file (NULL); /* Make sure a log stream has been set. */
+#endif
assert (logstream);
}
Modified: trunk/common/logging.h
===================================================================
--- trunk/common/logging.h 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/common/logging.h 2010-08-18 19:25:15 UTC (rev 5397)
@@ -24,6 +24,7 @@
#include <stdio.h>
#include "estream.h"
#include "mischelp.h"
+#include "w32help.h"
/* Flag values for log_set_prefix. */
#define JNLIB_LOG_WITH_PREFIX 1
Modified: trunk/doc/tools.texi
===================================================================
--- trunk/doc/tools.texi 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/doc/tools.texi 2010-08-18 19:25:15 UTC (rev 5397)
@@ -42,12 +42,13 @@
@end ifset
@mansect description
-Most of the main utilities are able to write their log files to a
-Unix Domain socket if configured that way. @command{watchgnupg} is a simple
-listener for such a socket. It ameliorates the output with a time
-stamp and makes sure that long lines are not interspersed with log
-output from other utilities.
+Most of the main utilities are able to write their log files to a Unix
+Domain socket if configured that way. @command{watchgnupg} is a simple
+listener for such a socket. It ameliorates the output with a time stamp
+and makes sure that long lines are not interspersed with log output from
+other utilities. This tool is not available for Windows.
+
@noindent
@command{watchgnupg} is commonly invoked as
@@ -70,6 +71,10 @@
@opindex force
Delete an already existing socket file.
+ at item --tcp @var{n}
+Instead of reading from a local socket, listen for connects on TCP port
+ at var{n}.
+
@item --verbose
@opindex verbose
Enable extra informational output.
@@ -84,6 +89,41 @@
@end table
+ at noindent
+ at mansect examples
+ at chapheading Examples
+
+ at example
+$ watchgnupg --force /home/foo/.gnupg/S.log
+ at end example
+
+This waits for connections on the local socket
+ at file{/home/foo/.gnupg/S.log} and shows all log entries. To make this
+work the option @option{log-file} needs to be used with all modules
+which logs are to be shown. The value for that option must be given
+with a special prefix (e.g. in the conf file):
+
+ at example
+log-file socket:///home/foo/.gnupg/S.log
+ at end example
+
+For debugging purposes it is also possible to do remote logging. Take
+care if you use this feature because the information is send in the
+clear over the network. Use this syntax in the conf files:
+
+ at example
+log-file tcp://192.168.1.1:4711
+ at end example
+
+You may use any port and not just 4711 as shown above; only IP addresses
+are supported (v4 and v6) and no host names. You need to start
+ at command{watchgnupg} with the @option{tcp} option. Note that under
+Windows the registry entry @var{HKCU\Software\GNU\GnuPG:DefaultLogFile}
+can be used to change the default log output from @code{stderr} to
+whatever is given by that entry. However the only useful entry is a TCP
+name for remote debugging.
+
+
@mansect see also
@ifset isman
@command{gpg}(1),
Modified: trunk/g10/gpg.c
===================================================================
--- trunk/g10/gpg.c 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/g10/gpg.c 2010-08-18 19:25:15 UTC (rev 5397)
@@ -1449,8 +1449,8 @@
if(first)
first=0;
else
- printf(";");
- printf("%d",i);
+ es_printf (";");
+ es_printf ("%d",i);
}
}
}
@@ -1468,8 +1468,8 @@
if(first)
first=0;
else
- printf(";");
- printf("%s",mapper(i));
+ es_printf (";");
+ es_printf ("%s",mapper(i));
}
}
}
@@ -1508,10 +1508,10 @@
{
print_sanitized_string2 (stdout, sl->d, ':',';');
if(sl->next)
- printf(";");
+ es_printf(";");
}
- printf("\n");
+ es_printf("\n");
}
any=1;
@@ -1519,33 +1519,33 @@
if(show_all || ascii_strcasecmp(name,"version")==0)
{
- printf("cfg:version:");
+ es_printf("cfg:version:");
es_write_sanitized (es_stdout, VERSION, strlen(VERSION), ":", NULL);
- printf("\n");
+ es_printf ("\n");
any=1;
}
if(show_all || ascii_strcasecmp(name,"pubkey")==0)
{
- printf("cfg:pubkey:");
+ es_printf ("cfg:pubkey:");
print_algo_numbers (openpgp_pk_test_algo);
- printf("\n");
+ es_printf ("\n");
any=1;
}
if(show_all || ascii_strcasecmp(name,"cipher")==0)
{
- printf("cfg:cipher:");
+ es_printf ("cfg:cipher:");
print_algo_numbers(openpgp_cipher_test_algo);
- printf("\n");
+ es_printf ("\n");
any=1;
}
if (show_all || !ascii_strcasecmp (name,"ciphername"))
{
- printf ("cfg:ciphername:");
+ es_printf ("cfg:ciphername:");
print_algo_names (openpgp_cipher_test_algo,openpgp_cipher_algo_name);
- printf ("\n");
+ es_printf ("\n");
any = 1;
}
@@ -1553,9 +1553,9 @@
|| ascii_strcasecmp(name,"digest")==0
|| ascii_strcasecmp(name,"hash")==0)
{
- printf("cfg:digest:");
+ es_printf ("cfg:digest:");
print_algo_numbers(openpgp_md_test_algo);
- printf("\n");
+ es_printf ("\n");
any=1;
}
@@ -1563,17 +1563,17 @@
|| !ascii_strcasecmp(name,"digestname")
|| !ascii_strcasecmp(name,"hashname"))
{
- printf ("cfg:digestname:");
+ es_printf ("cfg:digestname:");
print_algo_names (openpgp_md_test_algo, gcry_md_algo_name);
- printf("\n");
+ es_printf ("\n");
any=1;
}
if(show_all || ascii_strcasecmp(name,"compress")==0)
{
- printf("cfg:compress:");
+ es_printf ("cfg:compress:");
print_algo_numbers(check_compress_algo);
- printf("\n");
+ es_printf ("\n");
any=1;
}
@@ -1587,7 +1587,7 @@
for (p=list; p && (p2 = strchr (p, '\n')); p = p2+1)
{
*p2 = 0;
- printf("cfg:ccid-reader-id:%s\n", p);
+ es_printf ("cfg:ccid-reader-id:%s\n", p);
}
free (list);
#endif
@@ -1613,23 +1613,24 @@
{
char *configfile_esc = percent_escape (configfile, NULL);
- printf ("gpgconf-gpg.conf:%lu:\"%s\n",
- GC_OPT_FLAG_DEFAULT, configfile_esc ? configfile_esc : "/dev/null");
- printf ("verbose:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("reader-port:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("default-key:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("encrypt-to:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("auto-key-locate:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("log-file:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("debug-level:%lu:\"none:\n", GC_OPT_FLAG_DEFAULT);
- printf ("group:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("gpgconf-gpg.conf:%lu:\"%s\n",
+ GC_OPT_FLAG_DEFAULT,
+ configfile_esc ? configfile_esc : "/dev/null");
+ es_printf ("verbose:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("reader-port:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("default-key:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("encrypt-to:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("auto-key-locate:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("log-file:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("debug-level:%lu:\"none:\n", GC_OPT_FLAG_DEFAULT);
+ es_printf ("group:%lu:\n", GC_OPT_FLAG_NONE);
/* The next one is an info only item and should match the macros at
the top of keygen.c */
- printf ("default_pubkey_algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
- "RSA-2048");
+ es_printf ("default_pubkey_algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
+ "RSA-2048");
xfree (configfile_esc);
}
@@ -2992,11 +2993,12 @@
if( nogreeting )
greeting = 0;
- if( greeting ) {
- fprintf(stderr, "%s %s; %s\n",
- strusage(11), strusage(13), strusage(14) );
- fprintf(stderr, "%s\n", strusage(15) );
- }
+ if( greeting )
+ {
+ es_fprintf (es_stderr, "%s %s; %s\n",
+ strusage(11), strusage(13), strusage(14) );
+ es_fprintf (es_stderr, "%s\n", strusage(15) );
+ }
#ifdef IS_DEVELOPMENT_VERSION
if (!opt.batch)
{
@@ -4092,33 +4094,33 @@
display, but there are a few other similar assumptions in the
display code. */
static void
-print_hex( gcry_md_hd_t md, int algo, const char *fname )
+print_hex (gcry_md_hd_t md, int algo, const char *fname)
{
int i,n,count,indent=0;
const byte *p;
- if(fname)
- indent=printf("%s: ",fname);
+ if (fname)
+ indent = es_printf("%s: ",fname);
- if(indent>40)
+ if (indent>40)
{
printf("\n");
indent=0;
}
- if(algo==DIGEST_ALGO_RMD160)
- indent+=printf("RMD160 = ");
- else if(algo>0)
- indent+=printf("%6s = ", gcry_md_algo_name (algo));
+ if (algo==DIGEST_ALGO_RMD160)
+ indent += es_printf("RMD160 = ");
+ else if (algo>0)
+ indent += es_printf("%6s = ", gcry_md_algo_name (algo));
else
- algo=abs(algo);
+ algo = abs(algo);
- count=indent;
+ count = indent;
p = gcry_md_read (md, algo);
n = gcry_md_get_algo_dlen (algo);
- count += printf ("%02X",*p++);
+ count += es_printf ("%02X",*p++);
for(i=1;i<n;i++,p++)
{
@@ -4126,14 +4128,14 @@
{
if(count+2>79)
{
- printf("\n%*s",indent," ");
- count=indent;
+ es_printf ("\n%*s",indent," ");
+ count = indent;
}
else
- count+=printf(" ");
+ count += es_printf(" ");
- if(!(i%8))
- count+=printf(" ");
+ if (!(i%8))
+ count += es_printf(" ");
}
else if (n==20)
{
@@ -4141,58 +4143,59 @@
{
if(count+4>79)
{
- printf("\n%*s",indent," ");
+ es_printf ("\n%*s",indent," ");
count=indent;
}
else
- count+=printf(" ");
+ count += es_printf(" ");
}
- if(!(i%10))
- count+=printf(" ");
+ if (!(i%10))
+ count += es_printf(" ");
}
else
{
if(!(i%4))
{
- if(count+8>79)
+ if (count+8>79)
{
- printf("\n%*s",indent," ");
+ es_printf ("\n%*s",indent," ");
count=indent;
}
else
- count+=printf(" ");
+ count += es_printf(" ");
}
}
- count+=printf("%02X",*p);
+ count += es_printf("%02X",*p);
}
- printf("\n");
+ es_printf ("\n");
}
static void
print_hashline( gcry_md_hd_t md, int algo, const char *fname )
{
- int i, n;
- const byte *p;
+ int i, n;
+ const byte *p;
- if ( fname ) {
- for (p = fname; *p; p++ ) {
- if ( *p <= 32 || *p > 127 || *p == ':' || *p == '%' )
- printf("%%%02X", *p );
- else
- putchar( *p );
+ if ( fname )
+ {
+ for (p = fname; *p; p++ )
+ {
+ if ( *p <= 32 || *p > 127 || *p == ':' || *p == '%' )
+ es_printf ("%%%02X", *p );
+ else
+ es_putc (*p, es_stdout);
}
}
- putchar(':');
- printf("%d:", algo );
- p = gcry_md_read (md, algo);
- n = gcry_md_get_algo_dlen (algo);
- for(i=0; i < n ; i++, p++ )
- printf("%02X", *p );
- putchar(':');
- putchar('\n');
+ es_putc (':', es_stdout);
+ es_printf ("%d:", algo);
+ p = gcry_md_read (md, algo);
+ n = gcry_md_get_algo_dlen (algo);
+ for(i=0; i < n ; i++, p++ )
+ es_printf ("%02X", *p);
+ es_fputs (":\n", es_stdout);
}
static void
Modified: trunk/scd/scdaemon.c
===================================================================
--- trunk/scd/scdaemon.c 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/scd/scdaemon.c 2010-08-18 19:25:15 UTC (rev 5397)
@@ -617,9 +617,9 @@
if (greeting)
{
- fprintf (stderr, "%s %s; %s\n",
- strusage(11), strusage(13), strusage(14) );
- fprintf (stderr, "%s\n", strusage(15) );
+ es_fprintf (es_stderr, "%s %s; %s\n",
+ strusage(11), strusage(13), strusage(14) );
+ es_fprintf (es_stderr, "%s\n", strusage(15) );
}
#ifdef IS_DEVELOPMENT_VERSION
log_info ("NOTE: this is a development version!\n");
@@ -651,30 +651,30 @@
filename = make_filename (opt.homedir, "scdaemon.conf", NULL);
filename_esc = percent_escape (filename, NULL);
- printf ("gpgconf-scdaemon.conf:%lu:\"%s\n",
- GC_OPT_FLAG_DEFAULT, filename_esc);
+ es_printf ("gpgconf-scdaemon.conf:%lu:\"%s\n",
+ GC_OPT_FLAG_DEFAULT, filename_esc);
xfree (filename_esc);
xfree (filename);
- printf ("verbose:%lu:\n"
- "quiet:%lu:\n"
- "debug-level:%lu:\"none:\n"
- "log-file:%lu:\n",
- GC_OPT_FLAG_NONE,
- GC_OPT_FLAG_NONE,
- GC_OPT_FLAG_DEFAULT,
- GC_OPT_FLAG_NONE );
+ es_printf ("verbose:%lu:\n"
+ "quiet:%lu:\n"
+ "debug-level:%lu:\"none:\n"
+ "log-file:%lu:\n",
+ GC_OPT_FLAG_NONE,
+ GC_OPT_FLAG_NONE,
+ GC_OPT_FLAG_DEFAULT,
+ GC_OPT_FLAG_NONE );
- printf ("reader-port:%lu:\n", GC_OPT_FLAG_NONE );
- printf ("ctapi-driver:%lu:\n", GC_OPT_FLAG_NONE );
- printf ("pcsc-driver:%lu:\"%s:\n",
+ es_printf ("reader-port:%lu:\n", GC_OPT_FLAG_NONE );
+ es_printf ("ctapi-driver:%lu:\n", GC_OPT_FLAG_NONE );
+ es_printf ("pcsc-driver:%lu:\"%s:\n",
GC_OPT_FLAG_DEFAULT, DEFAULT_PCSC_DRIVER );
#ifdef HAVE_LIBUSB
- printf ("disable-ccid:%lu:\n", GC_OPT_FLAG_NONE );
+ es_printf ("disable-ccid:%lu:\n", GC_OPT_FLAG_NONE );
#endif
- printf ("deny-admin:%lu:\n", GC_OPT_FLAG_NONE );
- printf ("disable-keypad:%lu:\n", GC_OPT_FLAG_NONE );
- printf ("card-timeout:%lu:%d:\n", GC_OPT_FLAG_DEFAULT, 0);
+ es_printf ("deny-admin:%lu:\n", GC_OPT_FLAG_NONE );
+ es_printf ("disable-keypad:%lu:\n", GC_OPT_FLAG_NONE );
+ es_printf ("card-timeout:%lu:%d:\n", GC_OPT_FLAG_DEFAULT, 0);
scd_exit (0);
}
@@ -831,11 +831,11 @@
if (csh_style)
{
*strchr (infostr, '=') = ' ';
- printf ( "setenv %s\n", infostr);
+ es_printf ( "setenv %s\n", infostr);
}
else
{
- printf ( "%s; export SCDAEMON_INFO;\n", infostr);
+ es_printf ( "%s; export SCDAEMON_INFO;\n", infostr);
}
xfree (infostr);
exit (0);
Modified: trunk/sm/gpgsm.c
===================================================================
--- trunk/sm/gpgsm.c 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/sm/gpgsm.c 2010-08-18 19:25:15 UTC (rev 5397)
@@ -908,7 +908,7 @@
log_set_prefix ("gpgsm", 1);
/* Make sure that our subsystems are ready. */
- i18n_init();
+ i18n_init ();
init_common_subsystems (&argc, &argv);
/* Check that the libraries are suitable. Do it here because the
@@ -1429,9 +1429,9 @@
if (greeting)
{
- fprintf(stderr, "%s %s; %s\n",
- strusage(11), strusage(13), strusage(14) );
- fprintf(stderr, "%s\n", strusage(15) );
+ es_fprintf (es_stderr, "%s %s; %s\n",
+ strusage(11), strusage(13), strusage(14) );
+ es_fprintf (es_stderr, "%s\n", strusage(15) );
}
# ifdef IS_DEVELOPMENT_VERSION
if (!opt.batch)
@@ -1638,33 +1638,33 @@
{ /* List options and default values in the GPG Conf format. */
char *config_filename_esc = percent_escape (opt.config_filename, NULL);
- printf ("gpgconf-gpgsm.conf:%lu:\"%s\n",
- GC_OPT_FLAG_DEFAULT, config_filename_esc);
+ es_printf ("gpgconf-gpgsm.conf:%lu:\"%s\n",
+ GC_OPT_FLAG_DEFAULT, config_filename_esc);
xfree (config_filename_esc);
- printf ("verbose:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("debug-level:%lu:\"none:\n", GC_OPT_FLAG_DEFAULT);
- printf ("log-file:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("disable-crl-checks:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("disable-trusted-cert-crl-check:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("enable-ocsp:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("include-certs:%lu:%d:\n", GC_OPT_FLAG_DEFAULT,
- DEFAULT_INCLUDE_CERTS);
- printf ("disable-policy-checks:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("auto-issuer-key-retrieve:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("disable-dirmngr:%lu:\n", GC_OPT_FLAG_NONE);
- printf ("cipher-algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
- DEFAULT_CIPHER_ALGO);
- printf ("p12-charset:%lu:\n", GC_OPT_FLAG_DEFAULT);
- printf ("default-key:%lu:\n", GC_OPT_FLAG_DEFAULT);
- printf ("encrypt-to:%lu:\n", GC_OPT_FLAG_DEFAULT);
- printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("verbose:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("quiet:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("debug-level:%lu:\"none:\n", GC_OPT_FLAG_DEFAULT);
+ es_printf ("log-file:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("disable-crl-checks:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("disable-trusted-cert-crl-check:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("enable-ocsp:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("include-certs:%lu:%d:\n", GC_OPT_FLAG_DEFAULT,
+ DEFAULT_INCLUDE_CERTS);
+ es_printf ("disable-policy-checks:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("auto-issuer-key-retrieve:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("disable-dirmngr:%lu:\n", GC_OPT_FLAG_NONE);
+ es_printf ("cipher-algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
+ DEFAULT_CIPHER_ALGO);
+ es_printf ("p12-charset:%lu:\n", GC_OPT_FLAG_DEFAULT);
+ es_printf ("default-key:%lu:\n", GC_OPT_FLAG_DEFAULT);
+ es_printf ("encrypt-to:%lu:\n", GC_OPT_FLAG_DEFAULT);
+ es_printf ("keyserver:%lu:\n", GC_OPT_FLAG_NONE);
/* The next one is an info only item and should match what
proc_parameters actually implements. */
- printf ("default_pubkey_algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
- "RSA-2048");
+ es_printf ("default_pubkey_algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
+ "RSA-2048");
}
break;
Modified: trunk/tools/gpg-connect-agent.c
===================================================================
--- trunk/tools/gpg-connect-agent.c 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/tools/gpg-connect-agent.c 2010-08-18 19:25:15 UTC (rev 5397)
@@ -994,7 +994,9 @@
if (fd >= 0 && fd < DIM (open_fd_table))
{
open_fd_table[fd].inuse = 1;
-#warning fixme: implement our pipe emulation.
+#ifdef HAVE_W32CE_SYSTEM
+# warning fixme: implement our pipe emulation.
+#endif
#if defined(HAVE_W32_SYSTEM) && !defined(HAVE_W32CE_SYSTEM)
{
HANDLE prochandle, handle, newhandle;
@@ -1246,11 +1248,11 @@
if (opt.exec)
{
- int no_close[3];
+ assuan_fd_t no_close[3];
- no_close[0] = assuan_fd_from_posix_fd (fileno (stderr));
+ no_close[0] = assuan_fd_from_posix_fd (es_fileno (es_stderr));
no_close[1] = assuan_fd_from_posix_fd (log_get_fd ());
- no_close[2] = -1;
+ no_close[2] = ASSUAN_INVALID_FD;
rc = assuan_new (&ctx);
if (rc)
Modified: trunk/tools/gpgconf-comp.c
===================================================================
--- trunk/tools/gpgconf-comp.c 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/tools/gpgconf-comp.c 2010-08-18 19:25:15 UTC (rev 5397)
@@ -1284,7 +1284,7 @@
/* List all components that are available. */
void
-gc_component_list_components (FILE *out)
+gc_component_list_components (estream_t out)
{
gc_component_t component;
gc_option_t *option;
@@ -1320,9 +1320,9 @@
desc = gc_component[component].desc;
desc = my_dgettext (gc_component[component].desc_domain, desc);
- fprintf (out, "%s:%s:",
- gc_component[component].name, gc_percent_escape (desc));
- fprintf (out, "%s\n", gc_percent_escape (pgmname));
+ es_fprintf (out, "%s:%s:",
+ gc_component[component].name, gc_percent_escape (desc));
+ es_fprintf (out, "%s\n", gc_percent_escape (pgmname));
}
}
}
@@ -1432,7 +1432,7 @@
/* Check the options of a single component. Returns 0 if everything
is OK. */
int
-gc_component_check_options (int component, FILE *out, const char *conf_file)
+gc_component_check_options (int component, estream_t out, const char *conf_file)
{
gpg_error_t err;
unsigned int result;
@@ -1525,24 +1525,24 @@
desc = gc_component[component].desc;
desc = my_dgettext (gc_component[component].desc_domain, desc);
- fprintf (out, "%s:%s:",
- gc_component[component].name, gc_percent_escape (desc));
- fputs (gc_percent_escape (pgmname), out);
- fprintf (out, ":%d:%d:", !(result & 1), !(result & 2));
+ es_fprintf (out, "%s:%s:",
+ gc_component[component].name, gc_percent_escape (desc));
+ es_fputs (gc_percent_escape (pgmname), out);
+ es_fprintf (out, ":%d:%d:", !(result & 1), !(result & 2));
for (errptr = errlines; errptr; errptr = errptr->next)
{
if (errptr != errlines)
- fputs ("\n:::::", out); /* Continuation line. */
+ es_fputs ("\n:::::", out); /* Continuation line. */
if (errptr->fname)
- fputs (gc_percent_escape (errptr->fname), out);
- putc (':', out);
+ es_fputs (gc_percent_escape (errptr->fname), out);
+ es_putc (':', out);
if (errptr->fname)
- fprintf (out, "%u", errptr->lineno);
- putc (':', out);
- fputs (gc_percent_escape (errptr->errtext), out);
- putc (':', out);
+ es_fprintf (out, "%u", errptr->lineno);
+ es_putc (':', out);
+ es_fputs (gc_percent_escape (errptr->errtext), out);
+ es_putc (':', out);
}
- putc ('\n', out);
+ es_putc ('\n', out);
}
while (errlines)
@@ -1558,7 +1558,7 @@
/* Check all components that are available. */
void
-gc_check_programs (FILE *out)
+gc_check_programs (estream_t out)
{
gc_component_t component;
@@ -1587,7 +1587,7 @@
/* List the option OPTION. */
static void
-list_one_option (const gc_option_t *option, FILE *out)
+list_one_option (const gc_option_t *option, estream_t out)
{
const char *desc = NULL;
char *arg_name = NULL;
@@ -1617,16 +1617,16 @@
FIELDS. */
/* The name field. */
- fprintf (out, "%s", option->name);
+ es_fprintf (out, "%s", option->name);
/* The flags field. */
- fprintf (out, ":%lu", option->flags);
+ es_fprintf (out, ":%lu", option->flags);
if (opt.verbose)
{
- putc (' ', out);
+ es_putc (' ', out);
if (!option->flags)
- fprintf (out, "none");
+ es_fprintf (out, "none");
else
{
unsigned long flags = option->flags;
@@ -1640,8 +1640,8 @@
if (first)
first = 0;
else
- putc (',', out);
- fprintf (out, "%s", gc_flag[flag].name);
+ es_putc (',', out);
+ es_fprintf (out, "%s", gc_flag[flag].name);
}
flags >>= 1;
flag++;
@@ -1650,34 +1650,33 @@
}
/* The level field. */
- fprintf (out, ":%u", option->level);
+ es_fprintf (out, ":%u", option->level);
if (opt.verbose)
- fprintf (out, " %s", gc_level[option->level].name);
+ es_fprintf (out, " %s", gc_level[option->level].name);
/* The description field. */
- fprintf (out, ":%s", desc ? gc_percent_escape (desc) : "");
+ es_fprintf (out, ":%s", desc ? gc_percent_escape (desc) : "");
/* The type field. */
- fprintf (out, ":%u", option->arg_type);
+ es_fprintf (out, ":%u", option->arg_type);
if (opt.verbose)
- fprintf (out, " %s", gc_arg_type[option->arg_type].name);
+ es_fprintf (out, " %s", gc_arg_type[option->arg_type].name);
/* The alternate type field. */
- fprintf (out, ":%u", gc_arg_type[option->arg_type].fallback);
+ es_fprintf (out, ":%u", gc_arg_type[option->arg_type].fallback);
if (opt.verbose)
- fprintf (out, " %s",
- gc_arg_type[gc_arg_type[option->arg_type].fallback].name);
+ es_fprintf (out, " %s",
+ gc_arg_type[gc_arg_type[option->arg_type].fallback].name);
/* The argument name field. */
- fprintf (out, ":%s", arg_name ? gc_percent_escape (arg_name) : "");
- if (arg_name)
- xfree (arg_name);
+ es_fprintf (out, ":%s", arg_name ? gc_percent_escape (arg_name) : "");
+ xfree (arg_name);
/* The default value field. */
- fprintf (out, ":%s", option->default_value ? option->default_value : "");
+ es_fprintf (out, ":%s", option->default_value ? option->default_value : "");
/* The default argument field. */
- fprintf (out, ":%s", option->default_arg ? option->default_arg : "");
+ es_fprintf (out, ":%s", option->default_arg ? option->default_arg : "");
/* The value field. */
if (gc_arg_type[option->arg_type].fallback == GC_ARG_TYPE_NONE
@@ -1685,19 +1684,19 @@
&& option->value)
/* The special format "1,1,1,1,...,1" is converted to a number
here. */
- fprintf (out, ":%u", (unsigned int)((strlen (option->value) + 1) / 2));
+ es_fprintf (out, ":%u", (unsigned int)((strlen (option->value) + 1) / 2));
else
- fprintf (out, ":%s", option->value ? option->value : "");
+ es_fprintf (out, ":%s", option->value ? option->value : "");
/* ADD NEW FIELDS HERE. */
- putc ('\n', out);
+ es_putc ('\n', out);
}
/* List all options of the component COMPONENT. */
void
-gc_component_list_options (int component, FILE *out)
+gc_component_list_options (int component, estream_t out)
{
const gc_option_t *option = gc_component[component].options;
@@ -2980,7 +2979,7 @@
modifications are expected to already have been set to the global
table. */
void
-gc_component_change_options (int component, FILE *in, FILE *out)
+gc_component_change_options (int component, estream_t in, estream_t out)
{
int err = 0;
int runtime[GC_BACKEND_NR];
@@ -3004,7 +3003,7 @@
if (in)
{
/* Read options from the file IN. */
- while ((length = read_line (in, &line, &line_len, NULL)) > 0)
+ while ((length = es_read_line (in, &line, &line_len, NULL)) > 0)
{
char *linep;
unsigned long flags = 0;
@@ -3347,7 +3346,7 @@
returned on error. */
int
gc_process_gpgconf_conf (const char *fname_arg, int update, int defaults,
- FILE *listfp)
+ estream_t listfp)
{
int result = 0;
char *line = NULL;
@@ -3560,19 +3559,19 @@
*p = 0; /* We better strip any extra stuff. */
}
- fprintf (listfp, "k:%s:", gc_percent_escape (key));
- fprintf (listfp, "%s\n", group? gc_percent_escape (group):"");
+ es_fprintf (listfp, "k:%s:", gc_percent_escape (key));
+ es_fprintf (listfp, "%s\n", group? gc_percent_escape (group):"");
}
/* All other lines are rule records. */
- fprintf (listfp, "r:::%s:%s:%s:",
- gc_component[component_id].name,
- option_info->name? option_info->name : "",
- flags? flags : "");
+ es_fprintf (listfp, "r:::%s:%s:%s:",
+ gc_component[component_id].name,
+ option_info->name? option_info->name : "",
+ flags? flags : "");
if (value != empty)
- fprintf (listfp, "\"%s", gc_percent_escape (value));
+ es_fprintf (listfp, "\"%s", gc_percent_escape (value));
- putc ('\n', listfp);
+ es_putc ('\n', listfp);
}
/* Check whether the key matches but do this only if we are not
Modified: trunk/tools/gpgconf.c
===================================================================
--- trunk/tools/gpgconf.c 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/tools/gpgconf.c 2010-08-18 19:25:15 UTC (rev 5397)
@@ -118,19 +118,19 @@
/* Return the fp for the output. This is usually stdout unless
--output has been used. In the latter case this function opens
that file. */
-static FILE *
-get_outfp (FILE **fp)
+static estream_t
+get_outfp (estream_t *fp)
{
if (!*fp)
{
if (opt.outfile)
{
- *fp = fopen (opt.outfile, "w");
+ *fp = es_fopen (opt.outfile, "w");
if (!*fp)
gc_error (1, errno, "can not open `%s'", opt.outfile);
}
else
- *fp = stdout;
+ *fp = es_stdout;
}
return *fp;
}
@@ -144,7 +144,7 @@
const char *fname;
int no_more_options = 0;
enum cmd_and_opt_values cmd = 0;
- FILE *outfp = NULL;
+ estream_t outfp = NULL;
gnupg_reopen_std ("gpgconf");
set_strusage (my_strusage);
@@ -211,10 +211,10 @@
case aCheckOptions:
if (!fname)
{
- fputs (_("usage: gpgconf [options] "), stderr);
- putc ('\n',stderr);
- fputs (_("Need one component argument"), stderr);
- putc ('\n',stderr);
+ es_fputs (_("usage: gpgconf [options] "), es_stderr);
+ es_putc ('\n', es_stderr);
+ es_fputs (_("Need one component argument"), es_stderr);
+ es_putc ('\n', es_stderr);
exit (2);
}
else
@@ -222,8 +222,8 @@
int idx = gc_component_find (fname);
if (idx < 0)
{
- fputs (_("Component not found"), stderr);
- putc ('\n', stderr);
+ es_fputs (_("Component not found"), es_stderr);
+ es_putc ('\n', es_stderr);
exit (1);
}
gc_component_retrieve_options (idx);
@@ -232,7 +232,7 @@
if (cmd == aListOptions)
gc_component_list_options (idx, get_outfp (&outfp));
else if (cmd == aChangeOptions)
- gc_component_change_options (idx, stdin, get_outfp (&outfp));
+ gc_component_change_options (idx, es_stdin, get_outfp (&outfp));
else
gc_component_check_options (idx, get_outfp (&outfp), NULL);
}
@@ -252,8 +252,8 @@
idx = gc_component_find (fname);
if (idx < 0)
{
- fputs (_("Component not found"), stderr);
- putc ('\n', stderr);
+ es_fputs (_("Component not found"), es_stderr);
+ es_putc ('\n', es_stderr);
exit (1);
}
else
@@ -276,10 +276,10 @@
case aApplyDefaults:
if (fname)
{
- fputs (_("usage: gpgconf [options] "), stderr);
- putc ('\n',stderr);
- fputs (_("No argument allowed"), stderr);
- putc ('\n',stderr);
+ es_fputs (_("usage: gpgconf [options] "), es_stderr);
+ es_putc ('\n', es_stderr);
+ es_fputs (_("No argument allowed"), es_stderr);
+ es_putc ('\n', es_stderr);
exit (2);
}
gc_component_retrieve_options (-1);
@@ -290,20 +290,20 @@
case aListDirs:
/* Show the system configuration directories for gpgconf. */
get_outfp (&outfp);
- fprintf (outfp, "sysconfdir:%s\n",
- gc_percent_escape (gnupg_sysconfdir ()));
- fprintf (outfp, "bindir:%s\n",
- gc_percent_escape (gnupg_bindir ()));
- fprintf (outfp, "libexecdir:%s\n",
- gc_percent_escape (gnupg_libexecdir ()));
- fprintf (outfp, "libdir:%s\n",
- gc_percent_escape (gnupg_libdir ()));
- fprintf (outfp, "datadir:%s\n",
- gc_percent_escape (gnupg_datadir ()));
- fprintf (outfp, "localedir:%s\n",
- gc_percent_escape (gnupg_localedir ()));
- fprintf (outfp, "dirmngr-socket:%s\n",
- gc_percent_escape (dirmngr_socket_name ()));
+ es_fprintf (outfp, "sysconfdir:%s\n",
+ gc_percent_escape (gnupg_sysconfdir ()));
+ es_fprintf (outfp, "bindir:%s\n",
+ gc_percent_escape (gnupg_bindir ()));
+ es_fprintf (outfp, "libexecdir:%s\n",
+ gc_percent_escape (gnupg_libexecdir ()));
+ es_fprintf (outfp, "libdir:%s\n",
+ gc_percent_escape (gnupg_libdir ()));
+ es_fprintf (outfp, "datadir:%s\n",
+ gc_percent_escape (gnupg_datadir ()));
+ es_fprintf (outfp, "localedir:%s\n",
+ gc_percent_escape (gnupg_localedir ()));
+ es_fprintf (outfp, "dirmngr-socket:%s\n",
+ gc_percent_escape (dirmngr_socket_name ()));
{
char *infostr = getenv ("GPG_AGENT_INFO");
@@ -323,21 +323,21 @@
else
*tmp = 0;
}
- fprintf (outfp, "agent-socket:%s\n",
- infostr? gc_percent_escape (infostr) : "");
+ es_fprintf (outfp, "agent-socket:%s\n",
+ infostr? gc_percent_escape (infostr) : "");
xfree (infostr);
}
{
/* We need to use make_filename to expand a possible "~/". */
char *tmp = make_filename (default_homedir (), NULL);
- fprintf (outfp, "homedir:%s\n", gc_percent_escape (tmp));
+ es_fprintf (outfp, "homedir:%s\n", gc_percent_escape (tmp));
xfree (tmp);
}
break;
}
- if (outfp && outfp != stdout)
- if (fclose (outfp))
+ if (outfp != es_stdout)
+ if (es_fclose (outfp))
gc_error (1, errno, "error closing `%s'", opt.outfile);
return 0;
Modified: trunk/tools/gpgconf.h
===================================================================
--- trunk/tools/gpgconf.h 2010-08-16 11:03:43 UTC (rev 5396)
+++ trunk/tools/gpgconf.h 2010-08-18 19:25:15 UTC (rev 5397)
@@ -48,10 +48,10 @@
void gc_component_reload (int component);
/* List all components that are available. */
-void gc_component_list_components (FILE *out);
+void gc_component_list_components (estream_t out);
/* List all programs along with their status. */
-void gc_check_programs (FILE *out);
+void gc_check_programs (estream_t out);
/* Find the component with the name NAME. Returns -1 if not
found. */
@@ -62,19 +62,19 @@
void gc_component_retrieve_options (int component);
/* List all options of the component COMPONENT. */
-void gc_component_list_options (int component, FILE *out);
+void gc_component_list_options (int component, estream_t out);
/* Read the modifications from IN and apply them. */
-void gc_component_change_options (int component, FILE *in, FILE *out);
+void gc_component_change_options (int component, estream_t in, estream_t out);
/* Check the options of a single component. Returns 0 if everything
is OK. */
-int gc_component_check_options (int component, FILE *out,
+int gc_component_check_options (int component, estream_t out,
const char *conf_file);
/* Process global configuration file. */
int gc_process_gpgconf_conf (const char *fname, int update, int defaults,
- FILE *listfp);
+ estream_t listfp);
#endif /*GPGCONF_H*/
More information about the Gnupg-commits
mailing list