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

Diff of /lbbs/src/lml.c

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

Revision 1.27 by sysadm, Fri Oct 24 07:27:02 2025 UTC Revision 1.31 by sysadm, Wed Oct 29 03:23:39 2025 UTC
# Line 63  static int lml_tag_color_filter(const ch Line 63  static int lml_tag_color_filter(const ch
63  }  }
64    
65  #define LML_TAG_QUOTE_MAX_LEVEL 10  #define LML_TAG_QUOTE_MAX_LEVEL 10
 #define LML_TAG_QUOTE_LEVEL_LOOP 3  
66    
67  static const char *lml_tag_quote_color[] = {  static const char *lml_tag_quote_color[] = {
68          "\033[33m", // yellow          "\033[33m", // yellow
# Line 71  static const char *lml_tag_quote_color[] Line 70  static const char *lml_tag_quote_color[]
70          "\033[35m", // magenta          "\033[35m", // magenta
71  };  };
72    
73    static const int LML_TAG_QUOTE_LEVEL_LOOP = (int)(sizeof(lml_tag_quote_color) / sizeof(const char *));
74    
75  static int lml_tag_quote_level = 0;  static int lml_tag_quote_level = 0;
76    
77  static int lml_tag_quote_filter(const char *tag_name, const char *tag_param_buf, char *tag_output_buf, size_t tag_output_buf_len, int quote_mode)  static int lml_tag_quote_filter(const char *tag_name, const char *tag_param_buf, char *tag_output_buf, size_t tag_output_buf_len, int quote_mode)
# Line 118  typedef struct lml_tag_def_t Line 119  typedef struct lml_tag_def_t
119  const LML_TAG_DEF lml_tag_def[] = {  const LML_TAG_DEF lml_tag_def[] = {
120          // Definition of tuple: {lml_tag, lml_output, default_param, quote_mode_output, lml_filter_cb}          // Definition of tuple: {lml_tag, lml_output, default_param, quote_mode_output, lml_filter_cb}
121          {"plain", NULL, NULL, NULL, lml_tag_disable_filter},          {"plain", NULL, NULL, NULL, lml_tag_disable_filter},
122          {"nolml", "", NULL, "", NULL},          {"nolml", "", NULL, "", NULL}, // deprecated
123          {"lml", "", NULL, "", NULL},          {"lml", "", NULL, "", NULL},   // deprecated
124            {"align", "", "", "", NULL},   // N/A
125            {"/align", "", "", "", NULL},  // N/A
126            {"size", "", "", "", NULL},        // N/A
127            {"/size", "", "", "", NULL},   // N/A
128          {"left", "[", "", "[left]", NULL},          {"left", "[", "", "[left]", NULL},
129          {"right", "]", "", "[right]", NULL},          {"right", "]", "", "[right]", NULL},
130          {"bold", "\033[1m", "", "", NULL}, // does not work in Fterm          {"bold", "\033[1m", "", "", NULL}, // does not work in Fterm
# Line 227  int lml_render(const char *str_in, char Line 232  int lml_render(const char *str_in, char
232                                  lml_tag_quote_level += fb_quote_level;                                  lml_tag_quote_level += fb_quote_level;
233    
234                                  tag_output_len = snprintf(tag_output_buf, LML_TAG_OUTPUT_BUF_LEN, "%s",                                  tag_output_len = snprintf(tag_output_buf, LML_TAG_OUTPUT_BUF_LEN, "%s",
235                                                                                    lml_tag_quote_color[(lml_tag_quote_level) % LML_TAG_QUOTE_LEVEL_LOOP]);                                                                                    lml_tag_quote_color[lml_tag_quote_level % LML_TAG_QUOTE_LEVEL_LOOP]);
236                                  if (j + tag_output_len >= buf_len)                                  if (j + tag_output_len >= buf_len)
237                                  {                                  {
238                                          log_error("Buffer is not longer enough for output string %d >= %d\n", j + tag_output_len, buf_len);                                          log_error("Buffer is not longer enough for output string %d >= %d\n", j + tag_output_len, buf_len);
# Line 265  int lml_render(const char *str_in, char Line 270  int lml_render(const char *str_in, char
270                          }                          }
271                  }                  }
272    
273                  if (str_in[i] == '\n')                  if (str_in[i] == '\n') // jump out of tag at end of line
274                  {                  {
275                          tag_name_pos = -1; // jump out of tag at end of line                          if (tag_start_pos != -1) // tag is not closed
276                            {
277                                    tag_end_pos = i - 1;
278                                    tag_output_len = tag_end_pos - tag_start_pos + 1;
279                                    if (j + tag_output_len >= buf_len)
280                                    {
281                                            log_error("Buffer is not longer enough for output string %ld >= %d\n", j + tag_output_len, buf_len);
282                                            str_out[j] = '\0';
283                                            return j;
284                                    }
285    
286                                    memcpy(str_out + j, str_in + tag_start_pos, (size_t)tag_output_len);
287                                    j += tag_output_len;
288                            }
289    
290                            tag_start_pos = -1;
291                            tag_name_pos = -1;
292                          new_line = 1;                          new_line = 1;
293                  }                  }
294                  else if (str_in[i] == '\r')                  else if (str_in[i] == '\r')


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

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