OSDN Git Service

* cast from pointer to integer of different size
[modchxj/mod_chxj.git] / src / chxj_xhtml_mobile_1_0.c
index 7e7556e..07bb1a1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2008 Atsushi Konno All rights reserved.
+ * Copyright (C) 2005-2009 Atsushi Konno All rights reserved.
  * Copyright (C) 2005 QSDN,Inc. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -646,6 +646,67 @@ s_xhtml_search_emoji(xhtml_t *xhtml, char *txt, char **rslt)
 }
 
 
+char *
+chxj_xhtml_emoji_only_converter(request_rec *r, device_table *spec, const char *src, apr_size_t len)
+{
+  apr_size_t ii;
+  Doc __doc;
+  Doc *doc;
+  xhtml_t __xhtml;
+  xhtml_t *xhtml;
+  char one_byte[2];
+  char two_byte[3];
+  apr_pool_t *pool;
+
+  xhtml = &__xhtml;
+  doc   = &__doc;
+
+  DBG(r, "REQ[%X] start chxj_xhtml_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
+  memset(doc,     0, sizeof(Doc));
+  memset(xhtml, 0, sizeof(xhtml_t));
+
+  doc->r        = r;
+  xhtml->doc  = doc;
+  xhtml->spec = spec;
+  xhtml->out  = qs_alloc_zero_byte_string(r->pool);
+  xhtml->conf = chxj_get_module_config(r->per_dir_config, &chxj_module);
+  xhtml->doc->parse_mode = PARSE_MODE_CHTML;
+
+  apr_pool_create(&pool, r->pool);
+
+  chxj_buffered_write_init(pool, &doc->buf);
+
+  for (ii=0; ii<len; ii++) {
+    char *out;
+    int   rtn;
+
+    rtn = s_xhtml_search_emoji(xhtml, (char *)&src[ii], &out);
+    if (rtn) {
+      W_V(out);
+      ii+=(rtn - 1);
+      continue;
+    }
+
+    if (is_sjis_kanji(src[ii])) {
+      two_byte[0] = src[ii+0];
+      two_byte[1] = src[ii+1];
+      two_byte[2] = 0;
+      W_V(two_byte);
+      ii++;
+    }
+    else {
+      one_byte[0] = src[ii+0];
+      one_byte[1] = 0;
+      W_V(one_byte);
+    }
+  }
+  xhtml->out = chxj_buffered_write_flush(xhtml->out, &doc->buf);
+
+  DBG(r, "REQ[%X] end chxj_xhtml_emoji_eonly_converter()", (unsigned int)(apr_size_t)r);
+  return xhtml->out;
+}
+
+
 /**
  * It is a handler who processes the HTML tag.
  *
@@ -1355,16 +1416,20 @@ s_xhtml_1_0_start_form_tag(void *pdoc, Node *node)
   W_L("<form");
   if (attr_action) {
     char *q;
-    char *unused = NULL;
+    char *old_qs = NULL;
     q = strchr(attr_action, '?');
     if (q) {
-      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 1, post_flag, &unused, CHXJ_FALSE, CHXJ_FALSE);
-      if (new_hidden_tag) {
+      new_hidden_tag = chxj_form_action_to_hidden_tag(r, doc->pool, attr_action, 1, post_flag, &old_qs, CHXJ_FALSE, CHXJ_FALSE, xhtml->entryp);
+      if (new_hidden_tag || old_qs) {
         *q = 0;
       }
     }
     W_L(" action=\"");
     W_V(attr_action);
+    if (old_qs) {
+      W_L("?");
+      W_V(old_qs);
+    }
     W_L("\"");
   }
   if (attr_method) {