/[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.17 by sysadm, Sun Jun 15 04:46:19 2025 UTC Revision 1.22 by sysadm, Sat Jun 21 02:15:18 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
 #define _POSIX_C_SOURCE 200809L  
   
 #include "article_post.h"  
17  #include "article_cache.h"  #include "article_cache.h"
18  #include "editor.h"  #include "article_post.h"
 #include "screen.h"  
19  #include "bbs.h"  #include "bbs.h"
20  #include "log.h"  #include "database.h"
21    #include "editor.h"
22  #include "io.h"  #include "io.h"
23    #include "log.h"
24  #include "lml.h"  #include "lml.h"
25  #include "database.h"  #include "screen.h"
26  #include "user_priv.h"  #include "user_priv.h"
27  #include <ctype.h>  #include <ctype.h>
28  #include <string.h>  #include <string.h>
# Line 110  int article_post(const SECTION_LIST *p_s Line 108  int article_post(const SECTION_LIST *p_s
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;
# Line 173  int article_post(const SECTION_LIST *p_s Line 174  int article_post(const SECTION_LIST *p_s
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':
# Line 201  int article_post(const SECTION_LIST *p_s Line 205  int article_post(const SECTION_LIST *p_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          {          {
# Line 474  int article_modify(const SECTION_LIST *p Line 483  int article_modify(const SECTION_LIST *p
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)
# Line 506  int article_modify(const SECTION_LIST *p Line 515  int article_modify(const SECTION_LIST *p
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':
# Line 526  int article_modify(const SECTION_LIST *p Line 538  int article_modify(const SECTION_LIST *p
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)
# Line 722  int article_reply(const SECTION_LIST *p_ Line 739  int article_reply(const SECTION_LIST *p_
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();
# Line 764  int article_reply(const SECTION_LIST *p_ Line 781  int article_reply(const SECTION_LIST *p_
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("该主题谢绝回复");
# Line 815  int article_reply(const SECTION_LIST *p_ Line 832  int article_reply(const SECTION_LIST *p_
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                  {                  {
# Line 881  int article_reply(const SECTION_LIST *p_ Line 903  int article_reply(const SECTION_LIST *p_
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;
# Line 938  int article_reply(const SECTION_LIST *p_ Line 963  int article_reply(const SECTION_LIST *p_
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':
# Line 966  int article_reply(const SECTION_LIST *p_ Line 994  int article_reply(const SECTION_LIST *p_
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          {          {


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

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