diff options
author | Werner Koch <[email protected]> | 2002-01-21 12:03:14 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2002-01-21 12:03:14 +0000 |
commit | 416c0b7ea21b1c8703301a18f85fb7a25f6790ab (patch) | |
tree | 4801f2c82745dd80066a6f70968c791d87f49157 /assuan/assuan-util.c | |
parent | * server.c (option_handler): New. (diff) | |
download | gnupg-416c0b7ea21b1c8703301a18f85fb7a25f6790ab.tar.gz gnupg-416c0b7ea21b1c8703301a18f85fb7a25f6790ab.zip |
* assuan-connect.c: Move all except assuan_get_pid to...
* assuan-pipe-connect.c: this.
(assuan_pipe_disconnect): Removed.
(do_finish, do_deinit): New
(assuan_pipe_connect): and set them into the context.
* assuan-socket-connect.c: New.
* assuan-util.c (_assuan_log_sanitized_string): New.
* assuan-pipe-server.c (assuan_init_pipe_server): Factored most
code out to ...
(_assuan_new_context): new func.
(_assuan_release_context): New
* assuan-connect.c (assuan_pipe_connect): Use the new functions.
Diffstat (limited to 'assuan/assuan-util.c')
-rw-r--r-- | assuan/assuan-util.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/assuan/assuan-util.c b/assuan/assuan-util.c index 96cd68d4e..4153ef8db 100644 --- a/assuan/assuan-util.c +++ b/assuan/assuan-util.c @@ -25,6 +25,10 @@ #include "assuan-defs.h" +#ifdef HAVE_JNLIB_LOGGING +#include "../jnlib/logging.h" +#endif + static void *(*alloc_func)(size_t n) = malloc; static void *(*realloc_func)(void *p, size_t n) = realloc; @@ -150,3 +154,43 @@ _assuan_log_print_buffer (FILE *fp, const void *buffer, size_t length) putc (']', fp); } } + + +/* print a user supplied string after filtering out potential bad + characters*/ +void +_assuan_log_sanitized_string (const char *string) +{ + const unsigned char *s = string; +#ifdef HAVE_JNLIB_LOGGING + FILE *fp = log_get_stream (); +#else + FILE *fp = stderr; +#endif + + for (; *s; s++) + { + if (*s < 0x20 || (*s >= 0x7f && *s <= 0xa0)) + { + putc ('\\', fp); + if (*s == '\n') + putc ('n', fp); + else if (*s == '\r') + putc ('r', fp); + else if (*s == '\f') + putc ('f', fp); + else if (*s == '\v') + putc ('v', fp); + else if (*s == '\b') + putc ('b', fp); + else if (!*s) + putc ('0', fp); + else + fprintf (fp, "x%02x", *s ); + } + else + putc (*s, fp); + } +} + + |