Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
LSH
lsh
Commits
7747254c
Commit
7747254c
authored
Nov 15, 1998
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved functions format_cstring and make_cstring here.
Rev: src/format.c:1.19 Rev: src/format.h:1.14
parent
7cd1a123
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
src/format.c
src/format.c
+34
-0
src/format.h
src/format.h
+3
-0
No files found.
src/format.c
View file @
7747254c
...
...
@@ -416,3 +416,37 @@ void ssh_vformat_write(char *f, UINT32 size, UINT8 *buffer, va_list args)
assert
(
buffer
==
start
+
size
);
}
/* These functions add an extra NUL-character at the end of the string
* (not included in the length), to make it possible to pass the
* string directly to C library functions. */
struct
lsh_string
*
format_cstring
(
char
*
s
)
{
if
(
s
)
{
struct
lsh_string
*
res
=
ssh_format
(
"%lz%c"
,
s
,
0
);
res
->
length
--
;
return
res
;
}
return
NULL
;
}
struct
lsh_string
*
make_cstring
(
struct
lsh_string
*
s
,
int
free
)
{
struct
lsh_string
*
res
;
if
(
memchr
(
s
->
data
,
'\0'
,
s
->
length
))
{
if
(
free
)
lsh_string_free
(
s
);
return
0
;
}
res
=
ssh_format
(
"%lS%c"
,
s
,
0
);
res
->
length
--
;
if
(
free
)
lsh_string_free
(
s
);
return
res
;
}
src/format.h
View file @
7747254c
...
...
@@ -77,4 +77,7 @@ void ssh_vformat_write(char *format, UINT32 length, UINT8 *buffer, va_list args)
/* Short cut */
#define lsh_string_dup(s) (ssh_format("%lS", (s)))
struct
lsh_string
*
format_cstring
(
char
*
s
);
struct
lsh_string
*
make_cstring
(
struct
lsh_string
*
s
,
int
free
);
#endif
/* LSH_FORMAT_H_INCLUDED */
Write
Preview
Markdown
is supported
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