--- lbbs/src/article_post.c 2025/10/10 12:31:15 1.32 +++ lbbs/src/article_post.c 2025/11/05 03:17:12 1.40 @@ -1,18 +1,10 @@ -/*************************************************************************** - article_post.c - description - ------------------- - copyright : (C) 2004-2025 by Leaflet - email : leaflet@leafok.com - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 3 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * article_post + * - user interactive feature to post / modify / reply article + * + * Copyright (C) 2004-2025 Leaflet + */ #include "article_cache.h" #include "article_post.h" @@ -29,12 +21,12 @@ #include #include -#define TITLE_INPUT_MAX_LEN 72 -#define ARTICLE_CONTENT_MAX_LEN 1024 * 1024 * 4 // 4MB -#define ARTICLE_QUOTE_MAX_LINES 20 -#define ARTICLE_QUOTE_LINE_MAX_LEN 76 - -#define MODIFY_DT_MAX_LEN 50 +enum _article_post_constant_t +{ + TITLE_INPUT_MAX_LEN = 72, + ARTICLE_QUOTE_MAX_LINES = 20, + MODIFY_DT_MAX_LEN = 50, +}; int article_post(const SECTION_LIST *p_section, ARTICLE *p_article_new) { @@ -111,7 +103,7 @@ int article_post(const SECTION_LIST *p_s ch = 0; } - for (; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME)) + for (; !SYS_server_exit; ch = igetch_t(BBS_max_user_idle_time)) { switch (toupper(ch)) { @@ -119,7 +111,6 @@ int article_post(const SECTION_LIST *p_s case KEY_TIMEOUT: goto cleanup; case CR: - igetch_reset(); break; case 'T': len = get_data(24, 1, "标题: ", title_input, sizeof(title_input), TITLE_INPUT_MAX_LEN); @@ -175,7 +166,7 @@ int article_post(const SECTION_LIST *p_s prints("(S)发送, (C)取消, (T)更改标题 or (E)再编辑? [S]: "); iflush(); - for (ch = 0; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME)) + for (ch = 0; !SYS_server_exit; ch = igetch_t(BBS_max_user_idle_time)) { switch (toupper(ch)) { @@ -183,7 +174,6 @@ int article_post(const SECTION_LIST *p_s case KEY_TIMEOUT: goto cleanup; case CR: - igetch_reset(); case 'S': break; case 'C': @@ -527,14 +517,13 @@ int article_modify(const SECTION_LIST *p (reply_note ? "关闭" : "开启")); iflush(); - ch = igetch_t(MAX_DELAY_TIME); + ch = igetch_t(BBS_max_user_idle_time); switch (toupper(ch)) { case KEY_NULL: case KEY_TIMEOUT: goto cleanup; case CR: - igetch_reset(); case 'S': break; case 'C': @@ -854,7 +843,7 @@ int article_reply(const SECTION_LIST *p_ } // Apply LML render to content body - len = lml_render(row[1], content_f, ARTICLE_CONTENT_MAX_LEN, 0); + len = lml_render(row[1], content_f, ARTICLE_CONTENT_MAX_LEN, MAX_EDITOR_DATA_LINE_LENGTH - 3, 1); content_f[len] = '\0'; // Remove control sequence @@ -864,7 +853,7 @@ int article_reply(const SECTION_LIST *p_ "\n\n【 在 %s (%s) 的大作中提到: 】\n", p_article->username, p_article->nickname); - quote_content_lines = split_data_lines(content_f, ARTICLE_QUOTE_LINE_MAX_LEN, line_offsets, ARTICLE_QUOTE_MAX_LINES + 1, 0, NULL); + quote_content_lines = split_data_lines(content_f, MAX_EDITOR_DATA_LINE_LENGTH - 2, line_offsets, ARTICLE_QUOTE_MAX_LINES + 1, 0, NULL); for (i = 0; i < quote_content_lines; i++) { memcpy(content + len, ": ", 2); // quote line prefix @@ -926,7 +915,7 @@ int article_reply(const SECTION_LIST *p_ ch = 0; } - for (; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME)) + for (; !SYS_server_exit; ch = igetch_t(BBS_max_user_idle_time)) { switch (toupper(ch)) { @@ -934,7 +923,6 @@ int article_reply(const SECTION_LIST *p_ case KEY_TIMEOUT: goto cleanup; case CR: - igetch_reset(); break; case 'T': len = get_data(24, 1, "标题: ", title_input, sizeof(title_input), TITLE_INPUT_MAX_LEN); @@ -987,7 +975,7 @@ int article_reply(const SECTION_LIST *p_ prints("(S)发送, (C)取消, (T)更改标题 or (E)再编辑? [S]: "); iflush(); - for (ch = 0; !SYS_server_exit; ch = igetch_t(MAX_DELAY_TIME)) + for (ch = 0; !SYS_server_exit; ch = igetch_t(BBS_max_user_idle_time)) { switch (toupper(ch)) { @@ -995,7 +983,6 @@ int article_reply(const SECTION_LIST *p_ case KEY_TIMEOUT: goto cleanup; case CR: - igetch_reset(); case 'S': break; case 'C':