| 21 |
#include <string.h> |
#include <string.h> |
| 22 |
#include <stdlib.h> |
#include <stdlib.h> |
| 23 |
#include <unistd.h> |
#include <unistd.h> |
| 24 |
|
#include <wchar.h> |
| 25 |
#include <sys/param.h> |
#include <sys/param.h> |
| 26 |
#include <sys/stat.h> |
#include <sys/stat.h> |
| 27 |
#include <sys/shm.h> |
#include <sys/shm.h> |
| 136 |
int offset = 0; |
int offset = 0; |
| 137 |
int eol; |
int eol; |
| 138 |
int display_len; |
int display_len; |
| 139 |
char input_str[4]; |
char input_str[5]; |
| 140 |
int str_len = 0; |
int str_len = 0; |
| 141 |
|
wchar_t wcs[2]; |
| 142 |
char c; |
char c; |
| 143 |
|
|
| 144 |
buffer[buf_size - 1] = '\0'; |
buffer[buf_size - 1] = '\0'; |
| 213 |
break; |
break; |
| 214 |
} |
} |
| 215 |
} |
} |
| 216 |
|
input_str[str_len] = '\0'; |
| 217 |
|
|
| 218 |
if (str_len == 0) // Incomplete input |
if (str_len == 0) // Incomplete input |
| 219 |
{ |
{ |
| 220 |
continue; |
continue; |
| 221 |
} |
} |
| 222 |
|
|
| 223 |
if (offset + str_len > buf_size - 1 || display_len + 2 > max_display_len) // No enough space for Chinese character |
if (mbstowcs(wcs, input_str, 1) == (size_t)-1) |
| 224 |
|
{ |
| 225 |
|
log_error("mbstowcs() error\n"); |
| 226 |
|
} |
| 227 |
|
if (offset + str_len > buf_size - 1 || display_len + (UTF8_fixed_width ? 2 : wcwidth(wcs[0])) > max_display_len) // No enough space for Chinese character |
| 228 |
{ |
{ |
| 229 |
outc('\a'); |
outc('\a'); |
| 230 |
iflush(); |
iflush(); |
| 302 |
int offset = 0; |
int offset = 0; |
| 303 |
int eol; |
int eol; |
| 304 |
int display_len; |
int display_len; |
| 305 |
char input_str[4]; |
char input_str[5]; |
| 306 |
|
wchar_t wcs[2]; |
| 307 |
int str_len = 0; |
int str_len = 0; |
| 308 |
char c; |
char c; |
| 309 |
|
|
| 506 |
break; |
break; |
| 507 |
} |
} |
| 508 |
} |
} |
| 509 |
|
input_str[str_len] = '\0'; |
| 510 |
|
|
| 511 |
if (str_len == 0) // Incomplete input |
if (str_len == 0) // Incomplete input |
| 512 |
{ |
{ |
| 513 |
continue; |
continue; |
| 514 |
} |
} |
| 515 |
|
|
| 516 |
if (len + str_len > buf_size - 1 || display_len + 2 > max_display_len) // No enough space for Chinese character |
if (mbstowcs(wcs, input_str, 1) == (size_t)-1) |
| 517 |
|
{ |
| 518 |
|
log_error("mbstowcs() error\n"); |
| 519 |
|
} |
| 520 |
|
if (len + str_len > buf_size - 1 || display_len + (UTF8_fixed_width ? 2 : wcwidth(wcs[0])) > max_display_len) // No enough space for Chinese character |
| 521 |
{ |
{ |
| 522 |
outc('\a'); |
outc('\a'); |
| 523 |
iflush(); |
iflush(); |
| 942 |
moveto(SCREEN_ROWS, 0); |
moveto(SCREEN_ROWS, 0); |
| 943 |
clrtoeol(); |
clrtoeol(); |
| 944 |
prints("\033[1;44;33m时间[\033[36m%s\033[33m]%s%*s \033[33m用户[\033[36m%s\033[33m][%s\033[33m]\033[m", |
prints("\033[1;44;33m时间[\033[36m%s\033[33m]%s%*s \033[33m用户[\033[36m%s\033[33m][%s\033[33m]\033[m", |
| 945 |
str_time, msg_f, 65 - len_str_time - len_msg - len_username - len_str_tm_online, "", BBS_username, str_tm_online); |
str_time, msg_f, 65 - len_str_time - len_msg - len_username - len_str_tm_online, |
| 946 |
|
"", BBS_username, str_tm_online); |
| 947 |
|
|
| 948 |
return 0; |
return 0; |
| 949 |
} |
} |