summaryrefslogtreecommitdiff
path: root/src/sexp.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2003-11-11 12:57:36 +0000
committerWerner Koch <wk@gnupg.org>2003-11-11 12:57:36 +0000
commitf6f2462012cf4e979487bb2ccce8a7f1ba96d3a7 (patch)
tree6f61d5a92e7f131707667ea58562c63358aea3da /src/sexp.c
parentae971910cc6cbb7617c6b0e8048f942b96669345 (diff)
downloadlibgcrypt-f6f2462012cf4e979487bb2ccce8a7f1ba96d3a7.tar.gz
* Manifest: New.
* gcrypt.texi (Working with S-expressions): Added "%b". * sexp.c (sexp_sscan): Implemented "%b" format specifier. * tsexp.c (basic): Add pass structure and a test for the %b format.
Diffstat (limited to 'src/sexp.c')
-rw-r--r--src/sexp.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/sexp.c b/src/sexp.c
index bde7dc56..e271414b 100644
--- a/src/sexp.c
+++ b/src/sexp.c
@@ -823,10 +823,12 @@ unquote_string (const unsigned char *string, size_t length, unsigned char *buf)
* %m - MPI
* %s - string (no autoswitch to secure allocation)
* %d - integer stored as string (no autoswitch to secure allocation)
+ * %b - memory buffer; this takes _two_ arguments: an integer with the
+ * length of the buffer and a pointer to the buffer.
* all other format elements are currently not defined and return an error.
* this includes the "%%" sequence becauce the percent sign is not an
* allowed character.
- * FIXME: We should find a way to store the secure-MPIS not in the string
+ * FIXME: We should find a way to store the secure-MPIs not in the string
* but as reference to somewhere - this can help us to save huge amounts
* of secure memory. The problem is, that if only one element is secure, all
* other elements are automagicaly copied to secure meory too, so the most
@@ -867,7 +869,7 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ\
/* Depending on wether ARG_LIST is non-zero or not, this macro gives
us the next argument, either from the variable argument list as
- specified by ARG_PTR or from the arugment array ARG_LIST. */
+ specified by ARG_PTR or from the argument array ARG_LIST. */
#define ARG_NEXT(storage, type) \
do \
{ \
@@ -1129,6 +1131,21 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ\
memcpy (c.pos, astr, alen);
c.pos += alen;
}
+ else if (*p == 'b')
+ {
+ /* Insert a memory buffer. */
+ const char *astr;
+ int alen;
+
+ ARG_NEXT (alen, int);
+ ARG_NEXT (astr, const char *);
+
+ MAKE_SPACE (alen);
+ *c.pos++ = ST_DATA;
+ STORE_LEN (c.pos, alen);
+ memcpy (c.pos, astr, alen);
+ c.pos += alen;
+ }
else if (*p == 'd')
{
/* Insert an integer as string. */