OSDN Git Service

*** empty log message ***
[modchxj/mod_chxj.git] / src / chxj_jhtml.c
1 /*
2  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
3  * Copyright (C) 2005 Atsushi Konno All rights reserved.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17 #include "chxj_jhtml.h"
18 #include "chxj_hdml.h"
19 #include "chxj_dump.h"
20 #include "chxj_img_conv.h"
21 #include "chxj_qr_code.h"
22
23 static char* s_jhtml_node_exchange    (jhtml_t* jhtml, Node* node, int indent);
24 static char* s_jhtml_start_html_tag   (jhtml_t* jhtml, Node* child);
25 static char* s_jhtml_end_html_tag     (jhtml_t* jhtml, Node* child);
26 static char* s_jhtml_start_meta_tag   (jhtml_t* jhtml, Node* node);
27 static char* s_jhtml_end_meta_tag     (jhtml_t* jhtml, Node* node);
28 static char* s_jhtml_start_head_tag   (jhtml_t* jhtml, Node* node);
29 static char* s_jhtml_end_head_tag     (jhtml_t* jhtml, Node* node);
30 static char* s_jhtml_start_title_tag  (jhtml_t* jhtml, Node* node);
31 static char* s_jhtml_end_title_tag    (jhtml_t* jhtml, Node* node);
32 static char* s_jhtml_start_base_tag   (jhtml_t* jhtml, Node* node);
33 static char* s_jhtml_end_base_tag     (jhtml_t* jhtml, Node* node);
34 static char* s_jhtml_start_body_tag   (jhtml_t* jhtml, Node* node);
35 static char* s_jhtml_end_body_tag     (jhtml_t* jhtml, Node* node);
36 static char* s_jhtml_start_a_tag      (jhtml_t* jhtml, Node* node);
37 static char* s_jhtml_end_a_tag        (jhtml_t* jhtml, Node* node);
38 static char* s_jhtml_start_ul_tag     (jhtml_t* jhtml, Node* node);
39 static char* s_jhtml_end_ul_tag       (jhtml_t* jhtml, Node* node);
40 static char* s_jhtml_start_ol_tag     (jhtml_t* jhtml, Node* node);
41 static char* s_jhtml_end_ol_tag       (jhtml_t* jhtml, Node* node);
42 static char* s_jhtml_start_li_tag     (jhtml_t* jhtml, Node* node);
43 static char* s_jhtml_end_li_tag       (jhtml_t* jhtml, Node* node);
44 static char* s_jhtml_start_br_tag     (jhtml_t* jhtml, Node* node);
45 static char* s_jhtml_end_br_tag       (jhtml_t* jhtml, Node* node);
46 static char* s_jhtml_start_tr_tag     (jhtml_t* jhtml, Node* node);
47 static char* s_jhtml_end_tr_tag       (jhtml_t* jhtml, Node* node);
48 static char* s_jhtml_start_font_tag   (jhtml_t* jhtml, Node* node);
49 static char* s_jhtml_end_font_tag     (jhtml_t* jhtml, Node* node);
50 static char* s_jhtml_start_form_tag   (jhtml_t* jhtml, Node* node);
51 static char* s_jhtml_end_form_tag     (jhtml_t* jhtml, Node* node);
52 static char* s_jhtml_start_input_tag  (jhtml_t* jhtml, Node* node);
53 static char* s_jhtml_end_input_tag    (jhtml_t* jhtml, Node* node);
54 static char* s_jhtml_start_center_tag (jhtml_t* jhtml, Node* node);
55 static char* s_jhtml_end_center_tag   (jhtml_t* jhtml, Node* node);
56 static char* s_jhtml_start_hr_tag     (jhtml_t* jhtml, Node* node);
57 static char* s_jhtml_end_hr_tag       (jhtml_t* jhtml, Node* node);
58 static char* s_jhtml_start_img_tag    (jhtml_t* jhtml, Node* node);
59 static char* s_jhtml_end_img_tag      (jhtml_t* jhtml, Node* node);
60 static char* s_jhtml_start_select_tag (jhtml_t* jhtml, Node* node);
61 static char* s_jhtml_end_select_tag   (jhtml_t* jhtml, Node* node);
62 static char* s_jhtml_start_option_tag (jhtml_t* jhtml, Node* node);
63 static char* s_jhtml_end_option_tag   (jhtml_t* jhtml, Node* node);
64 static char* s_jhtml_start_div_tag    (jhtml_t* jhtml, Node* node);
65 static char* s_jhtml_end_div_tag      (jhtml_t* jhtml, Node* node);
66 static void  s_init_jhtml(jhtml_t* jhtml, Doc* doc, request_rec* r, device_table_t* spec);
67 static int   s_jhtml_search_emoji(jhtml_t* jhtml, char* txt, char** rslt);
68 static char* chxj_istyle_to_mode(request_rec* r, const char* s);
69 static void  s_jhtml_chxjif_tag(jhtml_t* jhtml, Node* node); 
70
71 /**
72  * converts from CHTML5.0 to JHTML.
73  *
74  * @param r     [i]   Requet_rec is appointed.
75  * @param spec  [i]   The result of the device specification processing which 
76  *                    was done in advance is appointed.
77  * @param src   [i]   The character string before the converting is appointed.
78  * @return The character string after the converting is returned.
79  */
80 char*
81 chxj_exchange_jhtml(
82   request_rec* r,
83   device_table_t* spec,
84   const char* src,
85   apr_size_t srclen,
86   apr_size_t *dstlen)
87 {
88   char*     dst = NULL;
89   char*     ss;
90   jhtml_t   jhtml;
91   Doc       doc;
92
93   /*--------------------------------------------------------------------------*/
94   /* If qrcode xml                                                            */
95   /*--------------------------------------------------------------------------*/
96   *dstlen = srclen;
97   dst = chxj_qr_code_blob_handler(r, src, (size_t*)dstlen);
98   if (dst) {
99     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,"i found qrcode xml");
100     return dst;
101   }
102   ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,"not found qrcode xml");
103
104   /*--------------------------------------------------------------------------*/
105   /* The CHTML structure is initialized.                                      */
106   /*--------------------------------------------------------------------------*/
107   s_init_jhtml(&jhtml, &doc, r, spec);
108   ap_set_content_type(r, "text/html; charset=Windows-31J");
109
110   /*--------------------------------------------------------------------------*/
111   /* The character string of the input is analyzed.                           */
112   /*--------------------------------------------------------------------------*/
113   qs_init_malloc(&doc);
114   qs_init_root_node(&doc);
115
116   ss = apr_pcalloc(r->pool, srclen + 1);
117   memset(ss, 0, srclen + 1);
118   memcpy(ss, src, srclen);
119 #ifdef DUMP_LOG
120   chxj_dump_out("[src] CHTML -> JHTML", ss, srclen);
121 #endif
122   qs_parse_string(&doc,ss,strlen(ss));
123
124   /*--------------------------------------------------------------------------*/
125   /* It converts it from CHTML to JHTML.                                      */
126   /*--------------------------------------------------------------------------*/
127   dst = s_jhtml_node_exchange(&jhtml, qs_get_root(&doc), 0);
128   qs_all_free(&doc,QX_LOGMARK);
129
130   if (dst == NULL) 
131     return apr_pstrdup(r->pool,ss);
132
133   if (strlen(dst) == 0) 
134     dst = apr_psprintf(r->pool, "\n");
135
136   *dstlen = strlen(dst);
137 #ifdef DUMP_LOG
138   chxj_dump_out("[dst] CHTML -> JHTML", dst, *dstlen);
139 #endif
140
141   return dst;
142 }
143
144 /**
145  * The CHTML structure is initialized.
146  *
147  * @param jhtml [i/o] The pointer to the JHTML structure that wants to be
148  *                   initialized is specified.
149  * @param doc   [i]   The Doc structure that should be set to the initialized
150  *                   JHTML structure is specified.
151  * @param r     [i]   To use POOL, the pointer to request_rec is specified.
152  * @param spec  [i]   The pointer to the device_table
153  */
154 static void
155 s_init_jhtml(jhtml_t* jhtml, Doc* doc, request_rec* r, device_table_t* spec)
156 {
157   memset(doc,   0, sizeof(Doc));
158   memset(jhtml, 0, sizeof(jhtml_t));
159
160   doc->r      = r;
161   jhtml->doc  = doc;
162   jhtml->spec = spec;
163   jhtml->out  = qs_alloc_zero_byte_string(r);
164   jhtml->conf = ap_get_module_config(r->per_dir_config, &chxj_module);
165   jhtml->doc->parse_mode = PARSE_MODE_CHTML;
166 }
167
168 /**
169  * It is main processing of conversion from CHTML to JHTML. 
170  *
171  * @param jhtml   [i/o] The pointer to the CHTML structure is specified. 
172  * @param node    [i]   The pointer to a current node is specified. 
173  * @param indent  [i]   The depth of the node processing it now is specified. 
174  *
175  * @return The character string after it converts it is returned. 
176  */
177 static char*
178 s_jhtml_node_exchange(jhtml_t* jhtml, Node* node, int indent) 
179 {
180   Node*         child;
181   Doc*          doc   = jhtml->doc;
182   request_rec*  r     = doc->r;
183
184   /*--------------------------------------------------------------------------*/
185   /* It is the main loop of the conversion processing.                        */
186   /*--------------------------------------------------------------------------*/
187   for (child = qs_get_child_node(doc,node);
188        child ;
189        child = qs_get_next_node(doc,child)) {
190     char* name = qs_get_node_name(doc,child);
191
192     /*------------------------------------------------------------------------*/
193     /* <UL> (for TEST)                                                        */
194     /*------------------------------------------------------------------------*/
195     if ((*name == 'u' || *name == 'U') && strcasecmp(name, "ul") == 0) {
196       s_jhtml_start_ul_tag  (jhtml, child);
197       s_jhtml_node_exchange (jhtml, child, indent+1);
198       s_jhtml_end_ul_tag    (jhtml, child);
199     }
200     /*------------------------------------------------------------------------*/
201     /* <LI> (for TEST)                                                        */
202     /*------------------------------------------------------------------------*/
203     else
204     if ((*name == 'l' || *name == 'L') && strcasecmp(name, "li") == 0) {
205       s_jhtml_start_li_tag  (jhtml, child);
206       s_jhtml_node_exchange (jhtml, child, indent+1);
207       s_jhtml_end_li_tag    (jhtml, child);
208     }
209     /*------------------------------------------------------------------------*/
210     /* <OL> (for TEST)                                                        */
211     /*------------------------------------------------------------------------*/
212     else
213     if ((*name == 'o' || *name == 'O') && strcasecmp(name, "ol") == 0) {
214       s_jhtml_start_ol_tag  (jhtml, child);
215       s_jhtml_node_exchange (jhtml, child, indent+1);
216       s_jhtml_end_ol_tag    (jhtml, child);
217     }
218     else
219     if (*name == 'h' || *name == 'H') { 
220       /*----------------------------------------------------------------------*/
221       /* <HTML>                                                               */
222       /*----------------------------------------------------------------------*/
223       if (strcasecmp(name, "html") == 0) {
224         s_jhtml_start_html_tag(jhtml, child);
225         s_jhtml_node_exchange (jhtml, child,indent+1);
226         s_jhtml_end_html_tag  (jhtml, child);
227       }
228       /*----------------------------------------------------------------------*/
229       /* <HEAD>                                                               */
230       /*----------------------------------------------------------------------*/
231       else
232       if (strcasecmp(name, "head") == 0) {
233         s_jhtml_start_head_tag(jhtml, child);
234         s_jhtml_node_exchange (jhtml, child,indent+1);
235         s_jhtml_end_head_tag  (jhtml, child);
236       }
237       /*----------------------------------------------------------------------*/
238       /* <HR>                                                                 */
239       /*----------------------------------------------------------------------*/
240       else
241       if (strcasecmp(name, "hr") == 0) {
242         s_jhtml_start_hr_tag  (jhtml, child);
243         s_jhtml_end_hr_tag    (jhtml, child);
244       }
245     }
246     /*------------------------------------------------------------------------*/
247     /* <META>                                                                 */
248     /*------------------------------------------------------------------------*/
249     else
250     if ((*name == 'm' || *name == 'M') && strcasecmp(name, "meta") == 0) {
251       s_jhtml_start_meta_tag(jhtml, child);
252       s_jhtml_end_meta_tag  (jhtml, child);
253     }
254     else
255     if (*name == 'b' || *name == 'B') {
256       /*----------------------------------------------------------------------*/
257       /* <BASE>                                                               */
258       /*----------------------------------------------------------------------*/
259       if (strcasecmp(name, "base") == 0) {
260         s_jhtml_start_base_tag(jhtml, child);
261         s_jhtml_end_base_tag  (jhtml, child);
262       }
263       /*----------------------------------------------------------------------*/
264       /* <BODY>                                                               */
265       /*----------------------------------------------------------------------*/
266       else
267       if (strcasecmp(name, "body") == 0) {
268         s_jhtml_start_body_tag(jhtml, child);
269         s_jhtml_node_exchange (jhtml, child,indent+1);
270         s_jhtml_end_body_tag  (jhtml, child);
271       }
272       /*----------------------------------------------------------------------*/
273       /* <BR>                                                                 */
274       /*----------------------------------------------------------------------*/
275       else 
276       if (strcasecmp(name, "br") == 0) {
277         s_jhtml_start_br_tag  (jhtml, child);
278         s_jhtml_node_exchange (jhtml, child,indent+1);
279         s_jhtml_end_br_tag    (jhtml, child);
280       }
281     }
282     /*------------------------------------------------------------------------*/
283     /* <A>                                                                    */
284     /*------------------------------------------------------------------------*/
285     else
286     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "a") == 0) {
287       s_jhtml_start_a_tag   (jhtml, child);
288       s_jhtml_node_exchange (jhtml, child,indent+1);
289       s_jhtml_end_a_tag     (jhtml, child);
290     }
291     else
292     if (*name == 'f' || *name == 'F') {
293       /*----------------------------------------------------------------------*/
294       /* <FONT>                                                               */
295       /*----------------------------------------------------------------------*/
296       if (strcasecmp(name, "font") == 0) {
297         s_jhtml_start_font_tag(jhtml, child);
298         s_jhtml_node_exchange (jhtml, child,indent+1);
299         s_jhtml_end_font_tag  (jhtml, child);
300       }
301       /*----------------------------------------------------------------------*/
302       /* <FORM>                                                               */
303       /*----------------------------------------------------------------------*/
304       else
305       if (strcasecmp(name, "form") == 0) {
306         s_jhtml_start_form_tag(jhtml, child);
307         s_jhtml_node_exchange (jhtml, child,indent+1);
308         s_jhtml_end_form_tag  (jhtml, child);
309       }
310     }
311     else
312     if (*name == 'i' || *name == 'I') {
313       /*----------------------------------------------------------------------*/
314       /* <INPUT>                                                              */
315       /*----------------------------------------------------------------------*/
316       if (strcasecmp(name, "input") == 0) {
317         s_jhtml_start_input_tag (jhtml, child);
318         s_jhtml_node_exchange   (jhtml, child,indent+1);
319         s_jhtml_end_input_tag   (jhtml, child);
320       }
321       /*----------------------------------------------------------------------*/
322       /* <IMG>                                                                */
323       /*----------------------------------------------------------------------*/
324       else
325       if (strcasecmp(name, "img") == 0) {
326         s_jhtml_start_img_tag (jhtml, child);
327         s_jhtml_end_img_tag   (jhtml, child);
328       }
329     }
330     else
331     if (*name == 's' || *name == 'S') {
332       /*----------------------------------------------------------------------*/
333       /* <SELECT>                                                             */
334       /*----------------------------------------------------------------------*/
335       if (strcasecmp(name, "select") == 0) {
336         s_jhtml_start_select_tag(jhtml, child);
337         s_jhtml_node_exchange   (jhtml, child, indent+1);
338         s_jhtml_end_select_tag  (jhtml, child);
339       }
340       /*----------------------------------------------------------------------*/
341       /* <STYLE> (for TEST)                                                   */
342       /*----------------------------------------------------------------------*/
343       else
344       if (strcasecmp(name, "style") == 0) {
345         s_jhtml_node_exchange (jhtml, child, indent+1);
346       }
347       /*----------------------------------------------------------------------*/
348       /* <SPAN> (for TEST)                                                    */
349       /*----------------------------------------------------------------------*/
350       else
351       if (strcasecmp(name, "span") == 0) {
352         s_jhtml_node_exchange (jhtml, child, indent+1);
353       }
354     }
355     /*------------------------------------------------------------------------*/
356     /* <OPTION>                                                               */
357     /*------------------------------------------------------------------------*/
358     else
359     if ((*name == 'o' || *name == 'O')
360     &&  strcasecmp(name, "option") == 0) {
361       s_jhtml_start_option_tag(jhtml, child);
362       s_jhtml_node_exchange   (jhtml, child, indent+1);
363       s_jhtml_end_option_tag  (jhtml, child);
364     }
365     /*------------------------------------------------------------------------*/
366     /* <DIV>                                                                  */
367     /*------------------------------------------------------------------------*/
368     else
369     if ((*name == 'd' || *name == 'D')
370     &&  strcasecmp(name, "div") == 0) {
371       s_jhtml_start_div_tag (jhtml, child);
372       s_jhtml_node_exchange (jhtml, child, indent+1);
373       s_jhtml_end_div_tag   (jhtml, child);
374     }
375     /*------------------------------------------------------------------------*/
376     /* <BLINK>                                                                */
377     /*------------------------------------------------------------------------*/
378     else
379     if ((*name == 'b' || *name == 'B')
380     && strcasecmp(name, "blink") == 0) {
381       /* ignore */
382     }
383     /*------------------------------------------------------------------------*/
384     /* <CENTER>                                                               */
385     /*------------------------------------------------------------------------*/
386     else
387     if (*name == 'c' || *name == 'C') {
388       if (strcasecmp(name, "center") == 0) {
389         s_jhtml_start_center_tag(jhtml, child);
390         s_jhtml_node_exchange   (jhtml, child,indent+1);
391         s_jhtml_end_center_tag  (jhtml, child);
392       }
393       /*----------------------------------------------------------------------*/
394       /* <CHXJ:IF>                                                            */
395       /*----------------------------------------------------------------------*/
396       else
397       if (strcasecmp(name, "chxj:if") == 0) {
398         ap_log_rerror(APLOG_MARK, APLOG_DEBUG,0,r, "chxj:if tag found");
399         if (chxj_chxjif_is_mine(jhtml->spec, doc, child)) {
400           ap_log_rerror(APLOG_MARK, APLOG_DEBUG,0,r, "chxj:if tag is mine");
401   
402           char* parse_attr = NULL;
403           parse_attr = qs_get_parse_attr(doc, child, r);
404           if (parse_attr != NULL && strcasecmp(parse_attr, "true") == 0) {
405             s_jhtml_node_exchange (jhtml, child, indent+1);
406           }
407           else {
408             s_jhtml_chxjif_tag(jhtml, child);
409           }
410         }
411       }
412     }
413     else
414     if (*name == 't' || *name == 'T') {
415       /*------------------------------------------------------------------------*/
416       /* <TITLE>                                                                */
417       /*------------------------------------------------------------------------*/
418       if (strcasecmp(name, "title") == 0) {
419         s_jhtml_start_title_tag (jhtml, child);
420         s_jhtml_node_exchange   (jhtml, child,indent+1);
421         s_jhtml_end_title_tag   (jhtml, child);
422       }
423       /*------------------------------------------------------------------------*/
424       /* <TABLE> (for TEST)                                                     */
425       /*------------------------------------------------------------------------*/
426       else
427       if (strcasecmp(name, "table") == 0) {
428         s_jhtml_node_exchange (jhtml, child, indent+1);
429       }
430       /*------------------------------------------------------------------------*/
431       /* <TBODY> (for TEST)                                                     */
432       /*------------------------------------------------------------------------*/
433       else
434       if (strcasecmp(name, "tbody") == 0) {
435         s_jhtml_node_exchange (jhtml, child, indent+1);
436       }
437       /*------------------------------------------------------------------------*/
438       /* <TH> (for TEST)                                                        */
439       /*------------------------------------------------------------------------*/
440       else
441       if (strcasecmp(name, "th") == 0) {
442         s_jhtml_node_exchange (jhtml, child, indent+1);
443       }
444       /*------------------------------------------------------------------------*/
445       /* <TR> (for TEST)                                                        */
446       /*------------------------------------------------------------------------*/
447       else
448       if (strcasecmp(name, "tr") == 0) {
449         s_jhtml_start_tr_tag  (jhtml, child);
450         s_jhtml_node_exchange (jhtml, child,indent+1);
451         s_jhtml_end_tr_tag    (jhtml, child);
452       }
453       /*------------------------------------------------------------------------*/
454       /* <TD> (for TEST)                                                        */
455       /*------------------------------------------------------------------------*/
456       else
457       if (strcasecmp(name, "td") == 0) {
458         s_jhtml_node_exchange (jhtml, child, indent+1);
459       }
460       /*------------------------------------------------------------------------*/
461       /* NORMAL TEXT                                                            */
462       /*------------------------------------------------------------------------*/
463       else
464       if (strcasecmp(name, "text") == 0) {
465         char*   textval;
466         char*   tmp;
467         char*   tdst;
468         char    one_byte[2];
469         int     ii;
470         int     tdst_len;
471   
472         textval = qs_get_node_value(doc,child);
473         textval = qs_trim_string(jhtml->doc->r, textval);
474         if (strlen(textval) == 0)
475           continue;
476   
477         tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
478         memset(tmp, 0, qs_get_node_size(doc,child)+1);
479   
480         tdst     = qs_alloc_zero_byte_string(r);
481         memset(one_byte, 0, sizeof(one_byte));
482         tdst_len = 0;
483   
484         for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
485           char* out;
486           int rtn = s_jhtml_search_emoji(jhtml, &textval[ii], &out);
487           if (rtn) {
488             tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
489             ii+=(rtn - 1);
490             continue;
491           }
492
493           if (is_sjis_kanji(textval[ii])) {
494             one_byte[0] = textval[ii+0];
495             tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
496             one_byte[0] = textval[ii+1];
497             tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
498             ii++;
499           }
500           else 
501           if (textval[ii] != '\r' && textval[ii] != '\n') {
502             one_byte[0] = textval[ii+0];
503             tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
504           }
505         }
506         jhtml->out = apr_pstrcat(r->pool, jhtml->out, tdst, NULL);
507       }
508     }
509   }
510   return jhtml->out;
511 }
512
513 /**
514  * Corresponding EMOJI to a current character-code is retrieved. 
515  * The substitution character string is stored in the rslt pointer if agreeing.
516  *
517  * @param jhtml   [i]   The pointer to the CHTML structure is specified. 
518  * @param txt     [i]   The character string to want to examine whether it is 
519  *                      EMOJI is specified. 
520  * @param rslt    [o]   The pointer to the pointer that stores the result is 
521  *                      specified. 
522  * @return When corresponding EMOJI exists, it returns it excluding 0. 
523  */
524 static int
525 s_jhtml_search_emoji(jhtml_t* jhtml, char* txt, char** rslt)
526 {
527   emoji_t*      ee;
528   request_rec*  r;
529   device_table_t* spec;
530   int           len;
531
532   spec = jhtml->spec;
533
534   len = strlen(txt);
535   r = jhtml->doc->r;
536
537   if (spec == NULL)
538     ap_log_rerror(APLOG_MARK, APLOG_DEBUG,0,r, "spec is NULL");
539
540   for (ee = jhtml->conf->emoji;
541        ee;
542        ee = ee->next) {
543     unsigned char hex1byte;
544     unsigned char hex2byte;
545     if (ee->imode == NULL) {
546       ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
547                       "emoji->imode is NULL");
548       continue;
549     }
550     hex1byte = ee->imode->hex1byte & 0xff;
551     hex2byte = ee->imode->hex2byte & 0xff;
552
553     if (ee->imode->string != NULL
554     &&  strlen(ee->imode->string) > 0
555     &&  strncasecmp(ee->imode->string, txt, strlen(ee->imode->string)) == 0) {
556       if (spec == NULL || spec->emoji_type == NULL) {
557         *rslt = apr_psprintf(r->pool,"\e%s\ f", ee->jphone->string);
558         return strlen(ee->imode->string);
559       }
560
561       return 0;
562     }
563     if (len >= 2
564     && ((unsigned char)txt[0] & 0xff) == ((unsigned char)hex1byte)
565     && ((unsigned char)txt[1] & 0xff) == ((unsigned char)hex2byte)) {
566       if (spec == NULL || spec->emoji_type == NULL) {
567         *rslt = apr_psprintf(r->pool,"\e%s\ f", ee->jphone->string);
568         return 2;
569       }
570
571       return 0;
572     }
573   }
574   return 0;
575 }
576
577 /**
578  * It is a handler who processes the HTML tag.
579  *
580  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
581  *                     destination is specified.
582  * @param node   [i]   The HTML tag node is specified.
583  * @return The conversion result is returned.
584  */
585 static char*
586 s_jhtml_start_html_tag(jhtml_t* jhtml, Node* node) 
587 {
588   Doc*          doc   = jhtml->doc;
589   request_rec*  r     = doc->r;
590
591   /*--------------------------------------------------------------------------*/
592   /* start HTML tag                                                           */
593   /*--------------------------------------------------------------------------*/
594   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<html>\n", NULL);
595
596   return jhtml->out;
597 }
598
599 /**
600  * It is a handler who processes the HTML tag.
601  *
602  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
603  *                     destination is specified.
604  * @param node   [i]   The HTML tag node is specified.
605  * @return The conversion result is returned.
606  */
607 static char*
608 s_jhtml_end_html_tag(jhtml_t* jhtml, Node* child) 
609 {
610   Doc*          doc = jhtml->doc;
611   request_rec*  r   = doc->r;
612
613   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</html>\n", NULL);
614
615   return jhtml->out;
616 }
617
618 /**
619  * It is a handler who processes the META tag.
620  *
621  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
622  *                     destination is specified.
623  * @param node   [i]   The META tag node is specified.
624  * @return The conversion result is returned.
625  */
626 static char*
627 s_jhtml_start_meta_tag(jhtml_t* jhtml, Node* node) 
628 {
629   Doc* doc = jhtml->doc;
630   request_rec* r = doc->r;
631   Attr* attr;
632
633   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<meta", NULL);
634
635   /*--------------------------------------------------------------------------*/
636   /* Get Attributes                                                           */
637   /*--------------------------------------------------------------------------*/
638   for (attr = qs_get_attr(doc,node);
639        attr;
640        attr = qs_get_next_attr(doc,attr)) {
641     char* name   = qs_get_attr_name(doc,attr);
642     char* value  = qs_get_attr_value(doc,attr);
643
644     if (strcasecmp(name, "http-equiv") == 0) {
645       /*----------------------------------------------------------------------*/
646       /* CHTML 2.0                                                            */
647       /*----------------------------------------------------------------------*/
648       jhtml->out = apr_pstrcat(r->pool, 
649                       jhtml->out, 
650                       " http-equiv=\"", 
651                       value,
652                       "\"",
653                       NULL);
654     }
655     else
656     if (strcasecmp(name, "content") == 0) {
657       /*----------------------------------------------------------------------*/
658       /* CHTML 2.0                                                            */
659       /*----------------------------------------------------------------------*/
660       jhtml->out = apr_pstrcat(r->pool, 
661                       jhtml->out, 
662                       " content=\"", 
663                       value,
664                       "\"",
665                       NULL);
666     }
667   }
668   jhtml->out = apr_pstrcat(r->pool, jhtml->out, ">", NULL);
669   return jhtml->out;
670 }
671
672 /**
673  * It is a handler who processes the META tag.
674  *
675  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
676  *                     destination is specified.
677  * @param node   [i]   The META tag node is specified.
678  * @return The conversion result is returned.
679  */
680 static char*
681 s_jhtml_end_meta_tag(jhtml_t* jhtml, Node* child) 
682 {
683   return jhtml->out;
684 }
685
686 /**
687  * It is a handler who processes the HEAD tag.
688  *
689  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
690  *                     destination is specified.
691  * @param node   [i]   The HEAD tag node is specified.
692  * @return The conversion result is returned.
693  */
694 static char*
695 s_jhtml_start_head_tag(jhtml_t* jhtml, Node* node) 
696 {
697   Doc*          doc = jhtml->doc;
698   request_rec*  r   = doc->r;
699
700   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<head>\r\n", NULL);
701
702   return jhtml->out;
703 }
704
705 /**
706  * It is a handler who processes the HEAD tag.
707  *
708  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
709  *                     destination is specified.
710  * @param node   [i]   The HEAD tag node is specified.
711  * @return The conversion result is returned.
712  */
713 static char*
714 s_jhtml_end_head_tag(jhtml_t* jhtml, Node* child) 
715 {
716   Doc*          doc = jhtml->doc;
717   request_rec*  r   = doc->r;
718
719   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</head>\r\n", NULL);
720
721   return jhtml->out;
722 }
723
724 /**
725  * It is a handler who processes the TITLE tag.
726  *
727  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
728  *                     destination is specified.
729  * @param node   [i]   The TITLE tag node is specified.
730  * @return The conversion result is returned.
731  */
732 static char*
733 s_jhtml_start_title_tag(jhtml_t* jhtml, Node* node) 
734 {
735   Doc* doc = jhtml->doc;
736   request_rec* r = doc->r;
737
738   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<title>", NULL);
739
740   return jhtml->out;
741 }
742
743 /**
744  * It is a handler who processes the TITLE tag.
745  *
746  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
747  *                     destination is specified.
748  * @param node   [i]   The TITLE tag node is specified.
749  * @return The conversion result is returned.
750  */
751 static char*
752 s_jhtml_end_title_tag(jhtml_t* jhtml, Node* child) 
753 {
754   Doc*          doc = jhtml->doc;
755   request_rec*  r   = doc->r;
756
757   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</title>\r\n", NULL);
758
759   return jhtml->out;
760 }
761
762 /**
763  * It is a handler who processes the BASE tag.
764  *
765  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
766  *                     destination is specified.
767  * @param node   [i]   The BASE tag node is specified.
768  * @return The conversion result is returned.
769  */
770 static char*
771 s_jhtml_start_base_tag(jhtml_t* jhtml, Node* node) 
772 {
773   Attr*         attr;
774   Doc*          doc   = jhtml->doc;
775   request_rec*  r     = doc->r;
776
777   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<base", NULL);
778
779   /*--------------------------------------------------------------------------*/
780   /* Get Attributes                                                           */
781   /*--------------------------------------------------------------------------*/
782   for (attr = qs_get_attr(doc,node);
783        attr;
784        attr = qs_get_next_attr(doc,attr)) {
785     char* name = qs_get_attr_name(doc,attr);
786     char* value = qs_get_attr_value(doc,attr);
787     if ((*name == 'h' || *name == 'H') && strcasecmp(name, "href") == 0) {
788       jhtml->out = apr_pstrcat(r->pool, 
789                       jhtml->out, 
790                       " href=\"", 
791                       value, 
792                       "\"", 
793                       NULL);
794     }
795   }
796
797   jhtml->out = apr_pstrcat(r->pool, jhtml->out, " >\r\n", NULL);
798
799   return jhtml->out;
800 }
801
802 /**
803  * It is a handler who processes the BASE tag.
804  *
805  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
806  *                     destination is specified.
807  * @param node   [i]   The BASE tag node is specified.
808  * @return The conversion result is returned.
809  */
810 static char*
811 s_jhtml_end_base_tag(jhtml_t* jhtml, Node* child) 
812 {
813   return jhtml->out;
814 }
815
816 /**
817  * It is a handler who processes the BODY tag.
818  *
819  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
820  *                     destination is specified.
821  * @param node   [i]   The BODY tag node is specified.
822  * @return The conversion result is returned.
823  */
824 static char*
825 s_jhtml_start_body_tag(jhtml_t* jhtml, Node* node) 
826 {
827   Doc* doc = jhtml->doc;
828   request_rec* r = doc->r;
829   Attr* attr;
830
831   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<body", NULL);
832
833   /*--------------------------------------------------------------------------*/
834   /* Get Attributes                                                           */
835   /*--------------------------------------------------------------------------*/
836   for (attr = qs_get_attr(doc,node);
837        attr;
838        attr = qs_get_next_attr(doc,attr)) {
839     char* name  = qs_get_attr_name(doc,attr);
840     char* value  = qs_get_attr_value(doc,attr);
841
842     if ((*name == 'b' || *name == 'B') && strcasecmp(name, "bgcolor") == 0) {
843       /*----------------------------------------------------------------------*/
844       /* CHTML 2.0                                                            */
845       /*----------------------------------------------------------------------*/
846       jhtml->out = apr_pstrcat(r->pool, 
847                       jhtml->out, 
848                       " bgcolor=\"", 
849                       value, 
850                       "\"", 
851                       NULL);
852     }
853     else
854     if ((*name == 't' || *name == 'T') && strcasecmp(name, "text") == 0) {
855       /*----------------------------------------------------------------------*/
856       /* CHTML 2.0                                                            */
857       /*----------------------------------------------------------------------*/
858       jhtml->out = apr_pstrcat(r->pool, 
859                       jhtml->out, 
860                       " text=\"", 
861                       value, 
862                       "\"", 
863                       NULL);
864     }
865     else
866     if ((*name == 'l' || *name == 'L') && strcasecmp(name, "link") == 0) {
867       /*----------------------------------------------------------------------*/
868       /* CHTML 2.0                                                            */
869       /*----------------------------------------------------------------------*/
870       jhtml->out = apr_pstrcat(r->pool, 
871                       jhtml->out, 
872                       " link=\"", 
873                       value, 
874                       "\"", 
875                       NULL);
876     }
877     else
878     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "alink") == 0) {
879       /*----------------------------------------------------------------------*/
880       /* CHTML 4.0                                                            */
881       /*----------------------------------------------------------------------*/
882       /* ignore */
883     }
884     else
885     if ((*name == 'v' || *name == 'V') && strcasecmp(name, "vlink") == 0) {
886       /*----------------------------------------------------------------------*/
887       /* CHTML 4.0                                                            */
888       /*----------------------------------------------------------------------*/
889       /* ignore */
890     }
891   }
892   jhtml->out = apr_pstrcat(r->pool, jhtml->out, ">\r\n", NULL);
893
894   return jhtml->out;
895 }
896
897 /**
898  * It is a handler who processes the BODY tag.
899  *
900  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
901  *                     destination is specified.
902  * @param node   [i]   The BODY tag node is specified.
903  * @return The conversion result is returned.
904  */
905 static char*
906 s_jhtml_end_body_tag(jhtml_t* jhtml, Node* child) 
907 {
908   Doc*          doc = jhtml->doc;
909   request_rec*  r = doc->r;
910
911   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</body>\r\n", NULL);
912
913   return jhtml->out;
914 }
915
916 /**
917  * It is a handler who processes the A tag.
918  *
919  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
920  *                     destination is specified.
921  * @param node   [i]   The A tag node is specified.
922  * @return The conversion result is returned.
923  */
924 static char*
925 s_jhtml_start_a_tag(jhtml_t* jhtml, Node* node) 
926 {
927   Doc*          doc   = jhtml->doc;
928   request_rec*  r     = doc->r;
929   Attr*         attr;
930
931   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<a", NULL);
932
933   /*--------------------------------------------------------------------------*/
934   /* Get Attributes                                                           */
935   /*--------------------------------------------------------------------------*/
936   for (attr = qs_get_attr(doc,node);
937        attr; 
938        attr = qs_get_next_attr(doc,attr)) {
939     char* name  = qs_get_attr_name(doc,attr);
940     char* value = qs_get_attr_value(doc,attr);
941
942     if ((*name == 'n' || *name == 'N') && strcasecmp(name, "name") == 0) {
943       /*----------------------------------------------------------------------*/
944       /* CHTML1.0                                                             */
945       /*----------------------------------------------------------------------*/
946       jhtml->out = apr_pstrcat(r->pool, 
947                       jhtml->out, 
948                       " name=\"", 
949                       value, 
950                       "\"", 
951                       NULL);
952     }
953     else
954     if ((*name == 'h' || *name == 'H') && strcasecmp(name, "href") == 0) {
955       /*----------------------------------------------------------------------*/
956       /* CHTML1.0                                                             */
957       /*----------------------------------------------------------------------*/
958       jhtml->out = apr_pstrcat(r->pool, 
959                       jhtml->out, 
960                       " href=\"", 
961                       value, 
962                       "\"", 
963                       NULL);
964     }
965     else
966     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "accesskey") == 0) {
967       /*----------------------------------------------------------------------*/
968       /* CHTML1.0                                                             */
969       /*----------------------------------------------------------------------*/
970       jhtml->out = apr_pstrcat(r->pool, 
971                       jhtml->out, 
972                       " accesskey=\"", 
973                       value, 
974                       "\"", 
975                       NULL);
976     }
977     else
978     if ((*name == 'c' || *name == 'C') && strcasecmp(name, "cti") == 0) {
979       /*----------------------------------------------------------------------*/
980       /* CHTML 2.0                                                            */
981       /*----------------------------------------------------------------------*/
982       jhtml->out = apr_pstrcat(r->pool, 
983                       jhtml->out, 
984                       " cti=\"", 
985                       value, 
986                       "\"", 
987                       NULL);
988     }
989     else
990     if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ijam") == 0) {
991       /*----------------------------------------------------------------------*/
992       /* CHTML 3.0                                                            */
993       /*----------------------------------------------------------------------*/
994       /* ignore */
995     }
996     else
997     if ((*name == 'u' || *name == 'U') && strcasecmp(name, "utn") == 0) {
998       /*----------------------------------------------------------------------*/
999       /* CHTML 3.0                                                            */
1000       /* It is special only for CHTML.                                        */
1001       /*----------------------------------------------------------------------*/
1002       jhtml->out = apr_pstrcat(r->pool, 
1003                       jhtml->out, 
1004                       " utn ", 
1005                       NULL);
1006     }
1007     else
1008     if ((*name == 't' || *name == 'T') && strcasecmp(name, "telbook") == 0) {
1009       /*----------------------------------------------------------------------*/
1010       /* CHTML 3.0                                                            */
1011       /*----------------------------------------------------------------------*/
1012       /* not support */
1013     }
1014     else
1015     if ((*name == 'k' || *name == 'K') && strcasecmp(name, "kana") == 0) {
1016       /*----------------------------------------------------------------------*/
1017       /* CHTML 3.0                                                            */
1018       /*----------------------------------------------------------------------*/
1019       /* not support */
1020     }
1021     else
1022     if ((*name == 'e' || *name == 'E') && strcasecmp(name, "email") == 0) {
1023       /*----------------------------------------------------------------------*/
1024       /* CHTML 3.0                                                            */
1025       /*----------------------------------------------------------------------*/
1026       /* not support */
1027     }
1028     else
1029     if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ista") == 0) {
1030       /*----------------------------------------------------------------------*/
1031       /* CHTML 4.0                                                            */
1032       /*----------------------------------------------------------------------*/
1033       /* ignore */
1034     }
1035     else
1036     if ((*name == 'i' || *name == 'I') && strcasecmp(name, "ilet") == 0) {
1037       /*----------------------------------------------------------------------*/
1038       /* CHTML 5.0                                                            */
1039       /*----------------------------------------------------------------------*/
1040       /* ignore */
1041     }
1042     else
1043     if ((*name == 'i' || *name == 'I') && strcasecmp(name, "iswf") == 0) {
1044       /*----------------------------------------------------------------------*/
1045       /* CHTML 5.0                                                            */
1046       /*----------------------------------------------------------------------*/
1047       /* ignore */
1048     }
1049     else
1050     if ((*name == 'i' || *name == 'I') && strcasecmp(name, "irst") == 0) {
1051       /*----------------------------------------------------------------------*/
1052       /* CHTML 5.0                                                            */
1053       /*----------------------------------------------------------------------*/
1054       /* ignore */
1055     }
1056   }
1057
1058   jhtml->out = apr_pstrcat(r->pool, jhtml->out, ">", NULL);
1059
1060   return jhtml->out;
1061 }
1062
1063 /**
1064  * It is a handler who processes the A tag.
1065  *
1066  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1067  *                     destination is specified.
1068  * @param node   [i]   The A tag node is specified.
1069  * @return The conversion result is returned.
1070  */
1071 static char*
1072 s_jhtml_end_a_tag(jhtml_t* jhtml, Node* child) 
1073 {
1074   Doc*         doc = jhtml->doc;
1075   request_rec* r   = doc->r;
1076
1077   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</a>", NULL);
1078
1079   return jhtml->out;
1080 }
1081
1082 /**
1083  * It is a handler who processes the BR tag.
1084  *
1085  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1086  *                     destination is specified.
1087  * @param node   [i]   The BR tag node is specified.
1088  * @return The conversion result is returned.
1089  */
1090 static char*
1091 s_jhtml_start_br_tag(jhtml_t* jhtml, Node* node) 
1092 {
1093   Doc*         doc = jhtml->doc;
1094   request_rec* r   = doc->r;
1095
1096   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<br>\r\n", NULL);
1097
1098   return jhtml->out;
1099 }
1100
1101 /**
1102  * It is a handler who processes the BR tag.
1103  *
1104  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1105  *                     destination is specified.
1106  * @param node   [i]   The BR tag node is specified.
1107  * @return The conversion result is returned.
1108  */
1109 static char*
1110 s_jhtml_end_br_tag(jhtml_t* jhtml, Node* child) 
1111 {
1112   return jhtml->out;
1113 }
1114
1115 /**
1116  * It is a handler who processes the TR tag.
1117  *
1118  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1119  *                     destination is specified.
1120  * @param node   [i]   The TR tag node is specified.
1121  * @return The conversion result is returned.
1122  */
1123 static char*
1124 s_jhtml_start_tr_tag(jhtml_t* jhtml, Node* node) 
1125 {
1126   Doc*         doc = jhtml->doc;
1127   request_rec* r   = doc->r;
1128
1129   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<br>\r\n", NULL);
1130
1131   return jhtml->out;
1132 }
1133
1134 /**
1135  * It is a handler who processes the TR tag.
1136  *
1137  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1138  *                     destination is specified.
1139  * @param node   [i]   The TR tag node is specified.
1140  * @return The conversion result is returned.
1141  */
1142 static char*
1143 s_jhtml_end_tr_tag(jhtml_t* jhtml, Node* child) 
1144 {
1145   return jhtml->out;
1146 }
1147
1148 /**
1149  * It is a handler who processes the FONT tag.
1150  *
1151  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1152  *                     destination is specified.
1153  * @param node   [i]   The FONT tag node is specified.
1154  * @return The conversion result is returned.
1155  */
1156 static char*
1157 s_jhtml_start_font_tag(jhtml_t* jhtml, Node* node) 
1158 {
1159   Doc*          doc   = jhtml->doc;
1160   request_rec*  r     = doc->r;
1161   Attr*         attr;
1162
1163   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<font", NULL);
1164
1165   /*--------------------------------------------------------------------------*/
1166   /* Get Attributes                                                           */
1167   /*--------------------------------------------------------------------------*/
1168   for (attr = qs_get_attr(doc,node);
1169        attr; 
1170        attr = qs_get_next_attr(doc,attr)) {
1171     char* name  = qs_get_attr_name(doc,attr);
1172     char* value = qs_get_attr_value(doc,attr);
1173
1174     if ((*name == 'c' || *name == 'C') && strcasecmp(name, "color") == 0) {
1175       jhtml->out = apr_pstrcat(r->pool, 
1176                       jhtml->out, 
1177                       " color=\"", 
1178                       value, 
1179                       "\"", 
1180                       NULL);
1181     }
1182     else
1183     if ((*name == 's' || *name == 'S') && strcasecmp(name, "size") == 0) {
1184       /*----------------------------------------------------------------------*/
1185       /* CHTML 5.0                                                            */
1186       /*----------------------------------------------------------------------*/
1187       /* ignore */
1188     }
1189   }
1190
1191   jhtml->out = apr_pstrcat(r->pool, jhtml->out, ">", NULL);
1192
1193   return jhtml->out;
1194 }
1195
1196 /**
1197  * It is a handler who processes the FONT tag.
1198  *
1199  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1200  *                     destination is specified.
1201  * @param node   [i]   The FONT tag node is specified.
1202  * @return The conversion result is returned.
1203  */
1204 static char*
1205 s_jhtml_end_font_tag(jhtml_t* jhtml, Node* child) 
1206 {
1207   request_rec* r = jhtml->doc->r;
1208
1209   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</font>", NULL);
1210
1211   return jhtml->out;
1212 }
1213
1214 /**
1215  * It is a handler who processes the FORM tag.
1216  *
1217  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1218  *                     destination is specified.
1219  * @param node   [i]   The FORM tag node is specified.
1220  * @return The conversion result is returned.
1221  */
1222 static char*
1223 s_jhtml_start_form_tag(jhtml_t* jhtml, Node* node) 
1224 {
1225   Doc*         doc = jhtml->doc;
1226   request_rec* r   = doc->r;
1227   Attr* attr;
1228
1229   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<form", NULL);
1230
1231   /*--------------------------------------------------------------------------*/
1232   /* Get Attributes                                                           */
1233   /*--------------------------------------------------------------------------*/
1234   for (attr = qs_get_attr(doc,node);
1235        attr;
1236        attr = qs_get_next_attr(doc,attr)) {
1237     char* name = qs_get_attr_name(doc,attr);
1238     char* value = qs_get_attr_value(doc,attr);
1239
1240     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "action") == 0) {
1241       /*----------------------------------------------------------------------*/
1242       /* CHTML 1.0                                                            */
1243       /*----------------------------------------------------------------------*/
1244       jhtml->out = apr_pstrcat(r->pool, 
1245                       jhtml->out, 
1246                       " action=\"",
1247                       value,
1248                       "\"", 
1249                       NULL);
1250     }
1251     else
1252     if ((*name == 'm' || *name == 'M') && strcasecmp(name, "method") == 0) {
1253       /*----------------------------------------------------------------------*/
1254       /* CHTML 1.0                                                            */
1255       /*----------------------------------------------------------------------*/
1256       jhtml->out = apr_pstrcat(r->pool, 
1257                       jhtml->out, 
1258                       " method=\"",
1259                       value,
1260                       "\"", 
1261                       NULL);
1262     }
1263     else
1264     if ((*name == 'u' || *name == 'U') && strcasecmp(name, "utn") == 0) {
1265       /*----------------------------------------------------------------------*/
1266       /* CHTML 3.0                                                            */
1267       /* It is special only for CHTML.                                        */
1268       /*----------------------------------------------------------------------*/
1269       jhtml->out = apr_pstrcat(r->pool, 
1270                       jhtml->out, 
1271                       " utn ", 
1272                       NULL);
1273     }
1274   }
1275
1276   jhtml->out = apr_pstrcat(r->pool, jhtml->out, ">", NULL);
1277
1278   return jhtml->out;
1279 }
1280
1281 /**
1282  * It is a handler who processes the FORM tag.
1283  *
1284  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1285  *                     destination is specified.
1286  * @param node   [i]   The FORM tag node is specified.
1287  * @return The conversion result is returned.
1288  */
1289 static char*
1290 s_jhtml_end_form_tag(jhtml_t* jhtml, Node* child) 
1291 {
1292   Doc*         doc = jhtml->doc;
1293   request_rec* r   = doc->r;
1294
1295   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</form>", NULL);
1296
1297   return jhtml->out;
1298 }
1299
1300 /**
1301  * It is a handler who processes the INPUT tag.
1302  *
1303  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1304  *                     destination is specified.
1305  * @param node   [i]   The INPUT tag node is specified.
1306  * @return The conversion result is returned.
1307  */
1308 static char*
1309 s_jhtml_start_input_tag(jhtml_t* jhtml, Node* node) 
1310 {
1311   Doc*          doc         = jhtml->doc;
1312   request_rec*  r           = doc->r;
1313   char*         max_length  = NULL;
1314   char*         type        = NULL;
1315   char*         name        = NULL;
1316   char*         value       = NULL;
1317   char*         istyle      = NULL;
1318   char*         size        = NULL;
1319   char*         checked     = NULL;
1320   char*         accesskey   = NULL;
1321
1322   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<input", NULL);
1323
1324   /*--------------------------------------------------------------------------*/
1325   /* Get Attributes                                                           */
1326   /*--------------------------------------------------------------------------*/
1327
1328   type       = qs_get_type_attr(doc, node, r);
1329   name       = qs_get_name_attr(doc, node, r);
1330   value      = qs_get_value_attr(doc,node,r);
1331   istyle     = qs_get_istyle_attr(doc,node,r);
1332   max_length = qs_get_maxlength_attr(doc,node,r);
1333   checked    = qs_get_checked_attr(doc,node,r);
1334   accesskey  = qs_get_accesskey_attr(doc, node, r);
1335   size       = qs_get_size_attr(doc, node, r);
1336
1337   if (type) {
1338     jhtml->out = apr_pstrcat(r->pool,
1339                     jhtml->out, 
1340                     " type=\"", 
1341                     type, 
1342                     "\" ", 
1343                     NULL);
1344   }
1345   if (size) {
1346     jhtml->out = apr_pstrcat(r->pool, 
1347                     jhtml->out, 
1348                     " size=\"", 
1349                     size, 
1350                     "\" ", 
1351                     NULL);
1352   }
1353   if (name) {
1354     jhtml->out = apr_pstrcat(r->pool, 
1355                     jhtml->out, 
1356                     " name=\"", 
1357                     name, 
1358                     "\" ", 
1359                     NULL);
1360   }
1361   if (value) {
1362     jhtml->out = apr_pstrcat(r->pool, 
1363                     jhtml->out, 
1364                     " value=\"", 
1365                     value, 
1366                     "\" ", 
1367                     NULL);
1368   }
1369   if (accesskey) {
1370     jhtml->out = apr_pstrcat(r->pool, 
1371                     jhtml->out, 
1372                     " accesskey=\"", 
1373                     accesskey, "\" ", 
1374                     NULL);
1375   }
1376   if (istyle) {
1377     /*------------------------------------------------------------------------*/
1378     /* CHTML 2.0                                                              */
1379     /*------------------------------------------------------------------------*/
1380     if (type && (*type == 'p' || *type == 'P') && strcasecmp(type, "password") == 0) {
1381       jhtml->out = apr_pstrcat(r->pool, 
1382                     jhtml->out, 
1383                     " mode=\"", 
1384                     "numeric", "\" ", 
1385                     NULL);
1386     }
1387     else {
1388       jhtml->out = apr_pstrcat(r->pool, 
1389                     jhtml->out, 
1390                     " mode=\"", 
1391                     chxj_istyle_to_mode(r,istyle), "\" ", 
1392                     NULL);
1393     }
1394   }
1395   else
1396   if (istyle == NULL && type != NULL && strcasecmp(type, "password") == 0) {
1397     jhtml->out = apr_pstrcat(r->pool, 
1398                     jhtml->out, 
1399                     " mode=\"", 
1400                     "numeric", "\" ", 
1401                     NULL);
1402   }
1403   /*--------------------------------------------------------------------------*/
1404   /* The figure is default for the password.                                  */
1405   /*--------------------------------------------------------------------------*/
1406   if (max_length) {
1407     jhtml->out = apr_pstrcat(r->pool, 
1408                       jhtml->out, 
1409                       " maxlength=\"", 
1410                       max_length, 
1411                       "\"", 
1412                       NULL);
1413   }
1414
1415   if (checked) {
1416     jhtml->out = apr_pstrcat(r->pool, 
1417                     jhtml->out, " checked ", NULL);
1418   }
1419
1420   jhtml->out = apr_pstrcat(r->pool, jhtml->out, " >", NULL);
1421
1422   return jhtml->out;
1423 }
1424
1425 /**
1426  * It is a handler who processes the INPUT tag.
1427  *
1428  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1429  *                     destination is specified.
1430  * @param node   [i]   The INPUT tag node is specified.
1431  * @return The conversion result is returned.
1432  */
1433 static char*
1434 s_jhtml_end_input_tag(jhtml_t* jhtml, Node* child) 
1435 {
1436   return jhtml->out;
1437 }
1438
1439 /**
1440  * It is a handler who processes the CENTER tag.
1441  *
1442  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1443  *                     destination is specified.
1444  * @param node   [i]   The CENTER tag node is specified.
1445  * @return The conversion result is returned.
1446  */
1447 static char*
1448 s_jhtml_start_center_tag(jhtml_t* jhtml, Node* node) 
1449 {
1450   Doc*          doc = jhtml->doc;
1451   request_rec*  r   = doc->r;
1452
1453   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<center>", NULL);
1454
1455   return jhtml->out;
1456 }
1457
1458 /**
1459  * It is a handler who processes the CENTER tag.
1460  *
1461  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1462  *                     destination is specified.
1463  * @param node   [i]   The CENTER tag node is specified.
1464  * @return The conversion result is returned.
1465  */
1466 static char*
1467 s_jhtml_end_center_tag(jhtml_t* jhtml, Node* child) 
1468 {
1469   Doc*          doc = jhtml->doc;
1470   request_rec*  r   = doc->r;
1471
1472   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</center>", NULL);
1473
1474   return jhtml->out;
1475 }
1476
1477 /**
1478  * It is a handler who processes the li tag.
1479  *
1480  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1481  *                     destination is specified.
1482  * @param node   [i]   The li tag node is specified.
1483  * @return The conversion result is returned.
1484  */
1485 static char*
1486 s_jhtml_start_li_tag(jhtml_t* jhtml, Node* node) 
1487 {
1488   Doc*          doc = jhtml->doc;
1489   request_rec*  r   = doc->r;
1490
1491   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<li>", NULL);
1492
1493   return jhtml->out;
1494 }
1495
1496 /**
1497  * It is a handler who processes the li tag.
1498  *
1499  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1500  *                     destination is specified.
1501  * @param node   [i]   The li tag node is specified.
1502  * @return The conversion result is returned.
1503  */
1504 static char*
1505 s_jhtml_end_li_tag(jhtml_t* jhtml, Node* child) 
1506 {
1507   Doc*          doc = jhtml->doc;
1508   request_rec*  r   = doc->r;
1509
1510   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</li>", NULL);
1511
1512   return jhtml->out;
1513 }
1514
1515 /**
1516  * It is a handler who processes the OL tag.
1517  *
1518  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1519  *                     destination is specified.
1520  * @param node   [i]   The OL tag node is specified.
1521  * @return The conversion result is returned.
1522  */
1523 static char*
1524 s_jhtml_start_ol_tag(jhtml_t* jhtml, Node* node) 
1525 {
1526   Doc*          doc = jhtml->doc;
1527   request_rec*  r   = doc->r;
1528
1529   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<ol>", NULL);
1530
1531   return jhtml->out;
1532 }
1533
1534 /**
1535  * It is a handler who processes the OL tag.
1536  *
1537  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1538  *                     destination is specified.
1539  * @param node   [i]   The OL tag node is specified.
1540  * @return The conversion result is returned.
1541  */
1542 static char*
1543 s_jhtml_end_ol_tag(jhtml_t* jhtml, Node* child) 
1544 {
1545   Doc*          doc = jhtml->doc;
1546   request_rec*  r   = doc->r;
1547
1548   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</ol>", NULL);
1549
1550   return jhtml->out;
1551 }
1552
1553 /**
1554  * It is a handler who processes the UL tag.
1555  *
1556  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1557  *                     destination is specified.
1558  * @param node   [i]   The UL tag node is specified.
1559  * @return The conversion result is returned.
1560  */
1561 static char*
1562 s_jhtml_start_ul_tag(jhtml_t* jhtml, Node* node) 
1563 {
1564   Doc*          doc = jhtml->doc;
1565   request_rec*  r   = doc->r;
1566
1567   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<ul>", NULL);
1568
1569   return jhtml->out;
1570 }
1571
1572 /**
1573  * It is a handler who processes the UL tag.
1574  *
1575  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1576  *                     destination is specified.
1577  * @param node   [i]   The UL tag node is specified.
1578  * @return The conversion result is returned.
1579  */
1580 static char*
1581 s_jhtml_end_ul_tag(jhtml_t* jhtml, Node* child) 
1582 {
1583   Doc*          doc = jhtml->doc;
1584   request_rec*  r   = doc->r;
1585
1586   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</ul>", NULL);
1587
1588   return jhtml->out;
1589 }
1590
1591 /**
1592  * It is a handler who processes the HR tag.
1593  *
1594  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1595  *                     destination is specified.
1596  * @param node   [i]   The HR tag node is specified.
1597  * @return The conversion result is returned.
1598  */
1599 static char*
1600 s_jhtml_start_hr_tag(jhtml_t* jhtml, Node* node) 
1601 {
1602   Doc* doc = jhtml->doc;
1603   request_rec* r = doc->r;
1604   Attr* attr;
1605
1606   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<hr ", NULL);
1607  
1608   for (attr = qs_get_attr(doc,node);
1609        attr; 
1610        attr = qs_get_next_attr(doc,attr)) {
1611     char* name = qs_get_attr_name(doc,attr);
1612     char* value = qs_get_attr_value(doc,attr);
1613     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "align") == 0) {
1614       /*----------------------------------------------------------------------*/
1615       /* CHTML 1.0                                                            */
1616       /*----------------------------------------------------------------------*/
1617       jhtml->out = apr_pstrcat(r->pool,
1618                         jhtml->out, 
1619                         " align=\"", value, "\" ", NULL);
1620     }
1621     else
1622     if ((*name == 's' || *name == 'S') && strcasecmp(name, "size") == 0) {
1623       /*----------------------------------------------------------------------*/
1624       /* CHTML 1.0                                                            */
1625       /*----------------------------------------------------------------------*/
1626       jhtml->out = apr_pstrcat(r->pool,
1627                         jhtml->out, 
1628                         " size=\"", value, "\" ", NULL);
1629     }
1630     else
1631     if ((*name == 'w' || *name == 'W') && strcasecmp(name, "width") == 0) {
1632       /*----------------------------------------------------------------------*/
1633       /* CHTML 1.0                                                            */
1634       /*----------------------------------------------------------------------*/
1635       jhtml->out = apr_pstrcat(r->pool,
1636                         jhtml->out, 
1637                         " width=\"", value, "\" ", NULL);
1638     }
1639     else
1640     if ((*name == 'n' || *name == 'N') && strcasecmp(name, "noshade") == 0) {
1641       /*----------------------------------------------------------------------*/
1642       /* CHTML 1.0                                                            */
1643       /*----------------------------------------------------------------------*/
1644       jhtml->out = apr_pstrcat(r->pool,
1645                         jhtml->out, 
1646                         " noshade ", NULL);
1647     }
1648     else
1649     if ((*name == 'c' || *name == 'C') && strcasecmp(name, "color") == 0) {
1650       /*----------------------------------------------------------------------*/
1651       /* CHTML 4.0                                                            */
1652       /*----------------------------------------------------------------------*/
1653       /* ignore */
1654     }
1655   }
1656   jhtml->out = apr_pstrcat(r->pool, jhtml->out, " >", NULL);
1657
1658   return jhtml->out;
1659 }
1660
1661 /**
1662  * It is a handler who processes the HR tag.
1663  *
1664  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1665  *                     destination is specified.
1666  * @param node   [i]   The HR tag node is specified.
1667  * @return The conversion result is returned.
1668  */
1669 static char*
1670 s_jhtml_end_hr_tag(jhtml_t* jhtml, Node* child) 
1671 {
1672   return jhtml->out;
1673 }
1674
1675 /**
1676  * It is a handler who processes the IMG tag.
1677  *
1678  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1679  *                     destination is specified.
1680  * @param node   [i]   The IMG tag node is specified.
1681  * @return The conversion result is returned.
1682  */
1683 static char*
1684 s_jhtml_start_img_tag(jhtml_t* jhtml, Node* node) 
1685 {
1686   Doc*          doc = jhtml->doc;
1687   request_rec*  r   = doc->r;
1688   Attr* attr;
1689 #ifndef IMG_NOT_CONVERT_FILENAME
1690   device_table_t* spec = jhtml->spec;
1691 #endif
1692
1693   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<img", NULL);
1694  
1695
1696   /*--------------------------------------------------------------------------*/
1697   /* Get Attributes                                                           */
1698   /*--------------------------------------------------------------------------*/
1699   for (attr = qs_get_attr(doc,node);
1700        attr;
1701        attr = qs_get_next_attr(doc,attr)) {
1702     char* name  = qs_get_attr_name(doc,attr);
1703     char* value = qs_get_attr_value(doc,attr);
1704
1705     if ((*name == 's' || *name == 'S') && strcasecmp(name, "src") == 0) {
1706       /*----------------------------------------------------------------------*/
1707       /* CHTML 1.0                                                            */
1708       /*----------------------------------------------------------------------*/
1709 #ifdef IMG_NOT_CONVERT_FILENAME
1710       jhtml->out = apr_pstrcat(r->pool, 
1711                       jhtml->out, " src=\"",value,"\"", NULL);
1712 #else
1713       jhtml->out = apr_pstrcat(r->pool, 
1714                       jhtml->out, " src=\"", chxj_img_conv(r,spec,value), NULL);
1715       jhtml->out = apr_pstrcat(r->pool, jhtml->out, "\"", NULL);
1716 #endif
1717     }
1718     else
1719     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "align" ) == 0) {
1720       /*----------------------------------------------------------------------*/
1721       /* CHTML 1.0                                                            */
1722       /*----------------------------------------------------------------------*/
1723       jhtml->out = apr_pstrcat(r->pool, 
1724                       jhtml->out, " align=\"",value,"\"", NULL);
1725     }
1726     else
1727     if ((*name == 'w' || *name == 'W') && strcasecmp(name, "width" ) == 0) {
1728       /*----------------------------------------------------------------------*/
1729       /* CHTML 1.0                                                            */
1730       /*----------------------------------------------------------------------*/
1731       jhtml->out = apr_pstrcat(r->pool, 
1732                       jhtml->out, " width=\"",value,"\"", NULL);
1733     }
1734     else
1735     if ((*name == 'h' || *name == 'H') && strcasecmp(name, "height") == 0) {
1736       /*----------------------------------------------------------------------*/
1737       /* CHTML 1.0                                                            */
1738       /*----------------------------------------------------------------------*/
1739       jhtml->out = apr_pstrcat(r->pool, 
1740                       jhtml->out, " height=\"",value,"\"", NULL);
1741     }
1742     else
1743     if ((*name == 'h' || *name == 'H') && strcasecmp(name, "hspace") == 0) {
1744       /*----------------------------------------------------------------------*/
1745       /* CHTML 1.0                                                            */
1746       /*----------------------------------------------------------------------*/
1747       jhtml->out = apr_pstrcat(r->pool, 
1748                       jhtml->out, " hspace=\"",value,"\"", NULL);
1749     }
1750     else
1751     if ((*name == 'v' || *name == 'V') && strcasecmp(name, "vspace") == 0) {
1752       /*----------------------------------------------------------------------*/
1753       /* CHTML 1.0                                                            */
1754       /*----------------------------------------------------------------------*/
1755       jhtml->out = apr_pstrcat(r->pool, 
1756                       jhtml->out, " vspace=\"",value,"\"", NULL);
1757     }
1758     else
1759     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "alt"   ) == 0) {
1760       /*----------------------------------------------------------------------*/
1761       /* CHTML 1.0                                                            */
1762       /*----------------------------------------------------------------------*/
1763       jhtml->out = apr_pstrcat(r->pool, 
1764                       jhtml->out, " alt=\"",value,"\"", NULL);
1765     }
1766     else
1767     if ((*name == 'a' || *name == 'A') && strcasecmp(name, "align" ) == 0) {
1768       /*----------------------------------------------------------------------*/
1769       /* CHTML 4.0                                                            */
1770       /*----------------------------------------------------------------------*/
1771       /* ignore */
1772     }
1773   }
1774
1775   jhtml->out = apr_pstrcat(r->pool, jhtml->out, ">", NULL);
1776
1777   return jhtml->out;
1778 }
1779
1780 /**
1781  * It is a handler who processes the IMG tag.
1782  *
1783  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1784  *                     destination is specified.
1785  * @param node   [i]   The IMG tag node is specified.
1786  * @return The conversion result is returned.
1787  */
1788 static char*
1789 s_jhtml_end_img_tag(jhtml_t* jhtml, Node* child) 
1790 {
1791   return jhtml->out;
1792 }
1793
1794 /**
1795  * It is a handler who processes the SELECT tag.
1796  *
1797  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1798  *                     destination is specified.
1799  * @param node   [i]   The SELECT tag node is specified.
1800  * @return The conversion result is returned.
1801  */
1802 static char*
1803 s_jhtml_start_select_tag(jhtml_t* jhtml, Node* child)
1804 {
1805   Doc* doc = jhtml->doc;
1806   request_rec* r = doc->r;
1807   Attr* attr;
1808
1809   char* size      = NULL;
1810   char* name      = NULL;
1811
1812   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<select", NULL);
1813   for (attr = qs_get_attr(doc,child);
1814        attr;
1815        attr = qs_get_next_attr(doc,attr)) {
1816     char* nm  = qs_get_attr_name(doc,attr);
1817     char* val = qs_get_attr_value(doc,attr);
1818
1819     if (strcasecmp(nm, "size") == 0) {
1820       /*----------------------------------------------------------------------*/
1821       /* CHTML 1.0 version 2.0                                                */
1822       /*----------------------------------------------------------------------*/
1823       size = apr_pstrdup(r->pool, val);
1824     }
1825     else
1826     if (strcasecmp(nm, "name") == 0)
1827     {
1828       /*----------------------------------------------------------------------*/
1829       /* CHTML 1.0 version 2.0                                                */
1830       /*----------------------------------------------------------------------*/
1831       name = apr_pstrdup(r->pool, val);
1832     }
1833     else
1834     if (strcasecmp(nm, "multiple") == 0)
1835     {
1836       /*----------------------------------------------------------------------*/
1837       /* CHTML 1.0 version 2.0                                                */
1838       /*----------------------------------------------------------------------*/
1839       /* not support */
1840     }
1841   }
1842
1843   if (size != NULL)
1844   {
1845     jhtml->out = apr_pstrcat(r->pool, jhtml->out, " size=\"",size,"\"", NULL);
1846   }
1847   if (name != NULL)
1848   {
1849     jhtml->out = apr_pstrcat(r->pool, jhtml->out, " name=\"",name,"\"", NULL);
1850   }
1851   jhtml->out = apr_pstrcat(r->pool, jhtml->out, ">\n", NULL);
1852   return jhtml->out;
1853 }
1854
1855 /**
1856  * It is a handler who processes the SELECT tag.
1857  *
1858  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1859  *                     destination is specified.
1860  * @param node   [i]   The SELECT tag node is specified.
1861  * @return The conversion result is returned.
1862  */
1863 static char*
1864 s_jhtml_end_select_tag(jhtml_t* jhtml, Node* child)
1865 {
1866   Doc* doc = jhtml->doc;
1867   request_rec* r = doc->r;
1868
1869   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</select>\n", NULL);
1870   return jhtml->out;
1871 }
1872
1873 /**
1874  * It is a handler who processes the OPTION tag.
1875  *
1876  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1877  *                     destination is specified.
1878  * @param node   [i]   The OPTION tag node is specified.
1879  * @return The conversion result is returned.
1880  */
1881 static char*
1882 s_jhtml_start_option_tag(jhtml_t* jhtml, Node* child)
1883 {
1884   Doc* doc = jhtml->doc;
1885   request_rec* r = doc->r;
1886   Attr* attr;
1887
1888   char* selected   = NULL;
1889   char* value      = NULL;
1890
1891   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<option", NULL);
1892   for (attr = qs_get_attr(doc,child);
1893        attr;
1894        attr = qs_get_next_attr(doc,attr)) 
1895   {
1896     char* nm  = qs_get_attr_name(doc,attr);
1897     char* val = qs_get_attr_value(doc,attr);
1898
1899     if (strcasecmp(nm, "selected") == 0)
1900     {
1901       /*----------------------------------------------------------------------*/
1902       /* CHTML 1.0 version 2.0                                                */
1903       /*----------------------------------------------------------------------*/
1904       selected = apr_pstrdup(r->pool, val);
1905     }
1906     else
1907     if (strcasecmp(nm, "value") == 0)
1908     {
1909       /*----------------------------------------------------------------------*/
1910       /* CHTML 1.0 version 2.0                                                */
1911       /*----------------------------------------------------------------------*/
1912       value = apr_pstrdup(r->pool, val);
1913     }
1914   }
1915
1916   if (value != NULL)
1917   {
1918     jhtml->out = apr_pstrcat(r->pool, jhtml->out, " value=\"",value,"\"", NULL);
1919   }
1920   else
1921   {
1922     jhtml->out = apr_pstrcat(r->pool, jhtml->out, " value=\"\"", NULL);
1923   }
1924
1925   if (selected != NULL)
1926   {
1927     jhtml->out = apr_pstrcat(r->pool, jhtml->out, " selected ", NULL);
1928   }
1929
1930   jhtml->out = apr_pstrcat(r->pool, jhtml->out, ">", NULL);
1931   return jhtml->out;
1932 }
1933
1934 /**
1935  * It is a handler who processes the OPTION tag.
1936  *
1937  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1938  *                     destination is specified.
1939  * @param node   [i]   The OPTION tag node is specified.
1940  * @return The conversion result is returned.
1941  */
1942 static char*
1943 s_jhtml_end_option_tag(jhtml_t* jhtml, Node* child)
1944 {
1945   /* Don't close */
1946   return jhtml->out;
1947 }
1948
1949 /**
1950  * It is a handler who processes the DIV tag.
1951  *
1952  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1953  *                     destination is specified.
1954  * @param node   [i]   The DIV tag node is specified.
1955  * @return The conversion result is returned.
1956  */
1957 static char*
1958 s_jhtml_start_div_tag(jhtml_t* jhtml, Node* child)
1959 {
1960   Doc* doc = jhtml->doc;
1961   request_rec* r = doc->r;
1962   Attr* attr;
1963
1964   char* align   = NULL;
1965
1966   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "<div", NULL);
1967   for (attr = qs_get_attr(doc,child);
1968        attr;
1969        attr = qs_get_next_attr(doc,attr)) 
1970   {
1971     char* nm  = qs_get_attr_name(doc,attr);
1972     char* val = qs_get_attr_value(doc,attr);
1973
1974     if (strcasecmp(nm, "align") == 0)
1975     {
1976       /*----------------------------------------------------------------------*/
1977       /* CHTML 1.0 (W3C version 3.2)                                          */
1978       /*----------------------------------------------------------------------*/
1979       align = apr_pstrdup(r->pool, val);
1980     }
1981   }
1982
1983   if (align != NULL)
1984   {
1985     jhtml->out = apr_pstrcat(r->pool, 
1986                     jhtml->out, " align=\"", align, "\"", NULL);
1987   }
1988
1989   jhtml->out = apr_pstrcat(r->pool, jhtml->out, ">", NULL);
1990   return jhtml->out;
1991 }
1992
1993 /**
1994  * It is a handler who processes the DIV tag.
1995  *
1996  * @param jhtml  [i/o] The pointer to the CHTML structure at the output
1997  *                     destination is specified.
1998  * @param node   [i]   The DIV tag node is specified.
1999  * @return The conversion result is returned.
2000  */
2001 static char*
2002 s_jhtml_end_div_tag(jhtml_t* jhtml, Node* child)
2003 {
2004   Doc* doc = jhtml->doc;
2005   request_rec* r = doc->r;
2006
2007   jhtml->out = apr_pstrcat(r->pool, jhtml->out, "</div>\n", NULL);
2008
2009   return jhtml->out;
2010 }
2011
2012 static char*
2013 chxj_istyle_to_mode(request_rec* r, const char* s)
2014 {
2015   char* tmp;
2016   if (strcasecmp(s, "1") == 0)
2017   {
2018     return apr_psprintf(r->pool, "hiragana");
2019   }
2020   else
2021   if (strcasecmp(s, "2") == 0)
2022   {
2023     return apr_psprintf(r->pool, "hankakukana");
2024   }
2025   else
2026   if (strcasecmp(s, "3") == 0)
2027   {
2028     return apr_psprintf(r->pool, "alphabet");
2029   }
2030   else
2031   if (strcasecmp(s, "4") == 0)
2032   {
2033     return apr_psprintf(r->pool, "numeric");
2034   }
2035
2036   tmp = apr_palloc(r->pool, 1);
2037   tmp[0] = '\0';
2038   return apr_pstrdup(r->pool,tmp);
2039 }
2040
2041 static void
2042 s_jhtml_chxjif_tag(jhtml_t* jhtml, Node* node)
2043 {
2044   Doc*         doc   = jhtml->doc;
2045   Node*        child;
2046   request_rec* r     = doc->r;
2047
2048   for (child = qs_get_child_node(doc, node);
2049        child;
2050        child = qs_get_next_node(doc, child))
2051   {
2052     jhtml->out = apr_pstrcat(r->pool, jhtml->out, child->otext, NULL);
2053     s_jhtml_chxjif_tag(jhtml, child);
2054   }
2055 }
2056 /*
2057  * vim:ts=2 et
2058  */