OSDN Git Service

* Deleted Makefile, Makefile.in
[modchxj/mod_chxj.git] / src / chxj_jhtml.c
index 666500b..2f220ff 100644 (file)
@@ -24,6 +24,8 @@
 #include "chxj_str_util.h"
 #include "chxj_header_inf.h"
 #include "chxj_jreserved_tag.h"
+#include "chxj_serf.h"
+#include "chxj_conv_z2h.h"
 
 
 #define GET_JHTML(X) ((jhtml_t *)(X))
@@ -132,6 +134,7 @@ static char *chxj_istyle_to_mode(apr_pool_t *p, const char *s);
 static css_prop_list_t *s_jhtml_push_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
 static css_prop_list_t *s_jhtml_nopush_and_get_now_style(void *pdoc, Node *node, const char *style_attr_value);
 
+static char *s_add_copyright_parameter(request_rec *r, char *value);
 
 
 tag_handler jhtml_handler[] = {
@@ -305,6 +308,11 @@ tag_handler jhtml_handler[] = {
     s_jhtml_chxjif_tag,
     NULL,
   },
+  /* tagCHXJRAW */
+  {
+    s_jhtml_chxjif_tag,
+    NULL,
+  },
   /* tagNOBR */
   {
     NULL,
@@ -410,6 +418,21 @@ tag_handler jhtml_handler[] = {
     s_jhtml_newline_mark,
     NULL,
   },
+  /* tagObject */
+  {
+    NULL,
+    NULL,
+  },
+  /* tagParam */
+  {
+    NULL,
+    NULL,
+  },
+  /* tagCAPTION */
+  {
+    NULL,
+    NULL,
+  },
 };
 
 
@@ -1822,6 +1845,11 @@ s_jhtml_start_input_tag(void *pdoc, Node *node)
     W_L("\"");
   }
   if (attr_value) {
+    if (attr_type && (STRCASEEQ('s','S',"submit",attr_type) || STRCASEEQ('r','R',"reset",attr_type))) {
+      apr_size_t value_len = strlen(attr_value);
+      attr_value = chxj_conv_z2h(r, attr_value, &value_len, jhtml->entryp);
+    }
+
     W_L(" value=\"");
     W_V(chxj_add_slash_to_doublequote(doc->pool, attr_value));
     W_L("\"");
@@ -2060,36 +2088,6 @@ s_jhtml_start_li_tag(void *pdoc, Node *node)
     W_V(attr_value);
     W_L("\"");
   }
-  if (IS_CSS_ON(jhtml->entryp)) {
-    css_prop_list_t *style = s_jhtml_push_and_get_now_style(pdoc, node, attr_style);
-    if (style) {
-      css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type");
-      css_property_t *cur;
-      for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) {
-        if (STRCASEEQ('d','D',"decimal", cur->value)) {
-          attr_type = apr_pstrdup(doc->pool, "1");
-        }
-        else if (STRCASEEQ('u','U',"upper-alpha", cur->value)) {
-          attr_type = apr_pstrdup(doc->pool, "A");
-        }
-        else if (STRCASEEQ('l','L',"lower-alpha", cur->value)) {
-          attr_type = apr_pstrdup(doc->pool, "a");
-        }
-      }
-    }
-  }
-
-  W_L("<li");
-  if (attr_type) {
-    W_L(" type=\"");
-    W_V(attr_type);
-    W_L("\"");
-  }
-  if (attr_value) {
-    W_L(" value=\"");
-    W_V(attr_value);
-    W_L("\"");
-  }
   W_L(">");
   return jhtml->out;
 }
@@ -2703,6 +2701,8 @@ s_jhtml_start_img_tag(void *pdoc, Node *node)
       value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jhtml->entryp, 0);
       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
       value = chxj_add_cookie_no_update_parameter(r, value);
+      value = chxj_img_rewrite_parameter(r,jhtml->conf,value);
+      value = s_add_copyright_parameter(r, value);
       attr_src = value;
 #else
       value = chxj_img_conv(r, spec, value);
@@ -2710,6 +2710,8 @@ s_jhtml_start_img_tag(void *pdoc, Node *node)
       value = chxj_jreserved_tag_to_safe_for_query_string(r, value, jhtml->entryp, 0);
       value = chxj_add_cookie_parameter(r, value, jhtml->cookie);
       value = chxj_add_cookie_no_update_parameter(r, value);
+      value = chxj_img_rewrite_parameter(r,jhtml->conf,value);
+      value = s_add_copyright_parameter(r, value);
       attr_src = value;
 #endif
       }
