1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
|
sqlite3_bind_zeroblob(st,i+8,0);
}
} else {
if(ll_data[i].sgn) sqlite3_bind_int64(st,i+8,stack->s); else sqlite3_bind_int64(st,i+8,stack->u);
}
}
}
static int vt1_levels_open(sqlite3_vtab*vt,sqlite3_vtab_cursor**cur) {
sqlite3_str*str;
sqlite3_stmt*st1;
sqlite3_stmt*st2;
const unsigned char*d;
unsigned char*p;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
|
sqlite3_bind_zeroblob(st,i+8,0);
}
} else {
if(ll_data[i].sgn) sqlite3_bind_int64(st,i+8,stack->s); else sqlite3_bind_int64(st,i+8,stack->u);
}
}
}
static int level_is_solved(const unsigned char*d,long n,int j) {
if(n<=5 || !d) return 0;
if(*d) {
return (n-(d[n-2]<<8)-d[n-1]>3 && (d[n-4]<<8)+d[n-3]==j);
} else {
long i;
for(i=1;i<n;) {
if(d[i]==0x41 && n-i>2) return (d[i+1]+(d[i+2]<<8)==j);
else if(d[i]<0x40) i+=strnlen(d+i,n-i)+1;
else if(d[i]<0x80) i+=3;
else if(d[i]<0xC0) i+=5;
else i+=9;
}
return 0;
}
}
static int vt1_levels_open(sqlite3_vtab*vt,sqlite3_vtab_cursor**cur) {
sqlite3_str*str;
sqlite3_stmt*st1;
sqlite3_stmt*st2;
const unsigned char*d;
unsigned char*p;
|
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
|
if(p) {
sqlite3_bind_int(st2,7,(n>2 && d[0]==p[0] && d[1]==p[1]));
free(p);
} else {
sqlite3_bind_int(st2,7,0);
}
d=sqlite3_column_blob(st1,2); n=sqlite3_column_bytes(st1,2);
sqlite3_bind_int(st2,6,(d && n>5 && n-(d[n-2]<<8)-d[n-1]>3 && (d[n-4]<<8)+d[n-3]==j));
while((i=sqlite3_step(st2))==SQLITE_ROW);
if(i!=SQLITE_DONE) goto err;
sqlite3_bind_null(st2,5);
for(i=0;i<ll_ndata;i++) sqlite3_bind_null(st2,i+8);
}
if(i!=SQLITE_DONE) goto err;
sqlite3_finalize(st1);
|
|
|
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
|
if(p) {
sqlite3_bind_int(st2,7,(n>2 && d[0]==p[0] && d[1]==p[1]));
free(p);
} else {
sqlite3_bind_int(st2,7,0);
}
d=sqlite3_column_blob(st1,2); n=sqlite3_column_bytes(st1,2);
sqlite3_bind_int(st2,6,level_is_solved(d,n,j));
while((i=sqlite3_step(st2))==SQLITE_ROW);
if(i!=SQLITE_DONE) goto err;
sqlite3_bind_null(st2,5);
for(i=0;i<ll_ndata;i++) sqlite3_bind_null(st2,i+8);
}
if(i!=SQLITE_DONE) goto err;
sqlite3_finalize(st1);
|