]> mj.ucw.cz Git - libucw.git/blobdiff - lib/urlkey.c
Merged obj2buck.h and buck2obj.h to object.h, the number of includes
[libucw.git] / lib / urlkey.c
index f0848015c1e1c8477849f5d9a74965c086c2a6b2..34a6fc81fc1a859ce0b7e11eed976f1ef51005bc 100644 (file)
@@ -45,7 +45,7 @@ struct pxtab_node {
 #define HASH_GIVE_EQ
 #define HASH_GIVE_EXTRA_SIZE
 #define HASH_GIVE_INIT_KEY
-#define HASH_GIVE_ALLOC
+#define HASH_USE_POOL cfpool
 
 static inline uns
 pxtab_hash(HASH_KEY_DECL)
@@ -74,12 +74,6 @@ pxtab_init_key(struct pxtab_node *node, HASH_KEY_DECL)
   node->rhs = NULL;
 }
 
-static inline void *
-pxtab_alloc(uns size)
-{
-  return cfg_malloc(size);
-}
-
 #include "lib/hashtable.h"
 
 static inline byte *
@@ -266,7 +260,6 @@ url_key(byte *url, byte *buf)
       url = buf;
       buf += MAX_URL_SIZE;
     }
-  url = url_key_remove_www(url, &buf);
   DBG("\tOutput: %s", url);
   return url;
 }
@@ -275,5 +268,26 @@ void
 url_fingerprint(byte *url, struct fingerprint *fp)
 {
   byte buf[URL_KEY_BUF_SIZE];
-  return fingerprint(url_key(url, buf), fp);
+  fingerprint(url_key(url, buf), fp);
 }
+
+#ifdef TEST
+
+int main(int argc, char **argv)
+{
+  cf_read(cfdeffile);
+  url_key_init();
+  for (int i=1; i<argc; i++)
+    {
+      byte buf[URL_KEY_BUF_SIZE];
+      struct fingerprint fp;
+      byte *key = url_key(argv[i], buf);
+      fingerprint(key, &fp);
+      for (int j=0; j<12; j++)
+       printf("%02x", fp.hash[j]);
+      printf(" %s\n", key);
+    }
+  return 0;
+}
+
+#endif