(no subject)

Werner Koch wk@gnupg.org
Fri, 29 Aug 2003 10:47:14 +0200

On Thu, 28 Aug 2003 11:08:07 -0400,   said:

> Is there a way to put a wrapper on the file, or is there some sort of "ascii-armoring" or similar file I/O-safe format I can write these files in to fix this problem?  Thanks for any ideas.

Yes, you should use the advanced format if you have problems with
binary files (did you remember to use the "b" modifier to fopen?).

static char *
make_advanced (gcry_sexp_t sexp)
  int rc;
  size_t len;
  unsigned char *result;

  len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, NULL, 0);
  assert (len);
  result = xmalloc (len);
  len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, result, len);
  assert (len);
  gcry_sexp_release (sexp);
  return result;

This returns a C String suitable for printing.  gcry_sexp_sscan()
automatically detects the S-expression format, so there is nothing
special you need to do when reading the file back.

Beware, 1.1.12 won't be maintained anymore - we changed the API with
1.1.42 and is is suggested to use this new version.



Werner Koch                                      <wk@gnupg.org>
The GnuPG Experts                                http://g10code.com
Free Software Foundation Europe	                 http://fsfeurope.org