OSDN Git Service

* Modified IS_CSS_ON macro.
authorkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Thu, 12 Jun 2008 12:34:34 +0000 (12:34 +0000)
committerkonn <konn@1a406e8e-add9-4483-a2c8-d8cac5b7c224>
Thu, 12 Jun 2008 12:34:34 +0000 (12:34 +0000)
  * Added link tag for CHTML1.0.
  * Change Makefile to use pcre and serf and croco

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/branches/sandbox@2708 1a406e8e-add9-4483-a2c8-d8cac5b7c224

include/chxj_apply_convrule.h
include/mod_chxj.h
src/chxj_chtml10.c
src/chxj_css.c
src/chxj_node_convert.c
src/mod_chxj.c
test/chxj_chtml10/Makefile

index d5556e9..0f41b1d 100644 (file)
@@ -19,9 +19,9 @@
 
 #include "mod_chxj.h"
 
-extern chxjconvrule_entrychxj_apply_convrule(
-  request_rec*        r, 
-  apr_array_header_tconvrules);
+extern chxjconvrule_entry *chxj_apply_convrule(
+  request_rec         *r, 
+  apr_array_header_t  *convrules);
 
 #endif
 /*
index 0182a7e..be5c1a5 100644 (file)
@@ -273,6 +273,7 @@ typedef enum {
   tagPLAINTEXT,
   tagBLINK,
   tagMARQUEE,
+  tagLINK,
 } tag_type;
 
 typedef struct mod_chxj_config mod_chxj_config;
@@ -362,11 +363,14 @@ struct mod_chxj_config {
 #define CONVRULE_ENGINE_ON_BIT        (0x00000001)
 #define CONVRULE_ENGINE_OFF_BIT       (0x00000002)
 #define CONVRULE_COOKIE_ON_BIT        (0x00000004)
+#define CONVRULE_CSS_ON_BIT           (0x00000008)
 
 #define CONVRULE_ENGINE_ON_CMD        "EngineOn"
 #define CONVRULE_ENGINE_OFF_CMD       "EngineOff"
 #define CONVRULE_COOKIE_ON_CMD        "CookieOn"
 #define CONVRULE_COOKIE_OFF_CMD       "CookieOff"
+#define CONVRULE_CSS_ON_CMD           "CssOn"
+#define CONVRULE_CSS_OFF_CMD          "CssOff"
 
 
 #define CONVRULE_FLAG_NOTMATCH        (0x00000001)
@@ -377,6 +381,8 @@ struct mod_chxj_config {
 #define CONVRULE_PC_FLAG_OFF_BIT      (0x00000002)
 
 
+#define IS_CSS_ON(X)                  ((X)->action & CONVRULE_CSS_ON_BIT)
+
 typedef struct {
   apr_global_mutex_t* cookie_db_lock;
 } mod_chxj_global_config;
index cc411c4..36b0684 100644 (file)
@@ -108,6 +108,7 @@ static char *s_chtml10_end_menu_tag       (void *pdoc, Node *node);
 static char *s_chtml10_start_plaintext_tag(void *pdoc, Node *node);
 static char *s_chtml10_start_plaintext_tag_inner(void  *pdoc, Node *node);
 static char *s_chtml10_end_plaintext_tag  (void *pdoc, Node *node);
+static char *s_chtml10_start_link_tag     (void *pdoc, Node *node);
 
 static void  s_init_chtml10(chtml10_t *chtml, Doc *doc, request_rec *r, device_table *spec);
 
@@ -381,6 +382,11 @@ tag_handler chtml10_handler[] = {
     NULL,
     NULL,
   },
+  /* tagLINK */
+  {
+    s_chtml10_start_link_tag,
+    NULL,
+  },
 };
 
 
