diff options
author | Tatsuya Kinoshita <tats@vega.ocn.ne.jp> | 2011-05-04 07:18:09 +0000 |
---|---|---|
committer | Tatsuya Kinoshita <tats@vega.ocn.ne.jp> | 2011-05-04 07:18:09 +0000 |
commit | 5f8e0f8ef9a422691dd72e8a953a42a41478fcb4 (patch) | |
tree | 4b2df4796a534793648b3c4fc532fc36bd0cd525 /libwc/putc.c | |
parent | Releasing debian version 0.3-2.4 (diff) | |
download | w3m-debian/0.5.1-1.tar.gz w3m-debian/0.5.1-1.zip |
Releasing debian version 0.5.1-1debian/0.5.1-1
Diffstat (limited to '')
-rw-r--r-- | libwc/putc.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/libwc/putc.c b/libwc/putc.c new file mode 100644 index 0000000..4df2448 --- /dev/null +++ b/libwc/putc.c @@ -0,0 +1,56 @@ + +#include "wc.h" +#include "wtf.h" + +static wc_status putc_st; +static wc_ces putc_f_ces, putc_t_ces; +static Str putc_str; + +void +wc_putc_init(wc_ces f_ces, wc_ces t_ces) +{ + wc_output_init(t_ces, &putc_st); + putc_str = Strnew_size(8); + putc_f_ces = f_ces; + putc_t_ces = t_ces; +} + +void +wc_putc(char *c, FILE *f) +{ + wc_uchar *p; + + if (putc_f_ces != WC_CES_WTF) + p = (wc_uchar *)wc_conv(c, putc_f_ces, WC_CES_WTF)->ptr; + else + p = (wc_uchar *)c; + + Strclear(putc_str); + while (*p) + (*putc_st.ces_info->push_to)(putc_str, wtf_parse(&p), &putc_st); + fwrite(putc_str->ptr, 1, putc_str->length, f); +} + +void +wc_putc_end(FILE *f) +{ + Strclear(putc_str); + wc_push_end(putc_str, &putc_st); + if (putc_str->length) + fwrite(putc_str->ptr, 1, putc_str->length, f); +} + +void +wc_putc_clear_status(void) +{ + if (putc_st.ces_info->id & WC_CES_T_ISO_2022) { + putc_st.gl = 0; + putc_st.gr = 0; + putc_st.ss = 0; + putc_st.design[0] = 0; + putc_st.design[1] = 0; + putc_st.design[2] = 0; + putc_st.design[3] = 0; + } +} + |