mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
* 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.
This commit is contained in:
parent
c3885e0995
commit
416c0b7ea2
9 changed files with 547 additions and 223 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue