/[LeafOK_CVS]/lbbs/src/article_post.c
ViewVC logotype

Diff of /lbbs/src/article_post.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.41 by sysadm, Fri Nov 7 06:41:43 2025 UTC Revision 1.42 by sysadm, Mon Nov 10 14:22:18 2025 UTC
# Line 25  Line 25 
25  enum _article_post_constant_t  enum _article_post_constant_t
26  {  {
27          TITLE_INPUT_MAX_LEN = 72,          TITLE_INPUT_MAX_LEN = 72,
28          ARTICLE_QUOTE_MAX_LINES = 20,          ARTICLE_QUOTE_DEFAULT_LINES = 20,
29          MODIFY_DT_MAX_LEN = 50,          MODIFY_DT_MAX_LEN = 50,
30  };  };
31    
# Line 83  int article_post(const SECTION_LIST *p_s Line 83  int article_post(const SECTION_LIST *p_s
83          {          {
84                  clearscr();                  clearscr();
85                  moveto(21, 1);                  moveto(21, 1);
86                  prints("发表文章于 %s[%s] 讨论区,类型: %s,回复通知:%s",                  prints("发表文章于 %s[%s] 讨论区,类型: %s,回复通知: %s",
87                             p_section->stitle, p_section->sname,                             p_section->stitle, p_section->sname,
88                             (p_article_new->transship ? "转载" : "原创"),                             (p_article_new->transship ? "转载" : "原创"),
89                             (reply_note ? "开启" : "关闭"));                             (reply_note ? "开启" : "关闭"));
# Line 736  int article_reply(const SECTION_LIST *p_ Line 736  int article_reply(const SECTION_LIST *p_
736          MYSQL *db = NULL;          MYSQL *db = NULL;
737          MYSQL_RES *rs = NULL;          MYSQL_RES *rs = NULL;
738          MYSQL_ROW row;          MYSQL_ROW row;
739          long line_offsets[ARTICLE_QUOTE_MAX_LINES + 1];          long line_offsets[MAX_EDITOR_DATA_LINES + 1];
740          char sql[SQL_BUFFER_LEN];          char sql[SQL_BUFFER_LEN];
741          char *sql_content = NULL;          char *sql_content = NULL;
742          EDITOR_DATA *p_editor_data = NULL;          EDITOR_DATA *p_editor_data = NULL;
# Line 749  int article_reply(const SECTION_LIST *p_ Line 749  int article_reply(const SECTION_LIST *p_
749          char nickname_f[BBS_nickname_max_len * 2 + 1];          char nickname_f[BBS_nickname_max_len * 2 + 1];
750          int sign_id = 0;          int sign_id = 0;
751          int reply_note = 0;          int reply_note = 0;
752            int full_quote = 0;
753          long len;          long len;
754          int ch;          int ch;
755          char *p, *q;          char *p, *q;
# Line 873  int article_reply(const SECTION_LIST *p_ Line 874  int article_reply(const SECTION_LIST *p_
874    
875                  // Remove control sequence                  // Remove control sequence
876                  len = str_filter(content_f, 0);                  len = str_filter(content_f, 0);
   
                 len = snprintf(content, ARTICLE_CONTENT_MAX_LEN,  
                                            "\n\n【 在 %s (%s) 的大作中提到: 】\n",  
                                            p_article->username, p_article->nickname);  
   
                 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  
                         len += 2;  
                         memcpy(content + len, content_f + line_offsets[i], (size_t)(line_offsets[i + 1] - line_offsets[i]));  
                         len += (line_offsets[i + 1] - line_offsets[i]);  
                         if (content[len - 1] != '\n') // Appennd \n if not exist  
                         {  
                                 content[len] = '\n';  
                                 len++;  
                         }  
                 }  
                 if (content[len - 1] != '\n') // Appennd \n if not exist  
                 {  
                         content[len] = '\n';  
                         len++;  
                 }  
                 content[len] = '\0';  
   
                 free(content_f);  
                 content_f = NULL;  
   
                 p_editor_data = editor_data_load(content);  
                 if (p_editor_data == NULL)  
                 {  
                         log_error("editor_data_load(aid=%d, cid=%d) error\n", p_article->aid, atoi(row[0]));  
                         ret = -1;  
                         goto cleanup;  
                 }  
   
                 free(content);  
                 content = NULL;  
877          }          }
878          mysql_free_result(rs);          mysql_free_result(rs);
879          rs = NULL;          rs = NULL;
# Line 923  int article_reply(const SECTION_LIST *p_ Line 886  int article_reply(const SECTION_LIST *p_
886          {          {
887                  clearscr();                  clearscr();
888                  moveto(21, 1);                  moveto(21, 1);
889                  prints("回复文章于 %s[%s] 讨论区,回复通知:%s", p_section->stitle, p_section->sname, (reply_note ? "开启" : "关闭"));                  prints("回复文章于 %s[%s] 讨论区, 回复通知: %s, 引用模式: %s",
890                               p_section->stitle, p_section->sname,
891                               (reply_note ? "开启" : "关闭"),
892                               (full_quote ? "完整" : "精简"));
893                  moveto(22, 1);                  moveto(22, 1);
894                  prints("标题: %s", (p_article_new->title[0] == '\0' ? "[无]" : p_article_new->title));                  prints("标题: %s", (p_article_new->title[0] == '\0' ? "[无]" : p_article_new->title));
895                  moveto(23, 1);                  moveto(23, 1);
# Line 934  int article_reply(const SECTION_LIST *p_ Line 900  int article_reply(const SECTION_LIST *p_
900                          prints("    按0~3选签名档(0表示不使用)");                          prints("    按0~3选签名档(0表示不使用)");
901    
902                          moveto(24, 1);                          moveto(24, 1);
903                          prints("T改标题, C取消, N%s, Enter继续: ",                          prints("T改标题, C取消, N%s, Q%s, Enter继续: ",
904                                     (reply_note ? "关闭回复通知" : "开启回复通知"));                                     (reply_note ? "关闭回复通知" : "开启回复通知"), (full_quote ? "精简引用" : "完整引用"));
905                          iflush();                          iflush();
906                          ch = 0;                          ch = 0;
907                  }                  }
# Line 982  int article_reply(const SECTION_LIST *p_ Line 948  int article_reply(const SECTION_LIST *p_
948                          case 'N':                          case 'N':
949                                  reply_note = (reply_note ? 0 : 1);                                  reply_note = (reply_note ? 0 : 1);
950                                  break;                                  break;
951                            case 'Q':
952                                    full_quote = (full_quote ? 0 : 1);
953                                    break;
954                          case '0':                          case '0':
955                          case '1':                          case '1':
956                          case '2':                          case '2':
# Line 1001  int article_reply(const SECTION_LIST *p_ Line 970  int article_reply(const SECTION_LIST *p_
970                          continue;                          continue;
971                  }                  }
972    
973                    len = snprintf(content, ARTICLE_CONTENT_MAX_LEN,
974                                               "\n\n【 在 %s (%s) 的大作中提到: 】\n",
975                                               p_article->username, p_article->nickname);
976    
977                    quote_content_lines = split_data_lines(content_f,
978                                                                                               MAX_EDITOR_DATA_LINE_LENGTH - 2, line_offsets,
979                                                                                               (full_quote ? MAX_EDITOR_DATA_LINES : ARTICLE_QUOTE_DEFAULT_LINES) + 1,
980                                                                                               0, NULL);
981                    for (i = 0; i < quote_content_lines; i++)
982                    {
983                            memcpy(content + len, ": ", 2); // quote line prefix
984                            len += 2;
985                            memcpy(content + len, content_f + line_offsets[i], (size_t)(line_offsets[i + 1] - line_offsets[i]));
986                            len += (line_offsets[i + 1] - line_offsets[i]);
987                            if (content[len - 1] != '\n') // Appennd \n if not exist
988                            {
989                                    content[len] = '\n';
990                                    len++;
991                            }
992                    }
993                    if (content[len - 1] != '\n') // Appennd \n if not exist
994                    {
995                            content[len] = '\n';
996                            len++;
997                    }
998                    content[len] = '\0';
999    
1000                    free(content_f);
1001                    content_f = NULL;
1002    
1003                    p_editor_data = editor_data_load(content);
1004                    if (p_editor_data == NULL)
1005                    {
1006                            log_error("editor_data_load(aid=%d, cid=%d) error\n", p_article->aid, atoi(row[0]));
1007                            ret = -1;
1008                            goto cleanup;
1009                    }
1010    
1011                    free(content);
1012                    content = NULL;
1013    
1014                  for (ch = 'E'; !SYS_server_exit && toupper(ch) == 'E';)                  for (ch = 'E'; !SYS_server_exit && toupper(ch) == 'E';)
1015                  {                  {
1016                          editor_display(p_editor_data);                          editor_display(p_editor_data);


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1