/[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.3 by sysadm, Tue Jun 3 00:57:27 2025 UTC Revision 1.4 by sysadm, Tue Jun 3 01:26:52 2025 UTC
# Line 62  static int lml_tag_color_filter(const ch Line 62  static int lml_tag_color_filter(const ch
62          return 0;          return 0;
63  }  }
64    
65    #define LML_TAG_QUOTE_MAX_LEVEL 10
66    #define LML_TAG_QUOTE_LEVEL_LOOP 3
67    
68    static const char *lml_tag_quote_color[] = {
69            "\033[33m",
70            "\033[32m",
71            "\033[35m",
72    };
73    
74    static int lml_tag_quote_level = 0;
75    
76    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)
77    {
78    
79            if (strcasecmp(tag_name, "quote") == 0)
80            {
81                    if (lml_tag_quote_level <= LML_TAG_QUOTE_MAX_LEVEL)
82                    {
83                            lml_tag_quote_level++;
84                    }
85                    return snprintf(tag_output_buf, tag_output_buf_len, lml_tag_quote_color[lml_tag_quote_level % LML_TAG_QUOTE_LEVEL_LOOP]);
86            }
87            else if (strcasecmp(tag_name, "/quote") == 0)
88            {
89                    if (lml_tag_quote_level > 0)
90                    {
91                            lml_tag_quote_level--;
92                    }
93                    if (lml_tag_quote_level > 0)
94                    {
95                            return snprintf(tag_output_buf, tag_output_buf_len, lml_tag_quote_color[lml_tag_quote_level % LML_TAG_QUOTE_LEVEL_LOOP]);
96                    }
97                    else
98                    {
99                            return snprintf(tag_output_buf, tag_output_buf_len, "\033[m");
100                    }
101            }
102    
103            return 0;
104    }
105    
106  const static char *LML_tag_def[][3] = {  const static char *LML_tag_def[][3] = {
107          {"left", "[", ""},          {"left", "[", ""},
108          {"right", "]", NULL},          {"right", "]", NULL},
# Line 79  const static char *LML_tag_def[][3] = { Line 120  const static char *LML_tag_def[][3] = {
120          {"/u", "\033[24m", NULL},          {"/u", "\033[24m", NULL},
121          {"color", NULL, (const char *)lml_tag_color_filter},          {"color", NULL, (const char *)lml_tag_color_filter},
122          {"/color", "\033[m", NULL},          {"/color", "\033[m", NULL},
123            {"quote", NULL, (const char *)lml_tag_quote_filter},
124            {"/quote", NULL, (const char *)lml_tag_quote_filter},
125          {"url", "", ""},          {"url", "", ""},
126          {"/url", "(Á´½Ó: %s)", NULL},          {"/url", "(Á´½Ó: %s)", NULL},
127          {"link", "", ""},          {"link", "", ""},
# Line 94  const static char *LML_tag_def[][3] = { Line 137  const static char *LML_tag_def[][3] = {
137          {"bwf", "\033[1;31m****\033[m", ""},          {"bwf", "\033[1;31m****\033[m", ""},
138  };  };
139    
140  #define LML_TAG_COUNT 29  #define LML_TAG_COUNT 31
141    
142  static int LML_tag_name_len[LML_TAG_COUNT];  static int LML_tag_name_len[LML_TAG_COUNT];
143  static int LML_init = 0;  static int LML_init = 0;
# Line 128  int lml_plain(const char *str_in, char * Line 171  int lml_plain(const char *str_in, char *
171    
172          lml_init();          lml_init();
173    
174            lml_tag_quote_level = 0;
175    
176          for (i = 0; str_in[i] != '\0'; i++)          for (i = 0; str_in[i] != '\0'; i++)
177          {          {
178                  if (str_in[i] == '[')                  if (str_in[i] == '[')


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

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