| 24 |
#include "file_loader.h" |
#include "file_loader.h" |
| 25 |
#include <fcntl.h> |
#include <fcntl.h> |
| 26 |
#include <ctype.h> |
#include <ctype.h> |
| 27 |
|
#include <string.h> |
| 28 |
#include <unistd.h> |
#include <unistd.h> |
| 29 |
#include <stdlib.h> |
#include <stdlib.h> |
| 30 |
#include <errno.h> |
#include <errno.h> |
| 33 |
#include <sys/param.h> |
#include <sys/param.h> |
| 34 |
#include <sys/shm.h> |
#include <sys/shm.h> |
| 35 |
|
|
|
#define _POSIX_C_SOURCE 200809L |
|
|
#include <string.h> |
|
|
|
|
| 36 |
#define ACTIVE_BOARD_HEIGHT 8 |
#define ACTIVE_BOARD_HEIGHT 8 |
| 37 |
|
|
| 38 |
#define STR_TOP_LEFT_MAX_LEN 40 |
#define STR_TOP_LEFT_MAX_LEN 40 |
| 299 |
percentile, |
percentile, |
| 300 |
ctx.msg); |
ctx.msg); |
| 301 |
|
|
| 302 |
len = split_line(buffer, SCREEN_COLS, &eol, &display_len); |
len = split_line(buffer, SCREEN_COLS, &eol, &display_len, 1); |
| 303 |
for (; display_len < SCREEN_COLS; display_len++) |
for (; display_len < SCREEN_COLS; display_len++) |
| 304 |
{ |
{ |
| 305 |
buffer[len++] = ' '; |
buffer[len++] = ' '; |
| 422 |
output_end_row = SCREEN_ROWS - 1; |
output_end_row = SCREEN_ROWS - 1; |
| 423 |
clrline(output_current_row, SCREEN_ROWS); |
clrline(output_current_row, SCREEN_ROWS); |
| 424 |
break; |
break; |
|
case KEY_F2: // For test only |
|
|
EDITOR_DATA *p_editor_data; |
|
|
size_t data_new_len = strlen(p_data) + LINE_BUFFER_LEN; |
|
|
|
|
|
char *p_data_new = malloc(data_new_len); |
|
|
if (p_data_new == NULL) |
|
|
{ |
|
|
break; |
|
|
} |
|
|
p_editor_data = editor_data_load(p_data); |
|
|
if (p_editor_data == NULL) |
|
|
{ |
|
|
free(p_data_new); |
|
|
break; |
|
|
} |
|
|
|
|
|
editor_display(p_editor_data); |
|
|
editor_data_save(p_editor_data, p_data_new, data_new_len); |
|
|
editor_data_cleanup(p_editor_data); |
|
|
p_editor_data = NULL; |
|
|
free(p_data_new); |
|
|
p_data_new = NULL; |
|
|
|
|
|
// Refresh after display editor |
|
|
line_current -= (output_current_row - screen_begin_row); |
|
|
output_current_row = screen_begin_row; |
|
|
output_end_row = SCREEN_ROWS - 1; |
|
|
clrline(output_current_row, SCREEN_ROWS); |
|
|
break; |
|
| 425 |
case 0: // Refresh bottom line |
case 0: // Refresh bottom line |
| 426 |
break; |
break; |
| 427 |
default: |
default: |
| 429 |
break; |
break; |
| 430 |
} |
} |
| 431 |
|
|
| 432 |
BBS_last_access_tm = time(0); |
BBS_last_access_tm = time(NULL); |
| 433 |
} |
} |
| 434 |
|
|
| 435 |
continue; |
continue; |
| 516 |
|
|
| 517 |
strncpy(str_left_f, str_left, sizeof(str_left_f) - 1); |
strncpy(str_left_f, str_left, sizeof(str_left_f) - 1); |
| 518 |
str_left_f[sizeof(str_left_f) - 1] = '\0'; |
str_left_f[sizeof(str_left_f) - 1] = '\0'; |
| 519 |
len = split_line(str_left_f, STR_TOP_LEFT_MAX_LEN, &eol, &str_left_len); |
len = split_line(str_left_f, STR_TOP_LEFT_MAX_LEN, &eol, &str_left_len, 1); |
| 520 |
str_left_f[len] = '\0'; |
str_left_f[len] = '\0'; |
| 521 |
|
|
| 522 |
strncpy(str_middle_f, str_middle, sizeof(str_middle_f) - 1); |
strncpy(str_middle_f, str_middle, sizeof(str_middle_f) - 1); |
| 523 |
str_middle_f[sizeof(str_middle_f) - 1] = '\0'; |
str_middle_f[sizeof(str_middle_f) - 1] = '\0'; |
| 524 |
len = split_line(str_middle, STR_TOP_MIDDLE_MAX_LEN, &eol, &str_middle_len); |
len = split_line(str_middle, STR_TOP_MIDDLE_MAX_LEN, &eol, &str_middle_len, 1); |
| 525 |
str_middle_f[len] = '\0'; |
str_middle_f[len] = '\0'; |
| 526 |
|
|
| 527 |
strncpy(str_right_f, str_right, sizeof(str_right_f) - 1); |
strncpy(str_right_f, str_right, sizeof(str_right_f) - 1); |
| 528 |
str_right_f[sizeof(str_right_f) - 1] = '\0'; |
str_right_f[sizeof(str_right_f) - 1] = '\0'; |
| 529 |
len = split_line(str_right, STR_TOP_RIGHT_MAX_LEN, &eol, &str_right_len); |
len = split_line(str_right, STR_TOP_RIGHT_MAX_LEN, &eol, &str_right_len, 1); |
| 530 |
str_right_f[len] = '\0'; |
str_right_f[len] = '\0'; |
| 531 |
|
|
| 532 |
moveto(1, 0); |
moveto(1, 0); |
| 557 |
{ |
{ |
| 558 |
strncpy(msg_f, msg, sizeof(msg_f) - 1); |
strncpy(msg_f, msg, sizeof(msg_f) - 1); |
| 559 |
msg_f[sizeof(msg_f) - 1] = '\0'; |
msg_f[sizeof(msg_f) - 1] = '\0'; |
| 560 |
len = split_line(msg_f, 23, &eol, &msg_len); |
len = split_line(msg_f, 23, &eol, &msg_len, 1); |
| 561 |
msg_f[len] = '\0'; |
msg_f[len] = '\0'; |
| 562 |
} |
} |
| 563 |
|
|
| 564 |
len_username = (int)strnlen(BBS_username, sizeof(BBS_username)); |
len_username = (int)strnlen(BBS_username, sizeof(BBS_username)); |
| 565 |
|
|
| 566 |
time_online = time(0) - BBS_login_tm; |
time_online = time(NULL) - BBS_login_tm; |
| 567 |
tm_online = gmtime(&time_online); |
tm_online = gmtime(&time_online); |
| 568 |
if (tm_online->tm_mday > 1) |
if (tm_online->tm_mday > 1) |
| 569 |
{ |
{ |
| 610 |
} |
} |
| 611 |
} |
} |
| 612 |
|
|
| 613 |
if (time(0) - t_last_show >= 10) |
if (time(NULL) - t_last_show >= 10) |
| 614 |
{ |
{ |
| 615 |
line_last = line_current; |
line_last = line_current; |
| 616 |
t_last_show = time(0); |
t_last_show = time(NULL); |
| 617 |
} |
} |
| 618 |
else |
else |
| 619 |
{ |
{ |