@@ -3293,7 +3299,7 @@ s_chtml10_start_plaintext_tag_inner(void *pdoc, Node *node)
 
 
 /**
- * It is a hanplaintexter who processes the PLAINTEXT tag.
+ * It is a handler who processes the PLAINTEXT tag.
  *
  * @param pdoc  [i/o] The pointer to the CHTML structure at the output
  *                     destination is specified.
@@ -3306,6 +3312,63 @@ s_chtml10_end_plaintext_tag(void *pdoc, Node *UNUSED(child))
   chtml10_t *chtml10 = GET_CHTML10(pdoc);
   return chtml10->out;
 }
+
+
+/**
+ * It is a handler who processes the LINK tag.
+ *
+ * @param pdoc  [i/o] The pointer to the CHTML structure at the output
+ *                     destination is specified.
+ * @param node   [i]   The PLAINTEXT tag node is specified.
+ * @return The conversion result is returned.
+ */
+static char *
+s_chtml10_start_link_tag(void *pdoc, Node *node)
+{
+  chtml10_t     *chtml10;
+  Doc           *doc;
+  Attr          *attr;
+  char          *rel  = NULL;
+  char          *href = NULL;
+  char          *type = NULL;
+
+  chtml10 = GET_CHTML10(pdoc);
+  doc     = chtml10->doc;
+
+  if (! IS_CSS_ON(chtml10->entryp)) {
+    return chtml10->out;
+  }
+
+  for (attr = qs_get_attr(doc,node);
+       attr;
+       attr = qs_get_next_attr(doc,attr)) {
+    char *name  = qs_get_attr_name(doc,attr);
+    char *value = qs_get_attr_value(doc,attr);
+    if (STRCASEEQ('r','R',"rel", name)) {
+      if (value && *value) {
+        rel = value;
+      }
+    }
+    else if (STRCASEEQ('h','H',"href", name)) {
+      if (value && *value) {
+        href = value;
+      }
+    }
+    else if (STRCASEEQ('t','T',"type", name)) {
+      if (value && *value) {
+        type = value;
+      }
+    }
+  }
+
+  if (rel && href && type) {
+
+    /* この辺でCSSを読み込む */
+
+  }
+
+  return chtml10->out;
+}
 /*
  * vim:ts=2 et
  */
