| 81 |
{ |
{ |
| 82 |
lml_tag_quote_level++; |
lml_tag_quote_level++; |
| 83 |
} |
} |
| 84 |
return snprintf(tag_output_buf, tag_output_buf_len, lml_tag_quote_color[lml_tag_quote_level % LML_TAG_QUOTE_LEVEL_LOOP]); |
return snprintf(tag_output_buf, tag_output_buf_len, "%s", |
| 85 |
|
lml_tag_quote_color[lml_tag_quote_level % LML_TAG_QUOTE_LEVEL_LOOP]); |
| 86 |
} |
} |
| 87 |
else if (strcasecmp(tag_name, "/quote") == 0) |
else if (strcasecmp(tag_name, "/quote") == 0) |
| 88 |
{ |
{ |
| 90 |
{ |
{ |
| 91 |
lml_tag_quote_level--; |
lml_tag_quote_level--; |
| 92 |
} |
} |
| 93 |
return snprintf(tag_output_buf, tag_output_buf_len, |
return snprintf(tag_output_buf, tag_output_buf_len, "%s", |
| 94 |
(lml_tag_quote_level > 0 ? lml_tag_quote_color[lml_tag_quote_level % LML_TAG_QUOTE_LEVEL_LOOP] : "\033[m")); |
(lml_tag_quote_level > 0 ? lml_tag_quote_color[lml_tag_quote_level % LML_TAG_QUOTE_LEVEL_LOOP] : "\033[m")); |
| 95 |
} |
} |
| 96 |
|
|
| 117 |
{"quote", NULL, (const char *)lml_tag_quote_filter}, |
{"quote", NULL, (const char *)lml_tag_quote_filter}, |
| 118 |
{"/quote", NULL, (const char *)lml_tag_quote_filter}, |
{"/quote", NULL, (const char *)lml_tag_quote_filter}, |
| 119 |
{"url", "", ""}, |
{"url", "", ""}, |
| 120 |
{"/url", "(链接: %s)", NULL}, |
{"/url", "(閾炬帴: %s)", NULL}, |
| 121 |
{"link", "", ""}, |
{"link", "", ""}, |
| 122 |
{"/link", "(链接: %s)", NULL}, |
{"/link", "(閾炬帴: %s)", NULL}, |
| 123 |
{"email", "", ""}, |
{"email", "", ""}, |
| 124 |
{"/email", "(Email: %s)", NULL}, |
{"/email", "(Email: %s)", NULL}, |
| 125 |
{"user", "", ""}, |
{"user", "", ""}, |
| 126 |
{"/user", "(用户: %s)", NULL}, |
{"/user", "(鐢ㄦ埛: %s)", NULL}, |
| 127 |
{"article", "", ""}, |
{"article", "", ""}, |
| 128 |
{"/article", "(文章: %s)", NULL}, |
{"/article", "(鏂囩珷: %s)", NULL}, |
| 129 |
{"image", "(图片: %s)", ""}, |
{"image", "(鍥剧墖: %s)", ""}, |
| 130 |
{"flash", "(Flash: %s)", ""}, |
{"flash", "(Flash: %s)", ""}, |
| 131 |
{"bwf", "\033[1;31m****\033[m", ""}, |
{"bwf", "\033[1;31m****\033[m", ""}, |
| 132 |
}; |
}; |
| 153 |
|
|
| 154 |
int lml_plain(const char *str_in, char *str_out, int buf_len) |
int lml_plain(const char *str_in, char *str_out, int buf_len) |
| 155 |
{ |
{ |
| 156 |
|
char c; |
| 157 |
char tag_param_buf[LML_TAG_PARAM_BUF_LEN]; |
char tag_param_buf[LML_TAG_PARAM_BUF_LEN]; |
| 158 |
char tag_output_buf[LML_TAG_OUTPUT_BUF_LEN]; |
char tag_output_buf[LML_TAG_OUTPUT_BUF_LEN]; |
| 159 |
int i; |
int i; |
| 178 |
{ |
{ |
| 179 |
lml_tag_quote_level -= fb_quote_level; |
lml_tag_quote_level -= fb_quote_level; |
| 180 |
|
|
| 181 |
tag_output_len = snprintf(tag_output_buf, LML_TAG_OUTPUT_BUF_LEN, |
tag_output_len = snprintf(tag_output_buf, LML_TAG_OUTPUT_BUF_LEN, "%s", |
| 182 |
(lml_tag_quote_level > 0 ? lml_tag_quote_color[lml_tag_quote_level % LML_TAG_QUOTE_LEVEL_LOOP] : "\033[m")); |
(lml_tag_quote_level > 0 ? lml_tag_quote_color[lml_tag_quote_level % LML_TAG_QUOTE_LEVEL_LOOP] : "\033[m")); |
| 183 |
if (j + tag_output_len >= buf_len) |
if (j + tag_output_len >= buf_len) |
| 184 |
{ |
{ |
| 201 |
{ |
{ |
| 202 |
lml_tag_quote_level += fb_quote_level; |
lml_tag_quote_level += fb_quote_level; |
| 203 |
|
|
| 204 |
tag_output_len = snprintf(tag_output_buf, LML_TAG_OUTPUT_BUF_LEN, |
tag_output_len = snprintf(tag_output_buf, LML_TAG_OUTPUT_BUF_LEN, "%s", |
| 205 |
lml_tag_quote_color[(lml_tag_quote_level) % LML_TAG_QUOTE_LEVEL_LOOP]); |
lml_tag_quote_color[(lml_tag_quote_level) % LML_TAG_QUOTE_LEVEL_LOOP]); |
| 206 |
if (j + tag_output_len >= buf_len) |
if (j + tag_output_len >= buf_len) |
| 207 |
{ |
{ |
| 317 |
} |
} |
| 318 |
else if (tag_start_pos == -1) // not in LML tag |
else if (tag_start_pos == -1) // not in LML tag |
| 319 |
{ |
{ |
| 320 |
if (str_in[i] < 0 || str_in[i] > 127) // GBK chinese character |
if (str_in[i] & 0b10000000) // head of multi-byte character |
| 321 |
{ |
{ |
| 322 |
if (j + 2 >= buf_len) |
if (j + 4 >= buf_len) // Assuming UTF-8 CJK characters use 4 bytes, though most of them actually use 3 bytes |
| 323 |
{ |
{ |
| 324 |
log_error("Buffer is not longer enough for output string %ld >= %d\n", j + 2, buf_len); |
log_error("Buffer is not longer enough for output string %ld >= %d\n", j + 4, buf_len); |
| 325 |
str_out[j] = '\0'; |
str_out[j] = '\0'; |
| 326 |
return j; |
return j; |
| 327 |
} |
} |
| 328 |
str_out[j++] = str_in[i++]; |
|
| 329 |
if (str_in[i] == '\0') |
c = (str_in[i] & 0b01110000) << 1; |
| 330 |
|
while (c & 0b10000000) |
| 331 |
{ |
{ |
| 332 |
str_out[j] = '\0'; |
str_out[j++] = str_in[i++]; |
| 333 |
return j; |
if (str_in[i] == '\0') |
| 334 |
|
{ |
| 335 |
|
str_out[j] = '\0'; |
| 336 |
|
return j; |
| 337 |
|
} |
| 338 |
|
c = (c & 0b01111111) << 1; |
| 339 |
} |
} |
| 340 |
} |
} |
| 341 |
|
|