Permalink
Browse files

2.0.1 release

  • Loading branch information...
1 parent 17eb882 commit 15e637be5e341ee72565e705742a2a76d442ea07 Reza Naghibi committed Mar 12, 2012
Showing with 7,190 additions and 7,065 deletions.
  1. +1 −4 HISTORY
  2. +1 −1 README
  3. +7,117 −7,024 dtrees/openddr.dtree
  4. +1 −1 nginx/nginx.conf
  5. +1 −1 openddr/gen_dtree.sh
  6. +2 −2 src/dclass_client.h
  7. +37 −8 src/dclass_file.c
  8. +3 −4 src/dtree_client.h
  9. +3 −0 src/dtree_core.c
  10. +8 −2 src/dtree_mem.c
  11. +2 −0 src/main.c
  12. +1 −8 src/ngx_http_dclass_module.c
  13. +1 −1 src/openddr_client.c
  14. +2 −1 src/openddr_client.h
  15. +1 −1 test/test.sh
  16. +5 −5 test/uas.openddr
  17. +4 −2 varnish/dclass.vcl
View
@@ -1,8 +1,5 @@
2.0.0
-
-OpenDDR support
-
1.4
-
- -Initial release
+ -Initial release
View
2 README
@@ -20,7 +20,7 @@ To integrate with the dClass API:
-populate the index using a dtree file or OpenDDR resource file:
dclass_load_file(&dci,"/path/to/file.dtree");
-OR-
- openddr_load_resources(&dci,/path/to/openddr/resources");
+ openddr_load_resources(&dci,"/path/to/openddr/resources");
-classify a string against the index and get the resulting kv data:
dclass_keyvalue *kv=dclass_classify(&dci,"this is a string");
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -11,7 +11,7 @@ http {
#these definitions are inherited by all locations
#the default header field used is: user-agent
dclass on;
- dclass_def /some/path/OpenDDR/1.0.0.3/resources;
+ dclass_def /some/path/OpenDDR/1.0.0.4/resources;
location /disabled {
#disabled
View
@@ -1,6 +1,6 @@
#!/bin/bash
-OPENDDR_RESOURCE_PATH=/some/path/OpenDDR/1.0.0.3/resources
+OPENDDR_RESOURCE_PATH=/some/path/OpenDDR/1.0.0.4/resources
DCLASS_BIN=../src/dclass_client
if [ ! -s "$DCLASS_BIN" ]
View
@@ -23,7 +23,7 @@
#include "dtree_client.h"
-#define DCLASS_VERSION "2.0.0"
+#define DCLASS_VERSION "2.0.1"
//key value struct, dtree payload
@@ -39,7 +39,7 @@ typedef struct
dclass_keyvalue;
-//key value struct, dtree payload
+//dclass index
typedef struct
{
dtree_dt_index dti;
View
@@ -24,6 +24,9 @@ typedef struct
{
char *key;
char *value;
+
+ size_t key_len;
+ size_t val_len;
} dtree_kv_pair;
typedef struct
@@ -32,9 +35,15 @@ typedef struct
char *id;
char *cparam;
char *type;
+
+ size_t id_len;
+ size_t cparam_len;
+
int count;
int legacy;
+
flag_f flag;
+
dtree_kv_pair p[DTREE_DATA_MKEYS];
} dtree_file_entry;
@@ -162,10 +171,11 @@ int dclass_load_file(dclass_index *di,const char *path)
{
for(i=0;i<fe.count;i++)
{
- s=dtree_alloc_string(h,fe.p[i].key,strlen(fe.p[i].key));
+ s=dtree_alloc_string(h,fe.p[i].key,fe.p[i].key_len);
if(!i || DTREE_DC_DISTANCE(h,s)<DTREE_DC_DISTANCE(h,(char*)fe.id))
{
fe.id=s;
+ fe.id_len=fe.p[i].key_len;
fe.type=fe.p[i].value;
}
@@ -191,10 +201,10 @@ int dclass_load_file(dclass_index *di,const char *path)
fe.flag=DTREE_DT_FLAG_NONE;
dtree_printd(DTREE_PRINT_INITDTREE,
- "LOAD: line dump: pattern: '%s' id: '%s' type: '%s' flag: %ud cparam: '%s' legacy: %d\nKVS",
- fe.pattern,fe.id,fe.type,fe.flag,fe.cparam,fe.legacy);
+ "LOAD: line dump: pattern: '%s' id: '%s':%zu type: '%s' flag: %ud cparam: '%s':%zu legacy: %d\nKVS",
+ fe.pattern,fe.id,fe.id_len,fe.type,fe.flag,fe.cparam,fe.cparam_len,fe.legacy);
for(i=0;i<fe.count;i++)
- dtree_printd(DTREE_PRINT_INITDTREE,",'%s'='%s'",fe.p[i].key,fe.p[i].value);
+ dtree_printd(DTREE_PRINT_INITDTREE,",'%s':%zu='%s':%zu",fe.p[i].key,fe.p[i].key_len,fe.p[i].value,fe.p[i].val_len);
dtree_printd(DTREE_PRINT_INITDTREE,"\n");
//look for this entry
@@ -208,7 +218,7 @@ int dclass_load_file(dclass_index *di,const char *path)
goto lerror;
//populate kvd
- kvd->id=dtree_alloc_string(h,fe.id,strlen(fe.id));
+ kvd->id=dtree_alloc_string(h,fe.id,fe.id_len);
if(dtree_add_entry(&ids,kvd->id,kvd,0,NULL)<0)
goto lerror;
@@ -257,7 +267,7 @@ int dclass_load_file(dclass_index *di,const char *path)
keys_size=fe.count;
for(i=0;i<fe.count;i++)
- keys[i]=dtree_alloc_string(h,fe.p[i].key,strlen(fe.p[i].key));
+ keys[i]=dtree_alloc_string(h,fe.p[i].key,fe.p[i].key_len);
}
kvd->keys=(const char**)keys;
@@ -272,7 +282,7 @@ int dclass_load_file(dclass_index *di,const char *path)
for(i=0;i<kvd->size;i++)
{
if(fe.p[i].value)
- kvd->values[i]=dtree_alloc_string(h,fe.p[i].value,strlen(fe.p[i].value));
+ kvd->values[i]=dtree_alloc_string(h,fe.p[i].value,fe.p[i].val_len);
}
}
@@ -294,7 +304,7 @@ int dclass_load_file(dclass_index *di,const char *path)
goto lerror;
//populate kvd
- cparam->id=dtree_alloc_string(h,fe.cparam,strlen(fe.cparam));
+ cparam->id=dtree_alloc_string(h,fe.cparam,fe.cparam_len);
if(dtree_add_entry(&ids,cparam->id,cparam,0,NULL)<0)
goto lerror;
@@ -363,6 +373,8 @@ static void dclass_parse_fentry(char *buf,dtree_file_entry *fe)
char *p;
char *t;
char *key;
+ size_t klen;
+ size_t len;
for(p=buf;*p;p++)
{
@@ -389,36 +401,53 @@ static void dclass_parse_fentry(char *buf,dtree_file_entry *fe)
sep=*p;
*p='\0';
+ len=p-t;
+
+ if(!*(p-1))
+ len--;
+
if(!count)
fe->pattern=t;
else if(count==1 && sep=='=')
{
fe->legacy=1;
count=4;
key=t;
+ klen=len;
continue;
}
else if(count==1)
+ {
fe->id=t;
+ fe->id_len=len;
+ }
else if(count==2)
fe->type=t;
else if(count==3)
+ {
fe->cparam=t;
+ fe->cparam_len=len;
+ }
else if(count>=4)
{
if(!key)
{
key=t;
+ klen=len;
+
if(sep==',')
{
t=NULL;
+ len=0;
}
else
continue;
}
fe->p[fe->count].key=key;
+ fe->p[fe->count].key_len=klen;
fe->p[fe->count].value=t;
+ fe->p[fe->count].val_len=len;
fe->count++;
View
@@ -72,8 +72,8 @@ typedef unsigned int packed_ptr;
#define DTREE_DT_MAX_SLABS 1024
#define DTREE_DT_SLAB_SIZE 1024
-#define DTREE_DT_GETPP(H,PP) ((dtree_dt_node*)PP)
-#define DTREE_DT_GENPP(P,H,L) ((packed_ptr)P);
+#define DTREE_DT_GETPP(H,PP) ((dtree_dt_node*)(PP))
+#define DTREE_DT_GENPP(P,H,L) ((packed_ptr)(P))
#endif /*DTREE_DT_PACKED*/
@@ -162,8 +162,7 @@ typedef struct
dtree_dt_node *head;
- void *slabs[DTREE_DT_MAX_SLABS];
-
+ dtree_dt_node *slabs[DTREE_DT_MAX_SLABS];
char *dc_slabs[DTREE_M_MAX_SLABS];
char *dc_cache[DTREE_M_LOOKUP_CACHE];
}
View
@@ -123,9 +123,12 @@ static int dtree_add_node(dtree_dt_index *h,dtree_dt_node *n,char *t,void *data,
while(t<p)
{
*p=*t;
+
dtree_printd(DTREE_PRINT_INITDTREE,"ADD: set: '%c' *t: '%c' t: '%s'\n",n->data,*t,p);
+
if(dtree_add_node(h,n,p,data,flags,param)<0)
return -1;
+
t++;
}
View
@@ -42,7 +42,10 @@ packed_ptr dtree_alloc_node(dtree_dt_index *h)
p=calloc(DTREE_DT_SLAB_SIZE,sizeof(dtree_dt_node));
if(!p)
+ {
+ dtree_printd(DTREE_PRINT_INITDTREE,"NMALLOC: ERROR: calloc memory allocation failure: %d\n",DTREE_DT_SLAB_SIZE);
return (packed_ptr)0;
+ }
h->size+=DTREE_DT_SLAB_SIZE*sizeof(dtree_dt_node);
h->slabs[h->slab_count]=p;
@@ -206,8 +209,11 @@ void dtree_free(dtree_dt_index *h)
for(i=0;i<h->slab_count;i++)
free(h->slabs[i]);
- for(i=0;i<h->dc_slab_count;i++)
- free(h->dc_slabs[i]);
+ for(i=0;i<DTREE_M_MAX_SLABS;i++)
+ {
+ if(h->dc_slabs[i])
+ free(h->dc_slabs[i]);
+ }
dtree_init_index(h);
}
View
@@ -193,5 +193,7 @@ int main(int argc,char **args)
}
}
+ dclass_free(&di);
+
return 0;
}
@@ -238,14 +238,7 @@ static ngx_int_t ngx_http_dclass_class_variable(ngx_http_request_t *r, ngx_http_
return NGX_OK;
}
- kvd=(dclass_keyvalue*)dclass_classify(cf->head,(char*)hfield);
-
- if(!kvd)
- {
- v->data=(u_char*)"null";
- v->len=4;
- return NGX_OK;
- }
+ kvd=dclass_classify(cf->head,(char*)hfield);
v->data=(u_char*)kvd->id;
v->len=ngx_strlen(kvd->id);
View
@@ -378,7 +378,7 @@ static char *openddr_get_value(const char *buf,const char *attr,dtree_dt_index *
}
//strcasestr
-const char *_alt_strcasestr(const char *haystack,const char *needle)
+static const char *_alt_strcasestr(const char *haystack,const char *needle)
{
const char *p;
const char *startn=0;
View
@@ -40,7 +40,8 @@
"displayWidth", \
"device_os", \
"ajax_support_javascript", \
- "is_tablet" \
+ "is_tablet", \
+ "is_wireless_device" \
}
View
@@ -1,6 +1,6 @@
#!/bin/bash
-OPENDDR_RESOURCE=/some/path/OpenDDR/1.0.0.3/resources
+OPENDDR_RESOURCE=/some/path/OpenDDR/1.0.0.4/resources
DCLASS_BIN=../src/dclass_client
if [ ! -s "uas.txt" ]
View
@@ -49,14 +49,14 @@ UA lookup 48: 'genericPhone'
UA lookup 49: 'unknown'
UA lookup 50: 'unknown'
UA lookup 51: 'LX265'
-UA lookup 52: 'SAMSUNG-SGH'
+UA lookup 52: 'SAMSUNG-SGH-T340G'
UA lookup 53: 'unknown'
UA lookup 54: 'KWC-S1300'
UA lookup 55: 'unknown'
UA lookup 56: 'SAMSUNG-SGH'
UA lookup 57: 'Samsung-SPHM540'
UA lookup 58: 'LG-MN510'
-UA lookup 59: 'SAMSUNG-SGH'
+UA lookup 59: 'SAMSUNG-SGH-T528g'
UA lookup 60: 'SCH-U360'
UA lookup 61: 'SAMSUNG-SGH-T401G'
UA lookup 62: 'NetFront'
@@ -66,7 +66,7 @@ UA lookup 65: 'SAMSUNG-SGH-T749'
UA lookup 66: 'genericPhone'
UA lookup 67: 'NetFront'
UA lookup 68: 'NetFront'
-UA lookup 69: 'genericPhone'
+UA lookup 69: 'LG-LG8575'
UA lookup 70: 'SAMSUNG-GT-S3370'
UA lookup 71: 'unknown'
UA lookup 72: 'sam-r710'
@@ -90,7 +90,7 @@ UA lookup 89: 'unknown'
UA lookup 90: 'NetFront'
UA lookup 91: 'desktopDevice'
UA lookup 92: 'SAMSUNG-SGH-A107'
-UA lookup 93: 'unknown'
+UA lookup 93: 'MOT-W418G'
UA lookup 94: 'LG290C'
UA lookup 95: 'unknown'
UA lookup 96: 'LG-GS170'
@@ -103,7 +103,7 @@ UA lookup 102: 'NetFront'
UA lookup 103: 'LG290C'
UA lookup 104: 'SCH-U360'
UA lookup 105: 'genericPhone'
-UA lookup 106: 'genericPhone'
+UA lookup 106: 'LG-LG231C'
UA lookup 107: 'SAMSUNG-SGH-T401G'
UA lookup 108: 'genericPhone'
UA lookup 109: 'KWC-Buckle'
View
@@ -7,8 +7,8 @@ backend default {
sub vcl_init {
# load openddr
- dclass.init_dclass("/some/path/OpenDDR/1.0.0.3/resources");
- #dclass.init_dclass_p("/some/path/OpenDDR/1.0.0.3/resources",0);
+ dclass.init_dclass("/some/path/OpenDDR/1.0.0.4/resources");
+ #dclass.init_dclass_p("/some/path/OpenDDR/1.0.0.4/resources",0);
# load browser dtree
dclass.init_dclass_p("/some/path/dClass/dtrees/browser.dtree",1);
@@ -40,6 +40,8 @@ OpenDDR id: "} + req.http.dclass_openddr + {"
OpenDDR device: "} + dclass.get_field("vendor") + {" "} + dclass.get_field("model") + {"
OpenDDR display: "} + dclass.get_ifield("displayWidth") + {"x"} + dclass.get_ifield("displayHeight") + {"
OpenDDR js: "} + dclass.get_field("ajax_support_javascript") + {"
+OpenDDR wireless: "} + dclass.get_field("is_wireless_device") + {"
+OpenDDR tablet: "} + dclass.get_field("is_tablet") + {"
browser id: "} + req.http.dclass_browser + {"
browser name: "} + dclass.get_field_p("browser",1) + {"

0 comments on commit 15e637b

Please sign in to comment.