@@ -3486,17 +3488,18 @@ s_jhtml_end_b_tag(void* pdoc, Node* UNUSED(child))
 }
 
 static char*
-s_jhtml_text_tag(void* pdoc, Node* child)
+s_jhtml_text_tag(void *pdoc, Node *child)
 {
-  jhtml_t*     jhtml;
-  Doc*         doc;
-  char*        textval;
-  char*        tmp;
-  char*        tdst;
+  jhtml_t      *jhtml;
+  Doc          *doc;
+  char         *textval;
+  char         *tmp;
+  char         *tdst;
   char         one_byte[2];
   int          ii;
   int          tdst_len;
-  request_rec* r;
+  request_rec  *r;
+  apr_size_t   z2h_input_len;
 
   jhtml = GET_JHTML(pdoc);
   doc   = jhtml->doc;
@@ -3548,6 +3551,9 @@ s_jhtml_text_tag(void* pdoc, Node* child)
       }
     }
   }
+  z2h_input_len = strlen(tdst);
+  tdst = chxj_conv_z2h(r, tdst, &z2h_input_len, jhtml->entryp);
+
   W_V(tdst);
   DBG(r, "end s_jhtml_text_tag()");
   return jhtml->out;
@@ -5557,6 +5563,73 @@ s_jhtml_style_tag(void *pdoc, Node *node)
   }
   return jhtml->out;
 }
+
+
+static char *
+s_add_copyright_parameter(request_rec *r, char *value)
+{
+  request_rec *sub_req = NULL;
+  apr_pool_t *pool;
+  int rr_status;
+  char *content_type = NULL;
+  apr_table_t *headers_out = NULL;
+
+  DBG(r, "REQ[%X] start s_add_copyright_parameter", TO_ADDR(r));
+  apr_pool_create(&pool, r->pool);
+
+  if (chxj_starts_with(value, "http:") || chxj_starts_with(value, "https:")) {
+    apr_table_t *response;
+    int   response_code = 0;
+    response = chxj_serf_head(r, pool, value, &response_code);
+    if (response_code != HTTP_OK) {
+      DBG(r, "REQ[%X] end s_add_copyright_parameter (serf_req->status:[%d])", TO_ADDR(r), response_code);
+      return value;
+    }
+    content_type = (char *)apr_table_get(response, "Content-Type");
+    headers_out = response;
+  }
+  else {
+    //  sub_req = ap_sub_req_method_uri("GET", value, r, r->output_filters);
+    sub_req = ap_sub_req_lookup_uri(value, r, r->output_filters);
+    if (sub_req->status != HTTP_OK) {
+      DBG(r, "REQ[%X] end s_add_copyright_parameter (sub_req->status:[%d])", TO_ADDR(r), sub_req->status);
+      ap_destroy_sub_req(sub_req);
+      return value;
+    }
+    sub_req->header_only = 1;
+    sub_req->main = NULL;
+    rr_status = ap_run_sub_req(sub_req);
+    DBG(r, "REQ[%X] sub_req4:ContentType:[%s]", TO_ADDR(r), sub_req->content_type);
+    DBG(r, "REQ[%X] rr_status:[%d]", TO_ADDR(r), rr_status);
+    content_type = apr_pstrdup(pool, sub_req->content_type);
+    headers_out = sub_req->headers_out;
+  }
+  if (headers_out && apr_table_get(headers_out, "x-jphone-copyright")) {
+    if (content_type && strncasecmp("image/jpeg", content_type, 10) == 0) {
+      if (strchr(value, '?')) {
+        value = apr_psprintf(pool, "%s&_chxj_copy=.jpz", value);
+      }
+      else {
+        value = apr_psprintf(pool, "%s?_chxj_copy=.jpz", value);
+      }
+    }
+    else if (content_type && strncasecmp("image/png", content_type, 9) == 0) {
+      if (strchr(value, '?')) {
+        value = apr_psprintf(pool, "%s&_chxj_copy=.pnz", value);
+      }
+      else {
+        value = apr_psprintf(pool, "%s?_chxj_copy=.pnz", value);
+      }
+    }
+  }
+  if (sub_req) {
+    ap_destroy_sub_req(sub_req);
+  }
+  DBG(r, "REQ[%X] end s_add_copyright_parameter(result:[%s]", TO_ADDR(r), value);
+  return value;
+}
+
+
 /*
  * vim:ts=2 et
  */