зеркало из https://github.com/github/putty.git
StripCtrlChars: retarget and reset functions.
stripctrl_retarget() points the StripCtrlChars at a new BinarySink, to avoid having to pointlessly throw it away and make a new one all the time. Since that probably means the same scc is going to be reused for processing a fresh data stream, we also don't want any character-set conversion state hanging over from the previous stream, so we also reset the state in the process. Just in case it's needed, stripctrl_reset() is also provided to do that operation on its own.
This commit is contained in:
Родитель
d62a369af8
Коммит
cfef137ea2
2
misc.h
2
misc.h
|
@ -384,6 +384,8 @@ StripCtrlChars *stripctrl_new_term_fn(
|
|||
Terminal *, term_utf8_decode *, unsigned char));
|
||||
#define stripctrl_new_term(bs, cr, sub, term) \
|
||||
stripctrl_new_term_fn(bs, cr, sub, term, term_translate)
|
||||
void stripctrl_retarget(StripCtrlChars *sccpub, BinarySink *new_bs_out);
|
||||
void stripctrl_reset(StripCtrlChars *sccpub);
|
||||
void stripctrl_free(StripCtrlChars *sanpub);
|
||||
char *stripctrl_string_ptrlen(ptrlen str);
|
||||
static inline char *stripctrl_string(const char *str)
|
||||
|
|
24
stripctrl.c
24
stripctrl.c
|
@ -76,6 +76,30 @@ StripCtrlChars *stripctrl_new_term_fn(
|
|||
return &scc->public;
|
||||
}
|
||||
|
||||
void stripctrl_retarget(StripCtrlChars *sccpub, BinarySink *new_bs_out)
|
||||
{
|
||||
StripCtrlCharsImpl *scc =
|
||||
container_of(sccpub, StripCtrlCharsImpl, public);
|
||||
scc->bs_out = new_bs_out;
|
||||
stripctrl_reset(sccpub);
|
||||
}
|
||||
|
||||
void stripctrl_reset(StripCtrlChars *sccpub)
|
||||
{
|
||||
StripCtrlCharsImpl *scc =
|
||||
container_of(sccpub, StripCtrlCharsImpl, public);
|
||||
|
||||
/*
|
||||
* Clear all the fields that might have been in the middle of a
|
||||
* multibyte character or non-default shift state, so that we can
|
||||
* start converting a fresh piece of data to send to a channel
|
||||
* that hasn't seen the previous output.
|
||||
*/
|
||||
memset(&scc->term_utf8_decode, 0, sizeof(scc->term_utf8_decode));
|
||||
memset(&scc->mbs_in, 0, sizeof(scc->mbs_in));
|
||||
memset(&scc->mbs_out, 0, sizeof(scc->mbs_out));
|
||||
}
|
||||
|
||||
void stripctrl_free(StripCtrlChars *sccpub)
|
||||
{
|
||||
StripCtrlCharsImpl *scc =
|
||||
|
|
Загрузка…
Ссылка в новой задаче