Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
LSH
lsh
Commits
85ccf21a
Commit
85ccf21a
authored
Sep 03, 1998
by
Niels Möller
Browse files
Added %z specifier.
Rev: src/format.c:1.6 Rev: src/format.h:1.6
parent
49d7f3d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/format.c
View file @
85ccf21a
...
...
@@ -2,23 +2,24 @@
*
*/
#include
"format.h"
#include
"werror.h"
#include
<assert.h>
#include
<string.h>
struct
simple_packet
*
ssh_format
(
char
*
format
,
...)
#include
"format.h"
#include
"werror.h"
#include
"xalloc.h"
struct
lsh_string
*
ssh_format
(
char
*
format
,
...)
{
va_list
args
;
UINT32
length
;
struct
simple_packet
*
packet
;
struct
lsh_string
*
packet
;
va_start
(
args
,
format
);
length
=
ssh_vformat_length
(
format
,
args
);
va_end
(
args
);
packet
=
simple_packet
_alloc
(
length
);
packet
=
lsh_string
_alloc
(
length
);
va_start
(
args
,
format
);
ssh_vformat
(
format
,
packet
->
data
,
args
);
...
...
@@ -82,6 +83,13 @@ UINT32 ssh_vformat_length(char *f, va_list args)
length
+=
4
;
break
;
case
'z'
:
length
+=
strlen
(
va_arg
(
args
,
char
*
));
f
++
;
if
(
!
literal
)
length
+=
4
;
break
;
case
'r'
:
length
+=
va_arg
(
args
,
struct
lsh_string
*
)
->
length
;
(
void
)
va_arg
(
args
,
UINT8
**
);
/* pointer */
...
...
@@ -208,6 +216,21 @@ void ssh_vformat(char *f, UINT8 *buffer, va_list args)
buffer
+=
s
->
length
;
f
++
;
}
case
'z'
:
{
char
*
s
=
va_arg
(
args
,
char
*
);
UINT32
length
=
strlen
(
s
);
if
(
!
literal
)
{
WRITE_UINT32
(
buffer
,
length
);
buffer
+=
4
;
}
memcpy
(
buffer
,
s
,
length
);
buffer
+=
length
;
f
++
;
break
;
}
case
'r'
:
{
UINT32
length
=
va_arg
(
args
,
UINT32
);
...
...
src/format.h
View file @
85ccf21a
...
...
@@ -24,6 +24,11 @@
*
* %S Insert a string, given as a struct lsh_string pointer.
*
* %z Insert a string, using a null-terminated argument.
*
* %r Reserves space in the string, and stores a pointer to this space
* into the given UINT8 ** argument.
*
* %a Insert a string containing one atom.
*
* %A Insert a string containing a list of atoms. The corresponding
...
...
@@ -31,9 +36,6 @@
*
* %n Insert a string containing a bignum.
*
* %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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment