#define GET_XHTML(X) ((xhtml_t*)(X))
-static char* s_xhtml_1_0_node_exchange (xhtml_t* xhtml, Node* node, int indent);
static char* s_xhtml_1_0_start_html_tag (void* pdoc, Node* node);
static char* s_xhtml_1_0_end_html_tag (void* pdoc, Node* node);
static char* s_xhtml_1_0_start_p_tag (void* pdoc, Node* node);
/*--------------------------------------------------------------------------*/
/* It converts it from CHTML to XHTML. */
/*--------------------------------------------------------------------------*/
- dst = s_xhtml_1_0_node_exchange(&xhtml, qs_get_root(&doc), 0);
+ chxj_node_exchange(spec,r,(void*)&xhtml, &doc, qs_get_root(&doc), 0);
+ dst = xhtml.out;
+
qs_all_free(&doc,QX_LOGMARK);
if (! dst)
xhtml->doc->parse_mode = PARSE_MODE_CHTML;
}
-/**
- * It is main processing of conversion from CHTML to XHTML.
- *
- * @param xhtml [i/o] The pointer to the XHTML structure is specified.
- * @param node [i] The pointer to a current node is specified.
- * @param indent [i] The depth of the node processing it now is specified.
- *
- * @return The character string after it converts it is returned.
- */
-static char*
-s_xhtml_1_0_node_exchange(xhtml_t* xhtml, Node* node, int indent)
-{
- Node* child;
- Doc* doc = xhtml->doc;
- request_rec* r = doc->r;
-
- /*--------------------------------------------------------------------------*/
- /* It is the main loop of the conversion processing. */
- /*--------------------------------------------------------------------------*/
- for (child = qs_get_child_node(doc,node);
- child ;
- child = qs_get_next_node(doc,child)) {
-
- char* name = qs_get_node_name(doc,child);
-
- /*------------------------------------------------------------------------*/
- /* <TEXTAREA> (for TEST) */
- /*------------------------------------------------------------------------*/
- if ((*name == 't' || *name == 'T') && strcasecmp(name, "textarea") == 0) {
- s_xhtml_1_0_start_textarea_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- s_xhtml_1_0_end_textarea_tag (xhtml, child);
- }
- else
- /*------------------------------------------------------------------------*/
- /* <P> (for TEST) */
- /*------------------------------------------------------------------------*/
- if ((*name == 'p' || *name == 'P') && strcasecmp(name, "p") == 0) {
- s_xhtml_1_0_start_p_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- s_xhtml_1_0_end_p_tag (xhtml, child);
- }
- else
- /*------------------------------------------------------------------------*/
- /* <PRE> (for TEST) */
- /*------------------------------------------------------------------------*/
- if ((*name == 'p' || *name == 'P') && strcasecmp(name, "pre") == 0) {
- s_xhtml_1_0_start_pre_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- s_xhtml_1_0_end_pre_tag (xhtml, child);
- }
- else
- /*------------------------------------------------------------------------*/
- /* <UL> (for TEST) */
- /*------------------------------------------------------------------------*/
- if ((*name == 'u' || *name == 'U') && strcasecmp(name, "ul") == 0) {
- s_xhtml_1_0_start_ul_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- s_xhtml_1_0_end_ul_tag (xhtml, child);
- }
- /*------------------------------------------------------------------------*/
- /* <OL> (for TEST) */
- /*------------------------------------------------------------------------*/
- else
- if ((*name == 'o' || *name == 'O') && strcasecmp(name, "ol") == 0) {
- s_xhtml_1_0_start_ol_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- s_xhtml_1_0_end_ol_tag (xhtml, child);
- }
- /*------------------------------------------------------------------------*/
- /* <LI> (for TEST) */
- /*------------------------------------------------------------------------*/
- else
- if ((*name == 'l' || *name == 'L') && strcasecmp(name, "li") == 0) {
- s_xhtml_1_0_start_li_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- s_xhtml_1_0_end_li_tag (xhtml, child);
- }
- /*------------------------------------------------------------------------*/
- /* <NOBR> (for TEST) */
- /*------------------------------------------------------------------------*/
- else
- if ((*name == 'n' || *name == 'N') && strcasecmp(name, "nobr") == 0) {
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- }
- else
- if (*name == 'h' || *name == 'H') {
- /*----------------------------------------------------------------------*/
- /* <HTML> */
- /*----------------------------------------------------------------------*/
- if (strcasecmp(name, "html") == 0) {
- s_xhtml_1_0_start_html_tag(xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_html_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <HEAD> */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "head") == 0) {
- s_xhtml_1_0_start_head_tag(xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_head_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <HR> */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "hr") == 0) {
- s_xhtml_1_0_start_hr_tag (xhtml, child);
- s_xhtml_1_0_end_hr_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <H1> */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "h1") == 0) {
- s_xhtml_1_0_start_h1_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_h1_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <H2> */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "h2") == 0) {
- s_xhtml_1_0_start_h2_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_h2_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <H3> */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "h3") == 0) {
- s_xhtml_1_0_start_h3_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_h3_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <H4> */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "h4") == 0) {
- s_xhtml_1_0_start_h4_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_h4_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <H5> */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "h5") == 0) {
- s_xhtml_1_0_start_h5_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_h5_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <H6> */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "h6") == 0) {
- s_xhtml_1_0_start_h6_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_h6_tag (xhtml, child);
- }
- }
- /*------------------------------------------------------------------------*/
- /* <META> */
- /*------------------------------------------------------------------------*/
- else
- if ((*name == 'm' || *name == 'M') && strcasecmp(name, "meta") == 0) {
- s_xhtml_1_0_start_meta_tag(xhtml, child);
- s_xhtml_1_0_end_meta_tag (xhtml, child);
- }
- else
- if (*name == 'b' || *name == 'B') {
- /*----------------------------------------------------------------------*/
- /* <BASE> */
- /*----------------------------------------------------------------------*/
- if (strcasecmp(name, "base") == 0) {
- s_xhtml_1_0_start_base_tag(xhtml, child);
- s_xhtml_1_0_end_base_tag (xhtml, child);
- }
- else
- /*----------------------------------------------------------------------*/
- /* <BODY> */
- /*----------------------------------------------------------------------*/
- if (strcasecmp(name, "body") == 0) {
- s_xhtml_1_0_start_body_tag(xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_body_tag (xhtml, child);
- }
- else
- /*----------------------------------------------------------------------*/
- /* <BR> */
- /*----------------------------------------------------------------------*/
- if (strcasecmp(name, "br") == 0) {
- s_xhtml_1_0_start_br_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_br_tag (xhtml, child);
- }
- }
- /*------------------------------------------------------------------------*/
- /* <A> */
- /*------------------------------------------------------------------------*/
- else
- if ((*name == 'a' || *name == 'A') && strcasecmp(name, "a") == 0) {
- s_xhtml_1_0_start_a_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_a_tag (xhtml, child);
- }
- else
- if (*name == 'f' || *name == 'F') {
- /*----------------------------------------------------------------------*/
- /* <FONT> */
- /*----------------------------------------------------------------------*/
- if (strcasecmp(name, "font") == 0) {
- s_xhtml_1_0_start_font_tag(xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_font_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <FORM> */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "form") == 0) {
- s_xhtml_1_0_start_form_tag(xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_form_tag (xhtml, child);
- }
- }
- else
- if (*name == 'i' || *name == 'I') {
- /*----------------------------------------------------------------------*/
- /* <INPUT> */
- /*----------------------------------------------------------------------*/
- if (strcasecmp(name, "input") == 0) {
- s_xhtml_1_0_start_input_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_input_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <IMG> */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "img") == 0) {
- s_xhtml_1_0_start_img_tag (xhtml, child);
- s_xhtml_1_0_end_img_tag (xhtml, child);
- }
- }
- else
- if (*name == 's' || *name == 'S') {
- /*----------------------------------------------------------------------*/
- /* <SELECT> */
- /*----------------------------------------------------------------------*/
- if (strcasecmp(name, "select") == 0) {
- s_xhtml_1_0_start_select_tag(xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- s_xhtml_1_0_end_select_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <STYLE> (for TEST) */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "style") == 0) {
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- }
- /*----------------------------------------------------------------------*/
- /* <SPAN> (for TEST) */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "span") == 0) {
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- }
- }
- /*------------------------------------------------------------------------*/
- /* <OPTION> */
- /*------------------------------------------------------------------------*/
- else
- if ((*name == 'o' || *name == 'O') && strcasecmp(name, "option") == 0) {
- s_xhtml_1_0_start_option_tag(xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- s_xhtml_1_0_end_option_tag (xhtml, child);
- }
- /*------------------------------------------------------------------------*/
- /* <DIV> */
- /*------------------------------------------------------------------------*/
- else
- if ((*name == 'd' || *name == 'D') && strcasecmp(name, "div") == 0) {
- s_xhtml_1_0_start_div_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- s_xhtml_1_0_end_div_tag (xhtml, child);
- }
- else
- if (*name == 'c' || *name == 'C') {
- /*----------------------------------------------------------------------*/
- /* <CHXJ:IF> */
- /*----------------------------------------------------------------------*/
- if (strcasecmp(name, "chxj:if") == 0) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG,0,r, "chxj:if tag found");
- if (chxj_chxjif_is_mine(xhtml->spec, doc, child)) {
- char* destlang = qs_get_destlang_attr(doc, child, r);
- if (destlang != NULL && strcasecmp(destlang, "hdml") == 0) {
- ap_set_content_type(r, "text/x-hdml; charset=Shift_JIS");
- }
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG,0,r, "chxj:if tag is mine");
-
- char* parse_attr = NULL;
- parse_attr = qs_get_parse_attr(doc, child, r);
- if (parse_attr != NULL && strcasecmp(parse_attr, "true") == 0) {
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- }
- else {
- s_xhtml_1_0_chxjif_tag(xhtml, child);
- }
- }
- }
- /*----------------------------------------------------------------------*/
- /* <CENTER> */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "center") == 0) {
- s_xhtml_1_0_start_center_tag(xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_center_tag (xhtml, child);
- }
- }
- else
- if (*name == 't' || *name == 'T') {
- /*----------------------------------------------------------------------*/
- /* <TITLE> */
- /*----------------------------------------------------------------------*/
- if (strcasecmp(name, "title") == 0) {
- s_xhtml_1_0_start_title_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_title_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <TABLE> (for TEST) */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "table") == 0) {
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- }
- /*----------------------------------------------------------------------*/
- /* <TBODY> (for TEST) */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "tbody") == 0) {
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- }
- /*----------------------------------------------------------------------*/
- /* <TH> (for TEST) */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "th") == 0) {
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- }
- /*----------------------------------------------------------------------*/
- /* <TR> (for TEST) */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "tr") == 0) {
- s_xhtml_1_0_start_tr_tag (xhtml, child);
- s_xhtml_1_0_node_exchange (xhtml, child,indent+1);
- s_xhtml_1_0_end_tr_tag (xhtml, child);
- }
- /*----------------------------------------------------------------------*/
- /* <TD> (for TEST) */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "td") == 0) {
- s_xhtml_1_0_node_exchange (xhtml, child, indent+1);
- }
- /*----------------------------------------------------------------------*/
- /* NORMAL TEXT */
- /*----------------------------------------------------------------------*/
- else
- if (strcasecmp(name, "text") == 0) {
- char* textval;
- char* tmp;
- char* tdst;
- char one_byte[2];
- int ii;
- int tdst_len;
-
- textval = qs_get_node_value(doc,child);
- textval = qs_trim_string(xhtml->doc->r, textval);
- if (strlen(textval) == 0)
- continue;
-
- tmp = apr_palloc(r->pool, qs_get_node_size(doc,child)+1);
- memset(tmp, 0, qs_get_node_size(doc,child)+1);
-
- tdst = qs_alloc_zero_byte_string(r);
- memset(one_byte, 0, sizeof(one_byte));
- tdst_len = 0;
-
- for (ii=0; ii<qs_get_node_size(doc,child); ii++) {
- char* out;
- int rtn = s_xhtml_search_emoji(xhtml, &textval[ii], &out);
- if (rtn != 0) {
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG,0, r,
- "[%s][%d]", out, rtn);
- tdst = qs_out_apr_pstrcat(r, tdst, out, &tdst_len);
- ii+=(rtn - 1);
- continue;
- }
- if (is_sjis_kanji(textval[ii])) {
- one_byte[0] = textval[ii+0];
- tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
- one_byte[0] = textval[ii+1];
- tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
- ii++;
- }
- else if (xhtml->pre_flag) {
- one_byte[0] = textval[ii+0];
- tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
- }
- else if (xhtml->textarea_flag) {
- one_byte[0] = textval[ii+0];
- tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
- }
- else if (textval[ii] != '\r' && textval[ii] != '\n') {
- one_byte[0] = textval[ii+0];
- tdst = qs_out_apr_pstrcat(r, tdst, one_byte, &tdst_len);
- }
- }
- xhtml->out = apr_pstrcat(r->pool, xhtml->out, tdst, NULL);
- }
- }
- }
-
- return xhtml->out;
-}
/**
* Corresponding EMOJI to a current character-code is retrieved.