Commit e3277770 authored by Niels Möller's avatar Niels Möller
Browse files

New %r specifier.

Rev: src/format.c:1.5
Rev: src/format.h:1.5
parent e74f7fd8
......@@ -82,6 +82,15 @@ UINT32 ssh_vformat_length(char *f, va_list args)
length += 4;
break;
case 'r':
length += va_arg(args, struct lsh_string *)->length;
(void) va_arg(args, UINT8 **); /* pointer */
f++;
if (!literal)
length += 4;
break;
case 'a':
{
int atom = va_arg(args, int);
......@@ -199,7 +208,23 @@ void ssh_vformat(char *f, UINT8 *buffer, va_list args)
buffer += s->length;
f++;
}
case 'r':
{
UINT32 length = va_arg(args, UINT32);
UINT8 **p = va_arg(args, UINT8 **);
if (!literal)
{
WRITE_UINT32(buffer, length);
buffer += 4;
}
if (p)
*p = buffer;
buffer += length;
f++;
}
case 'a':
{
UINT32 length;
......
......@@ -31,10 +31,13 @@
*
* %n Insert a string containing a bignum.
*
* There is one valid modifier, "l" (as in literal). It is applicable
* to the s, a, A and n specifiers, and outputs strings *without* a
* length field.
*/
* %r Reserves space in the string, and stores a pointer to this space
* into the given UINT8 ** argument.
*
* There is one valid modifier:
*
* "l" (as in literal). It is applicable to the s, a, A, n and r
* specifiers, and outputs strings *without* a length field. */
UINT32 ssh_vformat_length(char *format, va_list args);
void ssh_vformat(char *format, UINT8 *buffer, va_list args);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment