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

Diff of /lbbs/src/str_process.c

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

Revision 1.15 by sysadm, Sat Jun 14 10:03:32 2025 UTC Revision 1.18 by sysadm, Sat Jun 21 02:15:18 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
 #include "str_process.h"  
17  #include "common.h"  #include "common.h"
18  #include "log.h"  #include "log.h"
19    #include "str_process.h"
20  #include <stdio.h>  #include <stdio.h>
21  #include <string.h>  #include <string.h>
22    
23  int split_line(const char *buffer, int max_display_len, int *p_eol, int *p_display_len)  int split_line(const char *buffer, int max_display_len, int *p_eol, int *p_display_len, int skip_ctrl_seq)
24  {  {
25          int i;          int i;
26          *p_eol = 0;          *p_eol = 0;
# Line 36  int split_line(const char *buffer, int m Line 36  int split_line(const char *buffer, int m
36                          continue;                          continue;
37                  }                  }
38    
39                  if (c == '\033' && buffer[i + 1] == '[') // Skip control sequence                  if (skip_ctrl_seq && c == '\033' && buffer[i + 1] == '[') // Skip control sequence
40                  {                  {
41                          i += 2;                          i += 2;
42                          while (buffer[i] != '\0' && buffer[i] != 'm')                          while (buffer[i] != '\0' && buffer[i] != 'm')
# Line 76  int split_line(const char *buffer, int m Line 76  int split_line(const char *buffer, int m
76          return i;          return i;
77  }  }
78    
79  long split_data_lines(const char *p_buf, int max_display_len, long *p_line_offsets, long line_offsets_count)  long split_data_lines(const char *p_buf, int max_display_len, long *p_line_offsets, long line_offsets_count, int skip_ctrl_seq)
80  {  {
81          int line_cnt = 0;          int line_cnt = 0;
82          int len;          int len;
# Line 87  long split_data_lines(const char *p_buf, Line 87  long split_data_lines(const char *p_buf,
87    
88          do          do
89          {          {
90                  len = split_line(p_buf, max_display_len, &end_of_line, &display_len);                  len = split_line(p_buf, max_display_len, &end_of_line, &display_len, skip_ctrl_seq);
91    
92                  // Exceed max_line_cnt                  // Exceed max_line_cnt
93                  if (line_cnt + 1 >= line_offsets_count)                  if (line_cnt + 1 >= line_offsets_count)
94                  {                  {
95                          log_error("Line count %d reaches limit %d\n", line_cnt + 1, line_offsets_count);                          // log_error("Line count %d reaches limit %d\n", line_cnt + 1, line_offsets_count);
96                          return line_cnt;                          return line_cnt;
97                  }                  }
98    
# Line 104  long split_data_lines(const char *p_buf, Line 104  long split_data_lines(const char *p_buf,
104          return line_cnt;          return line_cnt;
105  }  }
106    
107  int ctrl_seq_filter(char *buffer)  int str_filter(char *buffer, int skip_ctrl_seq)
108  {  {
109          int i;          int i;
110          int j;          int j;
# Line 116  int ctrl_seq_filter(char *buffer) Line 116  int ctrl_seq_filter(char *buffer)
116                          continue;                          continue;
117                  }                  }
118    
119                  if (buffer[i] == '\033' && buffer[i + 1] == '[') // Skip control sequence                  if (skip_ctrl_seq && buffer[i] == '\033' && buffer[i + 1] == '[') // Skip control sequence
120                  {                  {
121                          i += 2;                          i += 2;
122                          while (buffer[i] != '\0' && buffer[i] != 'm')                          while (buffer[i] != '\0' && buffer[i] != 'm')


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

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