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
c8397a83
Commit
c8397a83
authored
Mar 14, 2000
by
Niels Möller
Browse files
* src/format.c (make_cstring_l): New function.
Rev: src/format.c:1.35 Rev: src/format.h:1.28
parent
14ff85c3
Changes
2
Show whitespace changes
Inline
Side-by-side
src/format.c
View file @
c8397a83
...
...
@@ -603,7 +603,8 @@ static int write_decimal_length(UINT8 *buffer, UINT32 n)
* (not included in the length), to make it possible to pass the
* string directly to C library functions. */
struct
lsh_string
*
format_cstring
(
const
char
*
s
)
struct
lsh_string
*
format_cstring
(
const
char
*
s
)
{
if
(
s
)
{
...
...
@@ -614,22 +615,28 @@ struct lsh_string *format_cstring(const char *s)
return
NULL
;
}
struct
lsh_string
*
make_cstring
(
struct
lsh_string
*
s
,
int
free
)
struct
lsh_string
*
make_cstring_l
(
UINT32
length
,
UINT8
*
data
)
{
struct
lsh_string
*
res
;
if
(
memchr
(
s
->
data
,
'\0'
,
s
->
length
))
{
if
(
free
)
lsh_string_free
(
s
);
return
0
;
}
if
(
memchr
(
data
,
'\0'
,
length
))
return
NULL
;
res
=
ssh_format
(
"%l
S
%c"
,
s
,
0
);
res
=
ssh_format
(
"%l
s
%c"
,
length
,
data
,
0
);
res
->
length
--
;
return
res
;
}
struct
lsh_string
*
make_cstring
(
struct
lsh_string
*
s
,
int
free
)
{
struct
lsh_string
*
res
=
make_cstring_l
(
s
->
length
,
s
->
data
);
if
(
free
)
lsh_string_free
(
s
);
return
res
;
}
...
...
src/format.h
View file @
c8397a83
...
...
@@ -87,8 +87,14 @@ void ssh_vformat_write(const char *format, UINT32 length, UINT8 *buffer, va_list
/* Short cut */
#define lsh_string_dup(s) (ssh_format("%lS", (s)))
struct
lsh_string
*
format_cstring
(
const
char
*
s
);
struct
lsh_string
*
make_cstring
(
struct
lsh_string
*
s
,
int
free
);
struct
lsh_string
*
format_cstring
(
const
char
*
s
);
struct
lsh_string
*
make_cstring_l
(
UINT32
length
,
UINT8
*
data
);
struct
lsh_string
*
make_cstring
(
struct
lsh_string
*
s
,
int
free
);
unsigned
format_size_in_decimal
(
UINT32
n
);
void
format_decimal
(
unsigned
length
,
UINT8
*
buffer
,
UINT32
n
);
...
...
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