2 * Copyright (C) 2005 QSDN,Inc. All rights reserved.
3 * Copyright (C) 2005 Atsushi Konno All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 #include "chxj_chtml20.h"
18 #include "chxj_hdml.h"
19 #include "chxj_str_util.h"
20 #include "chxj_dump.h"
21 #include "chxj_img_conv.h"
23 static char* chtml20_node_exchange (Chtml20* chtml, Node* node, int indent);
24 static char* chtml20_start_html_tag (Chtml20* chtml, Node* child);
25 static char* chtml20_end_html_tag (Chtml20* chtml, Node* child);
26 static char* chtml20_start_meta_tag (Chtml20* chtml, Node* node);
27 static char* chtml20_end_meta_tag (Chtml20* chtml, Node* node);
28 static char* chtml20_start_head_tag (Chtml20* chtml, Node* node);
29 static char* chtml20_end_head_tag (Chtml20* chtml, Node* node);
30 static char* chtml20_start_title_tag (Chtml20* chtml, Node* node);
31 static char* chtml20_end_title_tag (Chtml20* chtml, Node* node);
32 static char* chtml20_start_base_tag (Chtml20* chtml, Node* node);
33 static char* chtml20_end_base_tag (Chtml20* chtml, Node* node);
34 static char* chtml20_start_body_tag (Chtml20* chtml, Node* node);
35 static char* chtml20_end_body_tag (Chtml20* chtml, Node* node);
36 static char* chtml20_start_a_tag (Chtml20* chtml, Node* node);
37 static char* chtml20_end_a_tag (Chtml20* chtml, Node* node);
38 static char* chtml20_start_br_tag (Chtml20* chtml, Node* node);
39 static char* chtml20_end_br_tag (Chtml20* chtml, Node* node);
40 static char* chtml20_start_font_tag (Chtml20* chtml, Node* node);
41 static char* chtml20_end_font_tag (Chtml20* chtml, Node* node);
42 static char* chtml20_start_form_tag (Chtml20* chtml, Node* node);
43 static char* chtml20_end_form_tag (Chtml20* chtml, Node* node);
44 static char* chtml20_start_input_tag (Chtml20* chtml, Node* node);
45 static char* chtml20_end_input_tag (Chtml20* chtml, Node* node);
46 static char* chtml20_start_center_tag (Chtml20* chtml, Node* node);
47 static char* chtml20_end_center_tag (Chtml20* chtml, Node* node);
48 static char* chtml20_start_hr_tag (Chtml20* chtml, Node* node);
49 static char* chtml20_end_hr_tag (Chtml20* chtml, Node* node);
50 static char* chtml20_start_img_tag (Chtml20* chtml, Node* node);
51 static char* chtml20_end_img_tag (Chtml20* chtml, Node* node);
52 static char* chtml20_start_select_tag (Chtml20* chtml, Node* node);
53 static char* chtml20_end_select_tag (Chtml20* chtml, Node* node);
54 static char* chtml20_start_option_tag (Chtml20* chtml, Node* node);
55 static char* chtml20_end_option_tag (Chtml20* chtml, Node* node);
56 static char* chtml20_start_div_tag (Chtml20* chtml, Node* node);
57 static char* chtml20_end_div_tag (Chtml20* chtml, Node* node);
58 static void chxj_init_chtml20(Chtml20* chtml, Doc* doc, request_rec* r, device_table* spec);
59 static int chtml20_search_emoji(Chtml20* chtml, char* txt, char** rslt);
60 static void chtml20_chxjif_tag(Chtml20* chtml, Node* node);
63 * converts from CHTML5.0 to CHTML2.0.
65 * @param r [i] Requet_rec is appointed.
66 * @param spec [i] The result of the device specification processing which
67 * was done in advance is appointed.
68 * @param src [i] The character string before the converting is appointed.
69 * @return The character string after the converting is returned.
72 chxj_exchange_chtml20(
84 /*--------------------------------------------------------------------------*/
85 /* The CHTML structure is initialized. */
86 /*--------------------------------------------------------------------------*/
87 chxj_init_chtml20(&chtml20, &doc, r, spec);
89 /*--------------------------------------------------------------------------*/
90 /* The character string of the input is analyzed. */
91 /*--------------------------------------------------------------------------*/
93 qs_init_root_node(&doc);
95 ss = apr_pcalloc(r->pool, srclen + 1);
96 memset(ss, 0, srclen + 1);
97 memcpy(ss, src, srclen);
99 chxj_dump_out("[src] CHTML -> CHTML2.0", ss, srclen);
102 qs_parse_string(&doc,ss, strlen(ss));
104 /*--------------------------------------------------------------------------*/
105 /* It converts it from CHTML to CHTML. */
106 /*--------------------------------------------------------------------------*/
107 dst = chtml20_node_exchange(&chtml20, qs_get_root(&doc), 0);
108 qs_all_free(&doc,QX_LOGMARK);
112 return apr_pstrdup(r->pool,ss);
115 if (strlen(dst) == 0)
117 dst = apr_psprintf(r->pool, "\n");
119 *dstlen = strlen(dst);
121 chxj_dump_out("[dst] CHTML -> CHTML2.0", dst, *dstlen);
127 * The CHTML structure is initialized.
129 * @param chtml20 [i/o] The pointer to the HDML structure that wants to be
130 * initialized is specified.
131 * @param doc [i] The Doc structure that should be set to the initialized
132 * HDML structure is specified.
133 * @param r [i] To use POOL, the pointer to request_rec is specified.
134 * @param spec [i] The pointer to the device_table
137 chxj_init_chtml20(Chtml20* chtml20, Doc* doc, request_rec* r, device_table* spec)
139 memset(doc, 0, sizeof(Doc));
140 memset(chtml20, 0, sizeof(Chtml20));
144 chtml20->spec = spec;
145 chtml20->out = qs_alloc_zero_byte_string(r);
146 chtml20->conf = ap_get_module_config(r->per_dir_config, &chxj_module);
147 chtml20->doc->parse_mode = PARSE_MODE_CHTML;
151 * It is main processing of conversion from CHTML to CHTML.
153 * @param chtml20 [i/o] The pointer to the CHTML structure is specified.
154 * @param node [i] The pointer to a current node is specified.
155 * @param indent [i] The depth of the node processing it now is specified.
157 * @return The character string after it converts it is returned.
160 chtml20_node_exchange(Chtml20* chtml20, Node* node, int indent)
163 Doc* doc = chtml20->doc;
164 request_rec* r = doc->r;
166 /*--------------------------------------------------------------------------*/
167 /* It is the main loop of the conversion processing. */
168 /*--------------------------------------------------------------------------*/
169 for (child = qs_get_child_node(doc,node);
171 child = qs_get_next_node(doc,child))
173 char* name = qs_get_node_name(doc,child);
175 /*------------------------------------------------------------------------*/
177 /*------------------------------------------------------------------------*/
178 if (strcasecmp(name, "html") == 0)
180 chtml20_start_html_tag(chtml20, child);
181 chtml20_node_exchange (chtml20, child,indent+1);
182 chtml20_end_html_tag (chtml20, child);
184 /*------------------------------------------------------------------------*/
186 /*------------------------------------------------------------------------*/
188 if (strcasecmp(name, "meta") == 0)
190 chtml20_start_meta_tag(chtml20, child);
191 chtml20_end_meta_tag (chtml20, child);
193 /*------------------------------------------------------------------------*/
195 /*------------------------------------------------------------------------*/
197 if (strcasecmp(name, "head") == 0)
199 chtml20_start_head_tag(chtml20, child);
200 chtml20_node_exchange (chtml20, child,indent+1);
201 chtml20_end_head_tag (chtml20, child);
203 /*------------------------------------------------------------------------*/
205 /*------------------------------------------------------------------------*/
207 if (strcasecmp(name, "title") == 0)
209 chtml20_start_title_tag (chtml20, child);
210 chtml20_node_exchange (chtml20, child,indent+1);
211 chtml20_end_title_tag (chtml20, child);
213 /*------------------------------------------------------------------------*/
215 /*------------------------------------------------------------------------*/
217 if (strcasecmp(name, "base") == 0)
219 chtml20_start_base_tag(chtml20, child);
220 chtml20_end_base_tag (chtml20, child);
222 /*------------------------------------------------------------------------*/
224 /*------------------------------------------------------------------------*/
226 if (strcasecmp(name, "body") == 0)
228 chtml20_start_body_tag(chtml20, child);
229 chtml20_node_exchange (chtml20, child,indent+1);
230 chtml20_end_body_tag (chtml20, child);
232 /*------------------------------------------------------------------------*/
234 /*------------------------------------------------------------------------*/
236 if (strcasecmp(name, "a") == 0)
238 chtml20_start_a_tag (chtml20, child);
239 chtml20_node_exchange (chtml20, child,indent+1);
240 chtml20_end_a_tag (chtml20, child);
242 /*------------------------------------------------------------------------*/
244 /*------------------------------------------------------------------------*/
246 if (strcasecmp(name, "br") == 0)
248 chtml20_start_br_tag (chtml20, child);
249 chtml20_node_exchange (chtml20, child,indent+1);
250 chtml20_end_br_tag (chtml20, child);
252 /*------------------------------------------------------------------------*/
254 /*------------------------------------------------------------------------*/
256 if (strcasecmp(name, "font") == 0)
258 chtml20_start_font_tag(chtml20, child);
259 chtml20_node_exchange (chtml20, child,indent+1);
260 chtml20_end_font_tag (chtml20, child);
262 /*------------------------------------------------------------------------*/
264 /*------------------------------------------------------------------------*/
266 if (strcasecmp(name, "form") == 0)
268 chtml20_start_form_tag(chtml20, child);
269 chtml20_node_exchange (chtml20, child,indent+1);
270 chtml20_end_form_tag (chtml20, child);
272 /*------------------------------------------------------------------------*/
274 /*------------------------------------------------------------------------*/
276 if (strcasecmp(name, "input") == 0)
278 chtml20_start_input_tag (chtml20, child);
279 chtml20_node_exchange (chtml20, child,indent+1);
280 chtml20_end_input_tag (chtml20, child);
282 /*------------------------------------------------------------------------*/
284 /*------------------------------------------------------------------------*/
286 if (strcasecmp(name, "hr") == 0)
288 chtml20_start_hr_tag (chtml20, child);
289 chtml20_end_hr_tag (chtml20, child);
291 /*------------------------------------------------------------------------*/
293 /*------------------------------------------------------------------------*/
295 if (strcasecmp(name, "center") == 0)
297 chtml20_start_center_tag(chtml20, child);
298 chtml20_node_exchange (chtml20, child,indent+1);
299 chtml20_end_center_tag (chtml20, child);
301 /*------------------------------------------------------------------------*/
303 /*------------------------------------------------------------------------*/
305 if (strcasecmp(name, "img") == 0)
307 chtml20_start_img_tag (chtml20, child);
308 chtml20_end_img_tag (chtml20, child);
310 /*------------------------------------------------------------------------*/
312 /*------------------------------------------------------------------------*/
314 if (strcasecmp(name, "select") == 0)
316 chtml20_start_select_tag(chtml20, child);
317 chtml20_node_exchange (chtml20, child, indent+1);
318 chtml20_end_select_tag (chtml20, child);
320 /*------------------------------------------------------------------------*/
322 /*------------------------------------------------------------------------*/
324 if (strcasecmp(name, "option") == 0)
326 chtml20_start_option_tag(chtml20, child);
327 chtml20_node_exchange (chtml20, child, indent+1);
328 chtml20_end_option_tag (chtml20, child);
330 /*------------------------------------------------------------------------*/
332 /*------------------------------------------------------------------------*/
334 if (strcasecmp(name, "div") == 0)
336 chtml20_start_div_tag (chtml20, child);
337 chtml20_node_exchange (chtml20, child, indent+1);
338 chtml20_end_div_tag (chtml20, child);
340 /*------------------------------------------------------------------------*/
342 /*------------------------------------------------------------------------*/
344 if (strcasecmp(name, "blink") == 0)
348 /*------------------------------------------------------------------------*/
350 /*------------------------------------------------------------------------*/
352 if (strcasecmp(name, "chxj:if") == 0)
354 ap_log_rerror(APLOG_MARK, APLOG_DEBUG,0,r, "chxj:if tag found");
355 if (chxj_chxjif_is_mine(chtml20->spec, doc, child))
357 ap_log_rerror(APLOG_MARK, APLOG_DEBUG,0,r, "chxj:if tag is mine");
358 chtml20_chxjif_tag(chtml20, child);
361 /*------------------------------------------------------------------------*/
363 /*------------------------------------------------------------------------*/
365 if (strcasecmp(name, "text") == 0)
374 textval = qs_get_node_value(doc,child);
375 textval = qs_trim_string(chtml20->doc->r, textval);
376 if (strlen(textval) == 0)
381 tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
382 memset(tmp, 0, qs_get_node_size(doc,child)+1);
384 tdst = qs_alloc_zero_byte_string(r);
385 memset(one_byte, 0, sizeof(one_byte));
388 for (ii=0; ii<qs_get_node_size(doc,child); ii++)
391 int rtn = chtml20_search_emoji(chtml20, &textval[ii], &out);
394 tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
398 if (is_sjis_kanji(textval[ii]))
400 one_byte[0] = textval[ii+0];
401 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
402 one_byte[0] = textval[ii+1];
403 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
406 else if (textval[ii] != '\r' && textval[ii] != '\n')
408 one_byte[0] = textval[ii+0];
409 tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
412 chtml20->out = apr_pstrcat(r->pool, chtml20->out, tdst, NULL);
419 * Corresponding EMOJI to a current character-code is retrieved.
420 * The substitution character string is stored in the rslt pointer if agreeing.
422 * @param chtml20 [i] The pointer to the CHTML structure is specified.
423 * @param txt [i] The character string to want to examine whether it is
424 * EMOJI is specified.
425 * @param rslt [o] The pointer to the pointer that stores the result is
427 * @return When corresponding EMOJI exists, it returns it excluding 0.
430 chtml20_search_emoji(Chtml20* chtml20, char* txt, char** rslt)
437 spec = chtml20->spec;
444 ap_log_rerror(APLOG_MARK, APLOG_DEBUG,0,r, "spec is NULL");
447 for (ee = chtml20->conf->emoji;
451 if (ee->imode == NULL)
453 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
454 "emoji->imode is NULL");
458 if (ee->imode->string != NULL
459 && strlen(ee->imode->string) > 0
460 && strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0)
462 if (spec == NULL || spec->emoji_type == NULL)
464 *rslt = apr_palloc(r->pool, 3);
465 (*rslt)[0] = ee->imode->hex1byte & 0xff;
466 (*rslt)[1] = ee->imode->hex2byte & 0xff;
468 return strlen(ee->imode->string);
478 * It is a handler who processes the HTML tag.
480 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
481 * destination is specified.
482 * @param node [i] The HTML tag node is specified.
483 * @return The conversion result is returned.
486 chtml20_start_html_tag(Chtml20* chtml20, Node* node)
488 Doc* doc = chtml20->doc;
489 request_rec* r = doc->r;
491 /*--------------------------------------------------------------------------*/
493 /*--------------------------------------------------------------------------*/
494 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<html>\n", NULL);
500 * It is a handler who processes the HTML tag.
502 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
503 * destination is specified.
504 * @param node [i] The HTML tag node is specified.
505 * @return The conversion result is returned.
508 chtml20_end_html_tag(Chtml20* chtml20, Node* child)
510 Doc* doc = chtml20->doc;
511 request_rec* r = doc->r;
513 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "</html>\n", NULL);
519 * It is a handler who processes the META tag.
521 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
522 * destination is specified.
523 * @param node [i] The META tag node is specified.
524 * @return The conversion result is returned.
527 chtml20_start_meta_tag(Chtml20* chtml20, Node* node)
529 Doc* doc = chtml20->doc;
530 request_rec* r = doc->r;
533 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<meta", NULL);
535 /*--------------------------------------------------------------------------*/
537 /*--------------------------------------------------------------------------*/
538 for (attr = qs_get_attr(doc,node);
540 attr = qs_get_next_attr(doc,attr))
542 char* name = qs_get_attr_name(doc,attr);
543 char* value = qs_get_attr_value(doc,attr);
545 if (strcasecmp(name, "http-equiv") == 0)
547 /*----------------------------------------------------------------------*/
549 /*----------------------------------------------------------------------*/
550 chtml20->out = apr_pstrcat(r->pool,
558 if (strcasecmp(name, "content") == 0)
560 /*----------------------------------------------------------------------*/
562 /*----------------------------------------------------------------------*/
563 chtml20->out = apr_pstrcat(r->pool,
571 chtml20->out = apr_pstrcat(r->pool, chtml20->out, ">", NULL);
576 * It is a handler who processes the META tag.
578 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
579 * destination is specified.
580 * @param node [i] The META tag node is specified.
581 * @return The conversion result is returned.
584 chtml20_end_meta_tag(Chtml20* chtml20, Node* child)
590 * It is a handler who processes the HEAD tag.
592 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
593 * destination is specified.
594 * @param node [i] The HEAD tag node is specified.
595 * @return The conversion result is returned.
598 chtml20_start_head_tag(Chtml20* chtml20, Node* node)
600 Doc* doc = chtml20->doc;
601 request_rec* r = doc->r;
602 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<head>\r\n", NULL);
608 * It is a handler who processes the HEAD tag.
610 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
611 * destination is specified.
612 * @param node [i] The HEAD tag node is specified.
613 * @return The conversion result is returned.
616 chtml20_end_head_tag(Chtml20* chtml20, Node* child)
618 Doc* doc = chtml20->doc;
619 request_rec* r = doc->r;
621 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "</head>\r\n", NULL);
626 * It is a handler who processes the TITLE tag.
628 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
629 * destination is specified.
630 * @param node [i] The TITLE tag node is specified.
631 * @return The conversion result is returned.
634 chtml20_start_title_tag(Chtml20* chtml20, Node* node)
636 Doc* doc = chtml20->doc;
637 request_rec* r = doc->r;
639 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<title>", NULL);
644 * It is a handler who processes the TITLE tag.
646 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
647 * destination is specified.
648 * @param node [i] The TITLE tag node is specified.
649 * @return The conversion result is returned.
652 chtml20_end_title_tag(Chtml20* chtml20, Node* child)
654 Doc* doc = chtml20->doc;
655 request_rec* r = doc->r;
657 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "</title>\r\n", NULL);
663 * It is a handler who processes the BASE tag.
665 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
666 * destination is specified.
667 * @param node [i] The BASE tag node is specified.
668 * @return The conversion result is returned.
671 chtml20_start_base_tag(Chtml20* chtml20, Node* node)
674 Doc* doc = chtml20->doc;
675 request_rec* r = doc->r;
677 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<base", NULL);
679 /*--------------------------------------------------------------------------*/
681 /*--------------------------------------------------------------------------*/
682 for (attr = qs_get_attr(doc,node);
684 attr = qs_get_next_attr(doc,attr))
686 char* name = qs_get_attr_name(doc,attr);
687 char* value = qs_get_attr_value(doc,attr);
688 if (strcasecmp(name, "href") == 0)
690 chtml20->out = apr_pstrcat(r->pool,
698 chtml20->out = apr_pstrcat(r->pool, chtml20->out, " >\r\n", NULL);
703 * It is a handler who processes the BASE tag.
705 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
706 * destination is specified.
707 * @param node [i] The BASE tag node is specified.
708 * @return The conversion result is returned.
711 chtml20_end_base_tag(Chtml20* chtml20, Node* child)
717 * It is a handler who processes the BODY tag.
719 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
720 * destination is specified.
721 * @param node [i] The BODY tag node is specified.
722 * @return The conversion result is returned.
725 chtml20_start_body_tag(Chtml20* chtml20, Node* node)
727 Doc* doc = chtml20->doc;
728 request_rec* r = doc->r;
731 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<body", NULL);
733 /*--------------------------------------------------------------------------*/
735 /*--------------------------------------------------------------------------*/
736 for (attr = qs_get_attr(doc,node);
738 attr = qs_get_next_attr(doc,attr))
740 char* name = qs_get_attr_name(doc,attr);
741 char* value = qs_get_attr_value(doc,attr);
743 if (strcasecmp(name, "bgcolor") == 0)
745 /*----------------------------------------------------------------------*/
747 /*----------------------------------------------------------------------*/
748 chtml20->out = apr_pstrcat(r->pool,
756 if (strcasecmp(name, "text") == 0)
758 /*----------------------------------------------------------------------*/
760 /*----------------------------------------------------------------------*/
761 chtml20->out = apr_pstrcat(r->pool,
769 if (strcasecmp(name, "link") == 0)
771 /*----------------------------------------------------------------------*/
773 /*----------------------------------------------------------------------*/
774 chtml20->out = apr_pstrcat(r->pool,
782 if (strcasecmp(name, "alink") == 0)
784 /*----------------------------------------------------------------------*/
786 /*----------------------------------------------------------------------*/
790 if (strcasecmp(name, "vlink") == 0)
792 /*----------------------------------------------------------------------*/
794 /*----------------------------------------------------------------------*/
798 chtml20->out = apr_pstrcat(r->pool, chtml20->out, ">\r\n", NULL);
804 * It is a handler who processes the BODY tag.
806 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
807 * destination is specified.
808 * @param node [i] The BODY tag node is specified.
809 * @return The conversion result is returned.
812 chtml20_end_body_tag(Chtml20* chtml20, Node* child)
814 Doc* doc = chtml20->doc;
815 request_rec* r = doc->r;
817 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "</body>\r\n", NULL);
823 * It is a handler who processes the A tag.
825 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
826 * destination is specified.
827 * @param node [i] The A tag node is specified.
828 * @return The conversion result is returned.
831 chtml20_start_a_tag(Chtml20* chtml20, Node* node)
833 Doc* doc = chtml20->doc;
834 request_rec* r = doc->r;
837 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<a", NULL);
839 /*--------------------------------------------------------------------------*/
841 /*--------------------------------------------------------------------------*/
842 for (attr = qs_get_attr(doc,node);
844 attr = qs_get_next_attr(doc,attr))
846 char* name = qs_get_attr_name(doc,attr);
847 char* value = qs_get_attr_value(doc,attr);
849 if (strcasecmp(name, "name") == 0)
851 /*----------------------------------------------------------------------*/
853 /*----------------------------------------------------------------------*/
854 chtml20->out = apr_pstrcat(r->pool,
862 if (strcasecmp(name, "href") == 0)
864 /*----------------------------------------------------------------------*/
866 /*----------------------------------------------------------------------*/
867 chtml20->out = apr_pstrcat(r->pool,
875 if (strcasecmp(name, "accesskey") == 0)
877 /*----------------------------------------------------------------------*/
879 /*----------------------------------------------------------------------*/
880 chtml20->out = apr_pstrcat(r->pool,
888 if (strcasecmp(name, "cti") == 0)
890 /*----------------------------------------------------------------------*/
892 /*----------------------------------------------------------------------*/
893 chtml20->out = apr_pstrcat(r->pool,
901 if (strcasecmp(name, "ijam") == 0)
903 /*----------------------------------------------------------------------*/
905 /*----------------------------------------------------------------------*/
909 if (strcasecmp(name, "utn") == 0)
911 /*----------------------------------------------------------------------*/
913 /*----------------------------------------------------------------------*/
917 if (strcasecmp(name, "telbook") == 0)
919 /*----------------------------------------------------------------------*/
921 /*----------------------------------------------------------------------*/
925 if (strcasecmp(name, "kana") == 0)
927 /*----------------------------------------------------------------------*/
929 /*----------------------------------------------------------------------*/
933 if (strcasecmp(name, "email") == 0)
935 /*----------------------------------------------------------------------*/
937 /*----------------------------------------------------------------------*/
941 if (strcasecmp(name, "ista") == 0)
943 /*----------------------------------------------------------------------*/
945 /*----------------------------------------------------------------------*/
949 if (strcasecmp(name, "ilet") == 0)
951 /*----------------------------------------------------------------------*/
953 /*----------------------------------------------------------------------*/
957 if (strcasecmp(name, "iswf") == 0)
959 /*----------------------------------------------------------------------*/
961 /*----------------------------------------------------------------------*/
965 if (strcasecmp(name, "irst") == 0)
967 /*----------------------------------------------------------------------*/
969 /*----------------------------------------------------------------------*/
973 chtml20->out = apr_pstrcat(r->pool, chtml20->out, ">", NULL);
978 * It is a handler who processes the A tag.
980 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
981 * destination is specified.
982 * @param node [i] The A tag node is specified.
983 * @return The conversion result is returned.
986 chtml20_end_a_tag(Chtml20* chtml20, Node* child)
988 Doc* doc = chtml20->doc;
989 request_rec* r = doc->r;
991 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "</a>", NULL);
996 * It is a handler who processes the BR tag.
998 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
999 * destination is specified.
1000 * @param node [i] The BR tag node is specified.
1001 * @return The conversion result is returned.
1004 chtml20_start_br_tag(Chtml20* chtml20, Node* node)
1006 Doc* doc = chtml20->doc;
1007 request_rec* r = doc->r;
1008 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<br>\r\n", NULL);
1009 return chtml20->out;
1013 * It is a handler who processes the BR tag.
1015 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1016 * destination is specified.
1017 * @param node [i] The BR tag node is specified.
1018 * @return The conversion result is returned.
1021 chtml20_end_br_tag(Chtml20* chtml20, Node* child)
1023 return chtml20->out;
1027 * It is a handler who processes the FONT tag.
1029 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1030 * destination is specified.
1031 * @param node [i] The FONT tag node is specified.
1032 * @return The conversion result is returned.
1035 chtml20_start_font_tag(Chtml20* chtml20, Node* node)
1037 Doc* doc = chtml20->doc;
1038 request_rec* r = doc->r;
1041 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<font", NULL);
1043 /*--------------------------------------------------------------------------*/
1044 /* Get Attributes */
1045 /*--------------------------------------------------------------------------*/
1046 for (attr = qs_get_attr(doc,node);
1048 attr = qs_get_next_attr(doc,attr))
1050 char* name = qs_get_attr_name(doc,attr);
1051 char* value = qs_get_attr_value(doc,attr);
1053 if (strcasecmp(name, "color") == 0)
1055 chtml20->out = apr_pstrcat(r->pool,
1063 if (strcasecmp(name, "size") == 0)
1065 /*----------------------------------------------------------------------*/
1067 /*----------------------------------------------------------------------*/
1072 chtml20->out = apr_pstrcat(r->pool, chtml20->out, ">", NULL);
1073 return chtml20->out;
1077 * It is a handler who processes the FONT tag.
1079 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1080 * destination is specified.
1081 * @param node [i] The FONT tag node is specified.
1082 * @return The conversion result is returned.
1085 chtml20_end_font_tag(Chtml20* chtml20, Node* child)
1087 request_rec* r = chtml20->doc->r;
1088 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "</font>", NULL);
1089 return chtml20->out;
1093 * It is a handler who processes the FORM tag.
1095 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1096 * destination is specified.
1097 * @param node [i] The FORM tag node is specified.
1098 * @return The conversion result is returned.
1101 chtml20_start_form_tag(Chtml20* chtml20, Node* node)
1103 Doc* doc = chtml20->doc;
1104 request_rec* r = doc->r;
1107 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<form", NULL);
1109 /*--------------------------------------------------------------------------*/
1110 /* Get Attributes */
1111 /*--------------------------------------------------------------------------*/
1112 for (attr = qs_get_attr(doc,node);
1114 attr = qs_get_next_attr(doc,attr))
1116 char* name = qs_get_attr_name(doc,attr);
1117 char* value = qs_get_attr_value(doc,attr);
1118 if (strcasecmp(name, "action") == 0)
1120 /*----------------------------------------------------------------------*/
1122 /*----------------------------------------------------------------------*/
1123 chtml20->out = apr_pstrcat(r->pool,
1131 if (strcasecmp(name, "method") == 0)
1133 /*----------------------------------------------------------------------*/
1135 /*----------------------------------------------------------------------*/
1136 chtml20->out = apr_pstrcat(r->pool,
1144 if (strcasecmp(name, "utn") == 0)
1146 /*----------------------------------------------------------------------*/
1148 /*----------------------------------------------------------------------*/
1152 chtml20->out = apr_pstrcat(r->pool, chtml20->out, ">", NULL);
1153 return chtml20->out;
1157 * It is a handler who processes the FORM tag.
1159 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1160 * destination is specified.
1161 * @param node [i] The FORM tag node is specified.
1162 * @return The conversion result is returned.
1165 chtml20_end_form_tag(Chtml20* chtml20, Node* child)
1167 Doc* doc = chtml20->doc;
1168 request_rec* r = doc->r;
1170 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "</form>", NULL);
1171 return chtml20->out;
1175 * It is a handler who processes the INPUT tag.
1177 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1178 * destination is specified.
1179 * @param node [i] The INPUT tag node is specified.
1180 * @return The conversion result is returned.
1183 chtml20_start_input_tag(Chtml20* chtml20, Node* node)
1185 Doc* doc = chtml20->doc;
1186 request_rec* r = doc->r;
1187 char* max_length = NULL;
1191 char* istyle = NULL;
1193 char* checked = NULL;
1194 char* accesskey = NULL;
1196 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<input", NULL);
1198 /*--------------------------------------------------------------------------*/
1199 /* Get Attributes */
1200 /*--------------------------------------------------------------------------*/
1202 type = qs_get_type_attr(doc, node, r);
1203 name = qs_get_name_attr(doc, node, r);
1204 value = qs_get_value_attr(doc,node,r);
1205 istyle = qs_get_istyle_attr(doc,node,r);
1206 max_length = qs_get_maxlength_attr(doc,node,r);
1207 checked = qs_get_checked_attr(doc,node,r);
1208 accesskey = qs_get_accesskey_attr(doc, node, r);
1209 size = qs_get_size_attr(doc, node, r);
1213 chtml20->out = apr_pstrcat(r->pool,
1222 chtml20->out = apr_pstrcat(r->pool,
1231 chtml20->out = apr_pstrcat(r->pool,
1240 chtml20->out = apr_pstrcat(r->pool,
1247 if (accesskey != NULL)
1249 chtml20->out = apr_pstrcat(r->pool,
1257 /*------------------------------------------------------------------------*/
1259 /*------------------------------------------------------------------------*/
1260 chtml20->out = apr_pstrcat(r->pool,
1266 /*--------------------------------------------------------------------------*/
1267 /* The figure is default for the password. */
1268 /*--------------------------------------------------------------------------*/
1269 if (max_length != NULL)
1271 if (chxj_chk_numeric(max_length) != 0)
1273 max_length = apr_psprintf(r->pool, "0");
1275 if (istyle != NULL && strcasecmp(istyle, "1") == 0)
1277 chtml20->out = apr_pstrcat(r->pool,
1279 apr_psprintf(r->pool, " maxlength=\"%d\"", chxj_atoi(max_length)*2) , NULL);
1283 chtml20->out = apr_pstrcat(r->pool,
1285 apr_psprintf(r->pool, " maxlength=\"%d\"", chxj_atoi(max_length)) , NULL);
1289 if (checked != NULL)
1291 chtml20->out = apr_pstrcat(r->pool,
1292 chtml20->out, " checked ", NULL);
1295 chtml20->out = apr_pstrcat(r->pool, chtml20->out, " >", NULL);
1296 return chtml20->out;
1300 * It is a handler who processes the INPUT tag.
1302 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1303 * destination is specified.
1304 * @param node [i] The INPUT tag node is specified.
1305 * @return The conversion result is returned.
1308 chtml20_end_input_tag(Chtml20* chtml20, Node* child)
1310 return chtml20->out;
1314 * It is a handler who processes the CENTER tag.
1316 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1317 * destination is specified.
1318 * @param node [i] The CENTER tag node is specified.
1319 * @return The conversion result is returned.
1322 chtml20_start_center_tag(Chtml20* chtml20, Node* node)
1324 Doc* doc = chtml20->doc;
1325 request_rec* r = doc->r;
1327 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<center>", NULL);
1329 return chtml20->out;
1333 * It is a handler who processes the CENTER tag.
1335 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1336 * destination is specified.
1337 * @param node [i] The CENTER tag node is specified.
1338 * @return The conversion result is returned.
1341 chtml20_end_center_tag(Chtml20* chtml20, Node* child)
1343 Doc* doc = chtml20->doc;
1344 request_rec* r = doc->r;
1346 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "</center>", NULL);
1348 return chtml20->out;
1352 * It is a handler who processes the HR tag.
1354 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1355 * destination is specified.
1356 * @param node [i] The HR tag node is specified.
1357 * @return The conversion result is returned.
1360 chtml20_start_hr_tag(Chtml20* chtml20, Node* node)
1362 Doc* doc = chtml20->doc;
1363 request_rec* r = doc->r;
1366 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<hr ", NULL);
1368 for (attr = qs_get_attr(doc,node);
1370 attr = qs_get_next_attr(doc,attr))
1372 char* name = qs_get_attr_name(doc,attr);
1373 char* value = qs_get_attr_value(doc,attr);
1374 if (strcasecmp(name, "align") == 0)
1376 /*----------------------------------------------------------------------*/
1378 /*----------------------------------------------------------------------*/
1379 chtml20->out = apr_pstrcat(r->pool,
1381 " align=\"", value, "\" ", NULL);
1384 if (strcasecmp(name, "size") == 0)
1386 /*----------------------------------------------------------------------*/
1388 /*----------------------------------------------------------------------*/
1389 chtml20->out = apr_pstrcat(r->pool,
1391 " size=\"", value, "\" ", NULL);
1394 if (strcasecmp(name, "width") == 0)
1396 /*----------------------------------------------------------------------*/
1398 /*----------------------------------------------------------------------*/
1399 chtml20->out = apr_pstrcat(r->pool,
1401 " width=\"", value, "\" ", NULL);
1404 if (strcasecmp(name, "noshade") == 0)
1406 /*----------------------------------------------------------------------*/
1408 /*----------------------------------------------------------------------*/
1409 chtml20->out = apr_pstrcat(r->pool,
1414 if (strcasecmp(name, "color") == 0)
1416 /*----------------------------------------------------------------------*/
1418 /*----------------------------------------------------------------------*/
1422 chtml20->out = apr_pstrcat(r->pool, chtml20->out, " >", NULL);
1424 return chtml20->out;
1428 * It is a handler who processes the HR tag.
1430 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1431 * destination is specified.
1432 * @param node [i] The HR tag node is specified.
1433 * @return The conversion result is returned.
1436 chtml20_end_hr_tag(Chtml20* chtml20, Node* child)
1438 return chtml20->out;
1442 * It is a handler who processes the IMG tag.
1444 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1445 * destination is specified.
1446 * @param node [i] The IMG tag node is specified.
1447 * @return The conversion result is returned.
1450 chtml20_start_img_tag(Chtml20* chtml20, Node* node)
1452 Doc* doc = chtml20->doc;
1453 request_rec* r = doc->r;
1455 #ifndef IMG_NOT_CONVERT_FILENAME
1456 device_table* spec = chtml20->spec;
1459 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<img", NULL);
1462 /*--------------------------------------------------------------------------*/
1463 /* Get Attributes */
1464 /*--------------------------------------------------------------------------*/
1465 for (attr = qs_get_attr(doc,node);
1467 attr = qs_get_next_attr(doc,attr))
1469 char* name = qs_get_attr_name(doc,attr);
1470 char* value = qs_get_attr_value(doc,attr);
1472 if (strcasecmp(name, "src") == 0)
1474 /*----------------------------------------------------------------------*/
1476 /*----------------------------------------------------------------------*/
1477 #ifdef IMG_NOT_CONVERT_FILENAME
1478 chtml20->out = apr_pstrcat(r->pool,
1479 chtml20->out, " src=\"",value,"\"", NULL);
1481 chtml20->out = apr_pstrcat(r->pool,
1482 chtml20->out, " src=\"",
1483 chxj_img_conv(r, spec,value), NULL);
1484 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "\"", NULL);
1488 if (strcasecmp(name, "align" ) == 0)
1490 /*----------------------------------------------------------------------*/
1492 /*----------------------------------------------------------------------*/
1493 chtml20->out = apr_pstrcat(r->pool,
1494 chtml20->out, " align=\"",value,"\"", NULL);
1497 if (strcasecmp(name, "width" ) == 0)
1499 /*----------------------------------------------------------------------*/
1501 /*----------------------------------------------------------------------*/
1502 chtml20->out = apr_pstrcat(r->pool,
1503 chtml20->out, " width=\"",value,"\"", NULL);
1506 if (strcasecmp(name, "height") == 0)
1508 /*----------------------------------------------------------------------*/
1510 /*----------------------------------------------------------------------*/
1511 chtml20->out = apr_pstrcat(r->pool,
1512 chtml20->out, " height=\"",value,"\"", NULL);
1515 if (strcasecmp(name, "hspace") == 0)
1517 /*----------------------------------------------------------------------*/
1519 /*----------------------------------------------------------------------*/
1520 chtml20->out = apr_pstrcat(r->pool,
1521 chtml20->out, " hspace=\"",value,"\"", NULL);
1524 if (strcasecmp(name, "vspace") == 0)
1526 /*----------------------------------------------------------------------*/
1528 /*----------------------------------------------------------------------*/
1529 chtml20->out = apr_pstrcat(r->pool,
1530 chtml20->out, " vspace=\"",value,"\"", NULL);
1533 if (strcasecmp(name, "alt" ) == 0)
1535 /*----------------------------------------------------------------------*/
1537 /*----------------------------------------------------------------------*/
1538 chtml20->out = apr_pstrcat(r->pool,
1539 chtml20->out, " alt=\"",value,"\"", NULL);
1542 if (strcasecmp(name, "align" ) == 0)
1544 /*----------------------------------------------------------------------*/
1546 /*----------------------------------------------------------------------*/
1551 chtml20->out = apr_pstrcat(r->pool, chtml20->out, ">", NULL);
1553 return chtml20->out;
1557 * It is a handler who processes the IMG tag.
1559 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1560 * destination is specified.
1561 * @param node [i] The IMG tag node is specified.
1562 * @return The conversion result is returned.
1565 chtml20_end_img_tag(Chtml20* chtml20, Node* child)
1567 return chtml20->out;
1571 * It is a handler who processes the SELECT tag.
1573 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1574 * destination is specified.
1575 * @param node [i] The SELECT tag node is specified.
1576 * @return The conversion result is returned.
1579 chtml20_start_select_tag(Chtml20* chtml20, Node* child)
1581 Doc* doc = chtml20->doc;
1582 request_rec* r = doc->r;
1588 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<select", NULL);
1589 for (attr = qs_get_attr(doc,child);
1591 attr = qs_get_next_attr(doc,attr))
1593 char* nm = qs_get_attr_name(doc,attr);
1594 char* val = qs_get_attr_value(doc,attr);
1596 if (strcasecmp(nm, "size") == 0)
1598 /*----------------------------------------------------------------------*/
1599 /* CHTML 1.0 version 2.0 */
1600 /*----------------------------------------------------------------------*/
1601 size = apr_pstrdup(r->pool, val);
1604 if (strcasecmp(nm, "name") == 0)
1606 /*----------------------------------------------------------------------*/
1607 /* CHTML 1.0 version 2.0 */
1608 /*----------------------------------------------------------------------*/
1609 name = apr_pstrdup(r->pool, val);
1612 if (strcasecmp(nm, "multiple") == 0)
1614 /*----------------------------------------------------------------------*/
1615 /* CHTML 1.0 version 2.0 */
1616 /*----------------------------------------------------------------------*/
1623 chtml20->out = apr_pstrcat(r->pool, chtml20->out, " size=\"",size,"\"", NULL);
1627 chtml20->out = apr_pstrcat(r->pool, chtml20->out, " name=\"",name,"\"", NULL);
1629 chtml20->out = apr_pstrcat(r->pool, chtml20->out, ">\n", NULL);
1630 return chtml20->out;
1634 * It is a handler who processes the SELECT tag.
1636 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1637 * destination is specified.
1638 * @param node [i] The SELECT tag node is specified.
1639 * @return The conversion result is returned.
1642 chtml20_end_select_tag(Chtml20* chtml20, Node* child)
1644 Doc* doc = chtml20->doc;
1645 request_rec* r = doc->r;
1647 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "</select>\n", NULL);
1648 return chtml20->out;
1652 * It is a handler who processes the OPTION tag.
1654 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1655 * destination is specified.
1656 * @param node [i] The OPTION tag node is specified.
1657 * @return The conversion result is returned.
1660 chtml20_start_option_tag(Chtml20* chtml20, Node* child)
1662 Doc* doc = chtml20->doc;
1663 request_rec* r = doc->r;
1666 char* selected = NULL;
1669 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<option", NULL);
1670 for (attr = qs_get_attr(doc,child);
1672 attr = qs_get_next_attr(doc,attr))
1674 char* nm = qs_get_attr_name(doc,attr);
1675 char* val = qs_get_attr_value(doc,attr);
1677 if (strcasecmp(nm, "selected") == 0)
1679 /*----------------------------------------------------------------------*/
1680 /* CHTML 1.0 version 2.0 */
1681 /*----------------------------------------------------------------------*/
1682 selected = apr_pstrdup(r->pool, val);
1685 if (strcasecmp(nm, "value") == 0)
1687 /*----------------------------------------------------------------------*/
1688 /* CHTML 1.0 version 2.0 */
1689 /*----------------------------------------------------------------------*/
1690 value = apr_pstrdup(r->pool, val);
1696 chtml20->out = apr_pstrcat(r->pool, chtml20->out, " value=\"",value,"\"", NULL);
1700 chtml20->out = apr_pstrcat(r->pool, chtml20->out, " value=\"\"", NULL);
1703 if (selected != NULL)
1705 chtml20->out = apr_pstrcat(r->pool, chtml20->out, " selected ", NULL);
1708 chtml20->out = apr_pstrcat(r->pool, chtml20->out, ">", NULL);
1709 return chtml20->out;
1713 * It is a handler who processes the OPTION tag.
1715 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1716 * destination is specified.
1717 * @param node [i] The OPTION tag node is specified.
1718 * @return The conversion result is returned.
1721 chtml20_end_option_tag(Chtml20* chtml20, Node* child)
1724 return chtml20->out;
1728 * It is a handler who processes the DIV tag.
1730 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1731 * destination is specified.
1732 * @param node [i] The DIV tag node is specified.
1733 * @return The conversion result is returned.
1736 chtml20_start_div_tag(Chtml20* chtml20, Node* child)
1738 Doc* doc = chtml20->doc;
1739 request_rec* r = doc->r;
1744 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "<div", NULL);
1745 for (attr = qs_get_attr(doc,child);
1747 attr = qs_get_next_attr(doc,attr))
1749 char* nm = qs_get_attr_name(doc,attr);
1750 char* val = qs_get_attr_value(doc,attr);
1752 if (strcasecmp(nm, "align") == 0)
1754 /*----------------------------------------------------------------------*/
1755 /* CHTML 1.0 (W3C version 3.2) */
1756 /*----------------------------------------------------------------------*/
1757 align = apr_pstrdup(r->pool, val);
1763 chtml20->out = apr_pstrcat(r->pool,
1764 chtml20->out, " align=\"", align, "\"", NULL);
1767 chtml20->out = apr_pstrcat(r->pool, chtml20->out, ">", NULL);
1768 return chtml20->out;
1772 * It is a handler who processes the DIV tag.
1774 * @param chtml20 [i/o] The pointer to the CHTML structure at the output
1775 * destination is specified.
1776 * @param node [i] The DIV tag node is specified.
1777 * @return The conversion result is returned.
1780 chtml20_end_div_tag(Chtml20* chtml20, Node* child)
1782 Doc* doc = chtml20->doc;
1783 request_rec* r = doc->r;
1785 chtml20->out = apr_pstrcat(r->pool, chtml20->out, "</div>\n", NULL);
1787 return chtml20->out;
1792 chtml20_chxjif_tag(Chtml20* chtml20, Node* node)
1794 Doc* doc = chtml20->doc;
1796 request_rec* r = doc->r;
1798 for (child = qs_get_child_node(doc, node);
1800 child = qs_get_next_node(doc, child))
1802 chtml20->out = apr_pstrcat(r->pool, chtml20->out, child->otext, NULL);
1803 chtml20_chxjif_tag(chtml20, child);