| 14 |
* * |
* * |
| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 16 |
|
|
|
#define _POSIX_C_SOURCE 200809L |
|
|
|
|
| 17 |
#include "article_post.h" |
#include "article_post.h" |
| 18 |
#include "article_cache.h" |
#include "article_cache.h" |
| 19 |
#include "editor.h" |
#include "editor.h" |
| 108 |
{ |
{ |
| 109 |
switch (toupper(ch)) |
switch (toupper(ch)) |
| 110 |
{ |
{ |
| 111 |
|
case KEY_NULL: |
| 112 |
|
case KEY_TIMEOUT: |
| 113 |
|
goto cleanup; |
| 114 |
case CR: |
case CR: |
| 115 |
igetch_reset(); |
igetch_reset(); |
| 116 |
break; |
break; |
| 174 |
{ |
{ |
| 175 |
switch (toupper(ch)) |
switch (toupper(ch)) |
| 176 |
{ |
{ |
| 177 |
|
case KEY_NULL: |
| 178 |
|
case KEY_TIMEOUT: |
| 179 |
|
goto cleanup; |
| 180 |
case CR: |
case CR: |
| 181 |
igetch_reset(); |
igetch_reset(); |
| 182 |
case 'S': |
case 'S': |
| 205 |
} |
} |
| 206 |
} |
} |
| 207 |
|
|
| 208 |
|
if (SYS_server_exit) // Do not save data on shutdown |
| 209 |
|
{ |
| 210 |
|
goto cleanup; |
| 211 |
|
} |
| 212 |
|
|
| 213 |
content = malloc(ARTICLE_CONTENT_MAX_LEN); |
content = malloc(ARTICLE_CONTENT_MAX_LEN); |
| 214 |
if (content == NULL) |
if (content == NULL) |
| 215 |
{ |
{ |
| 483 |
content[ARTICLE_CONTENT_MAX_LEN - 1] = '\0'; |
content[ARTICLE_CONTENT_MAX_LEN - 1] = '\0'; |
| 484 |
|
|
| 485 |
// Remove control sequence |
// Remove control sequence |
| 486 |
len_content = ctrl_seq_filter(content); |
len_content = str_filter(content, 0); |
| 487 |
|
|
| 488 |
p_editor_data = editor_data_load(content); |
p_editor_data = editor_data_load(content); |
| 489 |
if (p_editor_data == NULL) |
if (p_editor_data == NULL) |
| 515 |
{ |
{ |
| 516 |
switch (toupper(ch)) |
switch (toupper(ch)) |
| 517 |
{ |
{ |
| 518 |
|
case KEY_NULL: |
| 519 |
|
case KEY_TIMEOUT: |
| 520 |
|
goto cleanup; |
| 521 |
case CR: |
case CR: |
| 522 |
igetch_reset(); |
igetch_reset(); |
| 523 |
case 'S': |
case 'S': |
| 538 |
} |
} |
| 539 |
} |
} |
| 540 |
|
|
| 541 |
|
if (SYS_server_exit) // Do not save data on shutdown |
| 542 |
|
{ |
| 543 |
|
goto cleanup; |
| 544 |
|
} |
| 545 |
|
|
| 546 |
// Allocate buffers in big size |
// Allocate buffers in big size |
| 547 |
content = malloc(ARTICLE_CONTENT_MAX_LEN); |
content = malloc(ARTICLE_CONTENT_MAX_LEN); |
| 548 |
if (content == NULL) |
if (content == NULL) |
| 739 |
|
|
| 740 |
p_article_new->title[0] = '\0'; |
p_article_new->title[0] = '\0'; |
| 741 |
snprintf(title_input, sizeof(title_input), "Re: %s", p_article->title); |
snprintf(title_input, sizeof(title_input), "Re: %s", p_article->title); |
| 742 |
len = split_line(title_input, TITLE_INPUT_MAX_LEN, &eol, &display_len); |
len = split_line(title_input, TITLE_INPUT_MAX_LEN, &eol, &display_len, 0); |
| 743 |
title_input[len] = '\0'; |
title_input[len] = '\0'; |
| 744 |
|
|
| 745 |
db = db_open(); |
db = db_open(); |
| 781 |
{ |
{ |
| 782 |
mysql_close(db); |
mysql_close(db); |
| 783 |
db = NULL; |
db = NULL; |
| 784 |
|
|
| 785 |
clearscr(); |
clearscr(); |
| 786 |
moveto(1, 1); |
moveto(1, 1); |
| 787 |
prints("该主题谢绝回复"); |
prints("该主题谢绝回复"); |
| 832 |
content_f[len] = '\0'; |
content_f[len] = '\0'; |
| 833 |
|
|
| 834 |
// Remove control sequence |
// Remove control sequence |
| 835 |
len = ctrl_seq_filter(content_f); |
len = str_filter(content_f, 0); |
| 836 |
|
|
| 837 |
len = snprintf(content, ARTICLE_CONTENT_MAX_LEN, |
len = snprintf(content, ARTICLE_CONTENT_MAX_LEN, |
| 838 |
"\n\n【 在 %s (%s) 的大作中提到: 】\n", |
"\n\n【 在 %s (%s) 的大作中提到: 】\n", |
| 839 |
p_article->username, p_article->nickname); |
p_article->username, p_article->nickname); |
| 840 |
|
|
| 841 |
quote_content_lines = split_data_lines(content_f, ARTICLE_QUOTE_LINE_MAX_LEN, line_offsets, ARTICLE_QUOTE_MAX_LINES + 1); |
quote_content_lines = split_data_lines(content_f, ARTICLE_QUOTE_LINE_MAX_LEN, line_offsets, ARTICLE_QUOTE_MAX_LINES + 1, 0); |
| 842 |
for (i = 0; i < quote_content_lines; i++) |
for (i = 0; i < quote_content_lines; i++) |
| 843 |
{ |
{ |
| 844 |
memcpy(content + len, ": ", 2); // quote line prefix |
memcpy(content + len, ": ", 2); // quote line prefix |
| 845 |
len += 2; |
len += 2; |
| 846 |
memcpy(content + len, content_f + line_offsets[i], (size_t)(line_offsets[i + 1] - line_offsets[i])); |
memcpy(content + len, content_f + line_offsets[i], (size_t)(line_offsets[i + 1] - line_offsets[i])); |
| 847 |
len += (line_offsets[i + 1] - line_offsets[i]); |
len += (line_offsets[i + 1] - line_offsets[i]); |
| 848 |
|
if (content[len - 1] != '\n') // Appennd \n if not exist |
| 849 |
|
{ |
| 850 |
|
content[len] = '\n'; |
| 851 |
|
len++; |
| 852 |
|
} |
| 853 |
} |
} |
| 854 |
if (content[len - 1] != '\n') // Appennd \n if not exist |
if (content[len - 1] != '\n') // Appennd \n if not exist |
| 855 |
{ |
{ |
| 903 |
{ |
{ |
| 904 |
switch (toupper(ch)) |
switch (toupper(ch)) |
| 905 |
{ |
{ |
| 906 |
|
case KEY_NULL: |
| 907 |
|
case KEY_TIMEOUT: |
| 908 |
|
goto cleanup; |
| 909 |
case CR: |
case CR: |
| 910 |
igetch_reset(); |
igetch_reset(); |
| 911 |
break; |
break; |
| 963 |
{ |
{ |
| 964 |
switch (toupper(ch)) |
switch (toupper(ch)) |
| 965 |
{ |
{ |
| 966 |
|
case KEY_NULL: |
| 967 |
|
case KEY_TIMEOUT: |
| 968 |
|
goto cleanup; |
| 969 |
case CR: |
case CR: |
| 970 |
igetch_reset(); |
igetch_reset(); |
| 971 |
case 'S': |
case 'S': |
| 994 |
} |
} |
| 995 |
} |
} |
| 996 |
|
|
| 997 |
|
if (SYS_server_exit) // Do not save data on shutdown |
| 998 |
|
{ |
| 999 |
|
goto cleanup; |
| 1000 |
|
} |
| 1001 |
|
|
| 1002 |
content = malloc(ARTICLE_CONTENT_MAX_LEN); |
content = malloc(ARTICLE_CONTENT_MAX_LEN); |
| 1003 |
if (content == NULL) |
if (content == NULL) |
| 1004 |
{ |
{ |