index 450a752..c3cf27b 100644 (file)
@@ -239,7 +239,6 @@ s_search_selector_regexp(Doc *doc, request_rec *r, apr_pool_t *pool, css_stylesh
        cur != &stylesheet->selector_head; 
        cur = (css_selector_t *)((apr_size_t)cur->ref - (apr_size_t)APR_OFFSETOF(css_selector_t, next))) {
     ap_regmatch_t match[256];
-    DBG(r, "cur->name:[%s]", cur->name);
     if (chxj_ap_regexec(pattern1, cur->name, pattern1->re_nsub + 1, match, 0) == 0) {
       DBG(r, "match(independent of)");
       ret_sel = cur;
@@ -247,19 +246,14 @@ s_search_selector_regexp(Doc *doc, request_rec *r, apr_pool_t *pool, css_stylesh
     }
     else 
     if (chxj_ap_regexec(pattern2, cur->name, pattern2->re_nsub + 1, match, 0) == 0) {
-      DBG(r, "match(depend on) [%s]", cur->name);
       char *src = apr_pstrdup(pool, cur->name);
       char *one = chxj_ap_pregsub(pool, "$1",src, pattern2->re_nsub + 1, match);
       int loop = 0;
       do {
-        DBG(r, "start do while");
         *strrchr(src, *one) = 0;
-        DBG(r, "src:[%s] one:[%c]", src, *one);
         switch (*one) {
         case '>': /* Child selectors */
-          DBG(r, "child selectors");
           if (chxj_ap_regexec(pattern3, src, pattern3->re_nsub + 1, match, 0) == 0) {
-            DBG(r, "has any parent");
             one = chxj_ap_pregsub(pool, "$1",src, pattern3->re_nsub + 1, match);
 
             char *ret = s_cmp_now_node_vs_current_style(doc, r, pool, strrchr(src, *one)+1, pattern4, node->parent);
@@ -272,8 +266,6 @@ s_search_selector_regexp(Doc *doc, request_rec *r, apr_pool_t *pool, css_stylesh
             }
           }
           else {
-            DBG(r, "parent:[%x]", node->parent);
-            DBG(r, "parent->name:[%s] src:[%s]", node->parent->name, src);
             char *ret = s_cmp_now_node_vs_current_style(doc, r, pool, src, pattern4, node->parent);
             if (ret) {
               ret_sel = cur;
@@ -285,26 +277,20 @@ s_search_selector_regexp(Doc *doc, request_rec *r, apr_pool_t *pool, css_stylesh
 
 
         case '+': /* Adjacent sibling selectors */
-          DBG(r, "sibling selectors");
           if (chxj_ap_regexec(pattern3, src, pattern3->re_nsub + 1, match, 0) == 0) {
-            DBG(r, "has any parent");
             one = chxj_ap_pregsub(pool, "$1",src, pattern3->re_nsub + 1, match);
             char *ret = s_cmp_now_node_vs_current_style(doc, r, pool, strrchr(src, *one)+1, pattern4, node->prev);
             if (ret) {
-              DBG(r, "continue do while");
               loop = 1;
               node = node->prev;
               break;
             }
           }
           else {
-            DBG(r, "now node:[%s][%x]", node->name, node);
             if (! node->prev) {
               ret_sel = NULL;
               goto end_of_search;
             }
-            DBG(r, "prev:[%x] now:[%s]", node->prev, node->name);
-            DBG(r, "prev->name:[%s] src:[%s]", node->prev->name, src);
             char *ret = s_cmp_now_node_vs_current_style(doc, r, pool, src, pattern4, node->prev);
             if (ret) {
               ret_sel = cur;
@@ -315,19 +301,15 @@ s_search_selector_regexp(Doc *doc, request_rec *r, apr_pool_t *pool, css_stylesh
 
 
         case ' ': /* Descendant selectors */
-          DBG(r, "descendant selectors");
           if (chxj_ap_regexec(pattern3, src, pattern3->re_nsub + 1, match, 0) == 0) {
-            DBG(r, "has any parent");
             one = chxj_ap_pregsub(pool, "$1",src, pattern3->re_nsub + 1, match);
             for (; node && node->parent; node = node->parent) {
               if (strcasecmp(node->name, "ROOT") == 0 || strcasecmp(node->parent->name, "ROOT") == 0) {
-                DBG(r, "unmatch");
                 loop = 0;
                 break;
               }
               char *ret = s_cmp_now_node_vs_current_style(doc, r, pool, strrchr(src, *one)+1, pattern4, node->parent);
               if (ret) {
-                DBG(r, "continue do while");
                 loop = 1;
                 node = node->parent;
                 break;
@@ -335,11 +317,8 @@ s_search_selector_regexp(Doc *doc, request_rec *r, apr_pool_t *pool, css_stylesh
             }
           }
           else {
-            DBG(r, "parent:[%x]", node);
-            DBG(r, "parent->name:[%s] src:[%s]", node->name, src);
             for (; node && node->parent; node = node->parent) {
               if (strcasecmp(node->name, "ROOT") == 0 || strcasecmp(node->parent->name, "ROOT") == 0) {
-                DBG(r, "unmatch");
                 loop = 0;
                 break;
               }
@@ -353,12 +332,10 @@ s_search_selector_regexp(Doc *doc, request_rec *r, apr_pool_t *pool, css_stylesh
           break;
         default:
           loop = 0;
-          DBG(r, "unmatch(unknown separator)");
         }
       } while(loop);
       node = node_sv;
     }
-    DBG(r, "unmatch [%s]", cur->name);
   }
 
 end_of_search:
index a0cbc55..b1e5c1c 100644 (file)
@@ -355,6 +355,19 @@ chxj_node_convert(
         if (handlers[tagLABEL].end_tag_handler)
           handlers[tagLABEL].end_tag_handler(pdoc, child);
       }
+      else
+      /*----------------------------------------------------------------------*/
+      /* <LINK>                                                               */
+      /*----------------------------------------------------------------------*/
+      if (strcasecmp(name, "link") == 0) {
+        if (handlers[tagLINK].start_tag_handler) 
+          handlers[tagLINK].start_tag_handler(pdoc, child);
+
+        chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
+
+        if (handlers[tagLINK].end_tag_handler)
+          handlers[tagLINK].end_tag_handler(pdoc, child);
+      }
       else {
         chxj_node_convert(spec, r, pdoc, doc, child, indent+1);
       }
index aa799ef..ff5e8f2 100644 (file)
@@ -2009,6 +2009,15 @@ cmd_convert_rule(cmd_parms *cmd, void *mconfig, const char *arg)
       if (strcasecmp(CONVRULE_COOKIE_ON_CMD, action) == 0) {
         newrule->action |= CONVRULE_COOKIE_ON_BIT;
       }
+      else if (strcasecmp(CONVRULE_COOKIE_OFF_CMD, action) == 0) {
+        newrule->action &= (0xffffffff ^ CONVRULE_COOKIE_ON_BIT);
+      }
+      else if (strcasecmp(CONVRULE_CSS_ON_CMD, action) == 0) {
+        newrule->action |= CONVRULE_CSS_ON_BIT;
+      }
+      else if (strcasecmp(CONVRULE_CSS_OFF_CMD, action) == 0) {
+        newrule->action &= (0xffffffff ^ CONVRULE_CSS_ON_BIT);
+      }
       break;
     default:
       break;
index 5467d1a..cdca941 100644 (file)
@@ -18,7 +18,7 @@ test: $(TARGET)
        ./$(TARGET)
 
 $(TARGET): $(TARGET).c
-       gcc -g -o $@ -Wall -lcunit $< $(INC_DIR) -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE  -lapr-1 -laprutil-1 
+       gcc -g -o $@ -Wall -lcunit $< $(INC_DIR) -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE  -lapr-1 -laprutil-1 `croco-0.6-config --cflags`  `croco-0.6-config --libs` $(TOP_DIR)/src/serf/.libs/libserf-0.a -lpcre
 
 
 clean: