[sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-08-01 Thread Paul Harris
Hi,

I wanted to get a LOG10() function in sqlite3, and I found the
extension-functions.tgz file in http://sqlite.org/contrib

I am using the all-in-one sqlite3.h/c version of sqlite3, and the
extension-functions files don't seem to fit at all.

For example, it wants to call a function called sqlite3CreateFunc(),
which seems to have been renamed to sqlite3_create_function()

Should I even bother trying to hack these files into shape, or has
sqlite3 changed so much that these files will only serve to introduce
bugs?

Does anyone use this contribution?  Does anyone use it with a recent
sqlite3 release?

thanks
Paul

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-08-02 Thread Paul Harris
Hi,

I wanted to get a LOG10() function in sqlite3, and I found the
extension-functions.tgz file in http://sqlite.org/contrib

I am using the all-in-one sqlite3.h/c version of sqlite3, and the
extension-functions files don't seem to fit at all.

For example, it wants to call a function called sqlite3CreateFunc(),
which seems to have been renamed to sqlite3_create_function()

Should I even bother trying to hack these files into shape, or has
sqlite3 changed so much that these files will only serve to introduce
bugs?

Does anyone use this contribution?  Does anyone use it with a recent
sqlite3 release?

thanks
Paul

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-08-02 Thread Joe Wilson
--- Paul Harris <[EMAIL PROTECTED]> wrote:
> I wanted to get a LOG10() function in sqlite3, and I found the
> extension-functions.tgz file in http://sqlite.org/contrib
> 
> I am using the all-in-one sqlite3.h/c version of sqlite3, and the
> extension-functions files don't seem to fit at all.
> 
> For example, it wants to call a function called sqlite3CreateFunc(),
> which seems to have been renamed to sqlite3_create_function()
> 
> Should I even bother trying to hack these files into shape, or has
> sqlite3 changed so much that these files will only serve to introduce
> bugs?

The extension is somewhat out of date, but still usable.

sqlite3CreateFunc is an internal sqlite function to register 
the extension functions, making it incompatible with a seperately
compiled sqlite3.c. sqlite3utf8CharLen is another internal 
function used by the extension.

You could convert all the registration functions to use the external
API, or drop this file into sqlite/src and update the standard makefile.

If you want to live on the edge, put map.h, map.c, func_ext.c,
sqlite3.c and sqlite3.h in the same directory and run this:

sed 's/sqlite3RegisterBuiltinFunctions(db);/& {extern void 
sqlite3RegisterExtraFunctions(sqlite3
*db); sqlite3RegisterExtraFunctions(db);};/' sqlite3.c > sqlite3f.c
echo "" >> sqlite3f.c
echo "#include " >> sqlite3f.c
echo "" >> sqlite3f.c
sed 's/#include.*//' map.h map.c func_ext.c | \
  sed 's/sqlite3utf8CharLen/sqlite3Utf8CharLen/' >> sqlite3f.c

Then use sqlite3f.c instead of sqlite3.c to build your program.

If you're on Windows, download and install Cygwin or MSYS to get these 
UNIX commands to build sqlite3f.c.

# optional: build sqlite3 command-line shell. 
# shell.c must be in current directory.
gcc sqlite3f.c shell.c -o sqlite3f



   

Pinpoint customers who are looking for what you sell. 
http://searchmarketing.yahoo.com/

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-08-31 Thread Liam Healy
I was the one who packaged up extension-functions.tgz and posted on
contrib.  I didn't author the original code but I'd like to fix this up.
I'm not clear on what needs to be changed.  I gather that sqlite3utf8CharLen
and sqlite3CreateFunc shouldn't be used.  I'm not sure how to convert to use
the external API.  Anyone have a pointer?

Thanks.
Liam


On 8/2/07, Joe Wilson <[EMAIL PROTECTED]> wrote:
>
> --- Paul Harris <[EMAIL PROTECTED]> wrote:
> > I wanted to get a LOG10() function in sqlite3, and I found the
> > extension-functions.tgz file in http://sqlite.org/contrib
> >
> > I am using the all-in-one sqlite3.h/c version of sqlite3, and the
> > extension-functions files don't seem to fit at all.
> >
> > For example, it wants to call a function called sqlite3CreateFunc(),
> > which seems to have been renamed to sqlite3_create_function()
> >
> > Should I even bother trying to hack these files into shape, or has
> > sqlite3 changed so much that these files will only serve to introduce
> > bugs?
>
> The extension is somewhat out of date, but still usable.
>
> sqlite3CreateFunc is an internal sqlite function to register
> the extension functions, making it incompatible with a seperately
> compiled sqlite3.c. sqlite3utf8CharLen is another internal
> function used by the extension.
>
> You could convert all the registration functions to use the external
> API, or drop this file into sqlite/src and update the standard makefile.
>
> If you want to live on the edge, put map.h, map.c, func_ext.c,
> sqlite3.c and sqlite3.h in the same directory and run this:
>
> sed 's/sqlite3RegisterBuiltinFunctions(db);/& {extern void
> sqlite3RegisterExtraFunctions(sqlite3
> *db); sqlite3RegisterExtraFunctions(db);};/' sqlite3.c > sqlite3f.c
> echo "" >> sqlite3f.c
> echo "#include " >> sqlite3f.c
> echo "" >> sqlite3f.c
> sed 's/#include.*//' map.h map.c func_ext.c | \
>   sed 's/sqlite3utf8CharLen/sqlite3Utf8CharLen/' >> sqlite3f.c
>
> Then use sqlite3f.c instead of sqlite3.c to build your program.
>
> If you're on Windows, download and install Cygwin or MSYS to get these
> UNIX commands to build sqlite3f.c.
>
> # optional: build sqlite3 command-line shell.
> # shell.c must be in current directory.
> gcc sqlite3f.c shell.c -o sqlite3f
>
>
>
>
>
> 
> Pinpoint customers who are looking for what you sell.
> http://searchmarketing.yahoo.com/
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-08-31 Thread Joe Wilson
--- Liam Healy <[EMAIL PROTECTED]> wrote:
> I was the one who packaged up extension-functions.tgz and posted on
> contrib.  I didn't author the original code but I'd like to fix this up.
> I'm not clear on what needs to be changed.  I gather that sqlite3utf8CharLen
> and sqlite3CreateFunc shouldn't be used.  I'm not sure how to convert to use
> the external API.  Anyone have a pointer?

See:

  http://www.sqlite.org/capi3ref.html#sqlite3_create_function

  http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions

And include this statically in your code, if you require it:

#define SQLITE_SKIP_UTF8(zIn) {\
  if( (*(zIn++))>=0xc0 ){  \
while( (*zIn & 0xc0)==0x80 ){ zIn++; } \
  }\
}

int sqlite3Utf8CharLen(const char *zIn, int nByte){
  int r = 0;
  const u8 *z = (const u8*)zIn;
  const u8 *zTerm;
  if( nByte>=0 ){
zTerm = &z[nByte];
  }else{
zTerm = (const u8*)(-1);
  }
  assert( z<=zTerm );
  while( *z!=0 && zhttp://sims.yahoo.com/  

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-08-31 Thread Liam Healy
Thanks.  I have  changed the use of sqlite3CreateFunc to
sqlite3_create_function.  I did not need to include the source code for
sqlite3utf8CharLen because there's a sqlite3Utf8CharLen (note different
capitalization) in the library.  However, the definition
of sqlite3ReadUtf8 and needed definitions READ_UTF8, xtra_utf8_bytes,
xtra_utf8_bits, utf_mask are not in 3.4.2, so I needed to
salvage from 3.3.13 source.  This compiles and loads OK, but I'm wondering
if there is a 3.4 way of doing what sqlite3ReadUtf8 did
so that I don't have to carry the definitions.   If anyone has a suggestion
I'd appreciate hearing about it.

Liam


On 8/31/07, Joe Wilson <[EMAIL PROTECTED]> wrote:
>
> --- Liam Healy <[EMAIL PROTECTED]> wrote:
> > I was the one who packaged up extension-functions.tgz and posted on
> > contrib.  I didn't author the original code but I'd like to fix this up.
> > I'm not clear on what needs to be changed.  I gather that
> sqlite3utf8CharLen
> > and sqlite3CreateFunc shouldn't be used.  I'm not sure how to convert to
> use
> > the external API.  Anyone have a pointer?
>
> See:
>
>   http://www.sqlite.org/capi3ref.html#sqlite3_create_function
>
>   http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions
>
> And include this statically in your code, if you require it:
>
> #define SQLITE_SKIP_UTF8(zIn) {\
>   if( (*(zIn++))>=0xc0 ){  \
> while( (*zIn & 0xc0)==0x80 ){ zIn++; } \
>   }\
> }
>
> int sqlite3Utf8CharLen(const char *zIn, int nByte){
>   int r = 0;
>   const u8 *z = (const u8*)zIn;
>   const u8 *zTerm;
>   if( nByte>=0 ){
> zTerm = &z[nByte];
>   }else{
> zTerm = (const u8*)(-1);
>   }
>   assert( z<=zTerm );
>   while( *z!=0 && z SQLITE_SKIP_UTF8(z);
> r++;
>   }
>   return r;
> }
>
>


Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-08-31 Thread Joe Wilson
--- Liam Healy <[EMAIL PROTECTED]> wrote:
> Thanks.  I have  changed the use of sqlite3CreateFunc to
> sqlite3_create_function.  I did not need to include the source code for
> sqlite3utf8CharLen because there's a sqlite3Utf8CharLen (note different
> capitalization) in the library.  However, the definition

How you intend to integrate your new SQL extension functions into sqlite?
As a loadable module or as an sqlite3 source code patch?

You can't use sqlite3 internal functions such as sqlite3Utf8CharLen 
if you're making an external loadable module, which is why it was suggested
to copy the function into your code statically. You can only use the
published sqlite3 external API in this case. But your library will survive
without modifications over new sqlite3 releases.

If you're not making an external loable module and are making an sqlite3 
source patch, just use the script provided earlier in this thread to change 
the old extension sources to be compatible with the 3.4.x sqlite3.c 
amalgamation. Mind you, if you're doing the patch approach you may have to 
keep updating it with every new sqlite release.

> of sqlite3ReadUtf8 and needed definitions READ_UTF8, xtra_utf8_bytes,
> xtra_utf8_bits, utf_mask are not in 3.4.2, so I needed to
> salvage from 3.3.13 source.  This compiles and loads OK, but I'm wondering
> if there is a 3.4 way of doing what sqlite3ReadUtf8 did
> so that I don't have to carry the definitions.   If anyone has a suggestion
> I'd appreciate hearing about it.
> 
> Liam
> 
> 
> On 8/31/07, Joe Wilson <[EMAIL PROTECTED]> wrote:
> >
> > --- Liam Healy <[EMAIL PROTECTED]> wrote:
> > > I was the one who packaged up extension-functions.tgz and posted on
> > > contrib.  I didn't author the original code but I'd like to fix this up.
> > > I'm not clear on what needs to be changed.  I gather that
> > sqlite3utf8CharLen
> > > and sqlite3CreateFunc shouldn't be used.  I'm not sure how to convert to
> > use
> > > the external API.  Anyone have a pointer?
> >
> > See:
> >
> >   http://www.sqlite.org/capi3ref.html#sqlite3_create_function
> >
> >   http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions
> >
> > And include this statically in your code, if you require it:
> >
> > #define SQLITE_SKIP_UTF8(zIn) {\
> >   if( (*(zIn++))>=0xc0 ){  \
> > while( (*zIn & 0xc0)==0x80 ){ zIn++; } \
> >   }\
> > }
> >
> > int sqlite3Utf8CharLen(const char *zIn, int nByte){
> >   int r = 0;
> >   const u8 *z = (const u8*)zIn;
> >   const u8 *zTerm;
> >   if( nByte>=0 ){
> > zTerm = &z[nByte];
> >   }else{
> > zTerm = (const u8*)(-1);
> >   }
> >   assert( z<=zTerm );
> >   while( *z!=0 && z > SQLITE_SKIP_UTF8(z);
> > r++;
> >   }
> >   return r;
> > }



   

Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-09-01 Thread Liam Healy
Good point.  I guess my intent is this: I'd like to use the external
API completely if possible.  If not, I'm not sure whether to include source
or use the current library (I can see advantages to each).  I guess there
aren't external API calls that do the needed tasks, so I'll have to figure
out what to do.

Liam


On 9/1/07, Joe Wilson <[EMAIL PROTECTED]> wrote:
>
> --- Liam Healy <[EMAIL PROTECTED]> wrote:
> > Thanks.  I have  changed the use of sqlite3CreateFunc to
> > sqlite3_create_function.  I did not need to include the source code for
> > sqlite3utf8CharLen because there's a sqlite3Utf8CharLen (note different
> > capitalization) in the library.  However, the definition
>
> How you intend to integrate your new SQL extension functions into sqlite?
> As a loadable module or as an sqlite3 source code patch?
>
> You can't use sqlite3 internal functions such as sqlite3Utf8CharLen
> if you're making an external loadable module, which is why it was
> suggested
> to copy the function into your code statically. You can only use the
> published sqlite3 external API in this case. But your library will survive
> without modifications over new sqlite3 releases.
>
> If you're not making an external loable module and are making an sqlite3
> source patch, just use the script provided earlier in this thread to
> change
> the old extension sources to be compatible with the 3.4.x sqlite3.c
> amalgamation. Mind you, if you're doing the patch approach you may have to
> keep updating it with every new sqlite release.
>
> > of sqlite3ReadUtf8 and needed definitions READ_UTF8, xtra_utf8_bytes,
> > xtra_utf8_bits, utf_mask are not in 3.4.2, so I needed to
> > salvage from 3.3.13 source.  This compiles and loads OK, but I'm
> wondering
> > if there is a 3.4 way of doing what sqlite3ReadUtf8 did
> > so that I don't have to carry the definitions.   If anyone has a
> suggestion
> > I'd appreciate hearing about it.
> >
> > Liam
> >
> >
> > On 8/31/07, Joe Wilson <[EMAIL PROTECTED]> wrote:
> > >
> > > --- Liam Healy <[EMAIL PROTECTED]> wrote:
> > > > I was the one who packaged up extension-functions.tgz and posted on
> > > > contrib.  I didn't author the original code but I'd like to fix this
> up.
> > > > I'm not clear on what needs to be changed.  I gather that
> > > sqlite3utf8CharLen
> > > > and sqlite3CreateFunc shouldn't be used.  I'm not sure how to
> convert to
> > > use
> > > > the external API.  Anyone have a pointer?
> > >
> > > See:
> > >
> > >   http://www.sqlite.org/capi3ref.html#sqlite3_create_function
> > >
> > >   http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions
> > >
> > > And include this statically in your code, if you require it:
> > >
> > > #define SQLITE_SKIP_UTF8(zIn) {\
> > >   if( (*(zIn++))>=0xc0 ){  \
> > > while( (*zIn & 0xc0)==0x80 ){ zIn++; } \
> > >   }\
> > > }
> > >
> > > int sqlite3Utf8CharLen(const char *zIn, int nByte){
> > >   int r = 0;
> > >   const u8 *z = (const u8*)zIn;
> > >   const u8 *zTerm;
> > >   if( nByte>=0 ){
> > > zTerm = &z[nByte];
> > >   }else{
> > > zTerm = (const u8*)(-1);
> > >   }
> > >   assert( z<=zTerm );
> > >   while( *z!=0 && z > > SQLITE_SKIP_UTF8(z);
> > > r++;
> > >   }
> > >   return r;
> > > }
>
>
>
>
>
> 
> Yahoo! oneSearch: Finally, mobile search
> that gives answers, not web links.
> http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-09-05 Thread Liam Healy
OK I have posted a new version of extension-functions.tgz on
sqlite.org/contrib.  This version includes definitions for READ_UTF8,
sqlite3ReadUtf8, SKIP_UTF8, sqlite3utf8CharLen, xtra_utf8_bytes,
xtra_utf8_bits, utf_mask taken from the 3.3.13 source code, so it should
continue to work in sqlite 3.4.

Liam

On 9/1/07, Liam Healy <[EMAIL PROTECTED]> wrote:
>
> Good point.  I guess my intent is this: I'd like to use the external
> API completely if possible.  If not, I'm not sure whether to include
> source
> or use the current library (I can see advantages to each).  I guess there
> aren't external API calls that do the needed tasks, so I'll have to figure
> out what to do.
>
> Liam
>
>
> On 9/1/07, Joe Wilson < [EMAIL PROTECTED]> wrote:
> >
> > --- Liam Healy < [EMAIL PROTECTED]> wrote:
> > > Thanks.  I have  changed the use of sqlite3CreateFunc to
> > > sqlite3_create_function.  I did not need to include the source code
> > for
> > > sqlite3utf8CharLen because there's a sqlite3Utf8CharLen (note
> > different
> > > capitalization) in the library.  However, the definition
> >
> > How you intend to integrate your new SQL extension functions into
> > sqlite?
> > As a loadable module or as an sqlite3 source code patch?
> >
> > You can't use sqlite3 internal functions such as sqlite3Utf8CharLen
> > if you're making an external loadable module, which is why it was
> > suggested
> > to copy the function into your code statically. You can only use the
> > published sqlite3 external API in this case. But your library will
> > survive
> > without modifications over new sqlite3 releases.
> >
> > If you're not making an external loable module and are making an sqlite3
> > source patch, just use the script provided earlier in this thread to
> > change
> > the old extension sources to be compatible with the 3.4.x sqlite3.c
> > amalgamation. Mind you, if you're doing the patch approach you may have
> > to
> > keep updating it with every new sqlite release.
> >
> > > of sqlite3ReadUtf8 and needed definitions READ_UTF8, xtra_utf8_bytes,
> > > xtra_utf8_bits, utf_mask are not in 3.4.2, so I needed to
> > > salvage from 3.3.13 source.  This compiles and loads OK, but I'm
> > wondering
> > > if there is a 3.4 way of doing what sqlite3ReadUtf8 did
> > > so that I don't have to carry the definitions.   If anyone has a
> > suggestion
> > > I'd appreciate hearing about it.
> > >
> > > Liam
> > >
> > >
> > > On 8/31/07, Joe Wilson < [EMAIL PROTECTED]> wrote:
> > > >
> > > > --- Liam Healy <[EMAIL PROTECTED]> wrote:
> > > > > I was the one who packaged up extension-functions.tgz and posted
> > on
> > > > > contrib.  I didn't author the original code but I'd like to fix
> > this up.
> > > > > I'm not clear on what needs to be changed.  I gather that
> > > > sqlite3utf8CharLen
> > > > > and sqlite3CreateFunc shouldn't be used.  I'm not sure how to
> > convert to
> > > > use
> > > > > the external API.  Anyone have a pointer?
> > > >
> > > > See:
> > > >
> > > >   http://www.sqlite.org/capi3ref.html#sqlite3_create_function
> > > >
> > > >   http://www.sqlite.org/cvstrac/wiki?p=LoadableExtensions
> > > >
> > > > And include this statically in your code, if you require it:
> > > >
> > > > #define SQLITE_SKIP_UTF8(zIn) {\
> > > >   if( (*(zIn++))>=0xc0 ){  \
> > > > while( (*zIn & 0xc0)==0x80 ){ zIn++; } \
> > > >   }\
> > > > }
> > > >
> > > > int sqlite3Utf8CharLen(const char *zIn, int nByte){
> > > >   int r = 0;
> > > >   const u8 *z = (const u8*)zIn;
> > > >   const u8 *zTerm;
> > > >   if( nByte>=0 ){
> > > > zTerm = &z[nByte];
> > > >   }else{
> > > > zTerm = (const u8*)(-1);
> > > >   }
> > > >   assert( z<=zTerm );
> > > >   while( *z!=0 && z > > > SQLITE_SKIP_UTF8(z);
> > > > r++;
> > > >   }
> > > >   return r;
> > > > }
>
>


Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-09-05 Thread Joe Wilson
Hi Liam,

In func_ext.c and map.h you're including private sqlite3 header 
files: sqliteInt.h, os.h and vdbeInt.h, which change from release 
to release.

If you only use the public sqlite3.h header file instead, it has 
a greater chance of being compatible with new releases.

--- Liam Healy <[EMAIL PROTECTED]> wrote:
> OK I have posted a new version of extension-functions.tgz on
> sqlite.org/contrib.  This version includes definitions for READ_UTF8,
> sqlite3ReadUtf8, SKIP_UTF8, sqlite3utf8CharLen, xtra_utf8_bytes,
> xtra_utf8_bits, utf_mask taken from the 3.3.13 source code, so it should
> continue to work in sqlite 3.4.



   

Building a website is a piece of cake. Yahoo! Small Business gives you all the 
tools to get online.
http://smallbusiness.yahoo.com/webhosting 

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-09-10 Thread Liam Healy
Thanks for the tip Joe.  With sqlite3.h included, I can eliminate os.h and
vdbeInt.h, but not sqliteInt.h.  Apparently sqliteInt.h is not included by
sqlite3.h, and there are typedefs there that are needed.

Liam

On 9/5/07, Joe Wilson <[EMAIL PROTECTED]> wrote:
>
> Hi Liam,
>
> In func_ext.c and map.h you're including private sqlite3 header
> files: sqliteInt.h, os.h and vdbeInt.h, which change from release
> to release.
>
> If you only use the public sqlite3.h header file instead, it has
> a greater chance of being compatible with new releases.
>
> --- Liam Healy <[EMAIL PROTECTED]> wrote:
> > OK I have posted a new version of extension-functions.tgz on
> > sqlite.org/contrib.  This version includes definitions for READ_UTF8,
> > sqlite3ReadUtf8, SKIP_UTF8, sqlite3utf8CharLen, xtra_utf8_bytes,
> > xtra_utf8_bits, utf_mask taken from the 3.3.13 source code, so it should
> > continue to work in sqlite 3.4.
> 
>
>


Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-09-10 Thread Joe Wilson
--- Liam Healy <[EMAIL PROTECTED]> wrote:
> Thanks for the tip Joe.  With sqlite3.h included, I can eliminate os.h and
> vdbeInt.h, but not sqliteInt.h.  Apparently sqliteInt.h is not included by
> sqlite3.h, and there are typedefs there that are needed.

It would be nice if people could use the extension functions with
the amalgamation, consisting of just sqlite3.h and sqlite3.c. 
If you use sqliteInt.h, they can't do that.

Why not just repeat the typdefs for u8, etc, in your module?



   

Building a website is a piece of cake. Yahoo! Small Business gives you all the 
tools to get online.
http://smallbusiness.yahoo.com/webhosting 

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-09-11 Thread Nuno Lucas
On 9/10/07, Joe Wilson <[EMAIL PROTECTED]> wrote:
> --- Liam Healy <[EMAIL PROTECTED]> wrote:
> > Thanks for the tip Joe.  With sqlite3.h included, I can eliminate os.h and
> > vdbeInt.h, but not sqliteInt.h.  Apparently sqliteInt.h is not included by
> > sqlite3.h, and there are typedefs there that are needed.
>
> It would be nice if people could use the extension functions with
> the amalgamation, consisting of just sqlite3.h and sqlite3.c.
> If you use sqliteInt.h, they can't do that.
>
> Why not just repeat the typdefs for u8, etc, in your module?

Don't know current compiler standard compliance, but maybe including
the "new"  header file and using uint8_t, uint16_t, etc.
could be better yet (instead of every library having it's own typedef
section for basic types).


Regards,
~Nuno Lucas

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-09-14 Thread Liam Healy
I tried eliminating sqliteInt.h and replacing with explicit declarations
of i64 and u8.   That part worked fine, but func_ext.c also uses
sqliteMalloc
which is also defined in sqliteInt.h which led me down a rabbit hole of
pulling
more and more from sqliteInt.h, and I still can't eliminate the errors and
warnings.  As a reminder, I didn't write the original source code, and I
have
only the vaguest sense of the meaning and need for these functions.  So, if
anyone has any insight on how to accomplish the same goal without using
internal definitions, I'd appreciate hearing about it.

Liam

On 9/11/07, Nuno Lucas <[EMAIL PROTECTED]> wrote:
>
> On 9/10/07, Joe Wilson <[EMAIL PROTECTED]> wrote:
> > --- Liam Healy <[EMAIL PROTECTED]> wrote:
> > > Thanks for the tip Joe.  With sqlite3.h included, I can eliminate os.hand
> > > vdbeInt.h, but not sqliteInt.h.  Apparently sqliteInt.h is not
> included by
> > > sqlite3.h, and there are typedefs there that are needed.
> >
> > It would be nice if people could use the extension functions with
> > the amalgamation, consisting of just sqlite3.h and sqlite3.c.
> > If you use sqliteInt.h, they can't do that.
> >
> > Why not just repeat the typdefs for u8, etc, in your module?
>
> Don't know current compiler standard compliance, but maybe including
> the "new"  header file and using uint8_t, uint16_t, etc.
> could be better yet (instead of every library having it's own typedef
> section for basic types).
>
>
> Regards,
> ~Nuno Lucas
>
>
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
>
> -
>
>


Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-09-14 Thread Nuno Lucas
On 9/14/07, Liam Healy <[EMAIL PROTECTED]> wrote:
> I tried eliminating sqliteInt.h and replacing with explicit declarations
> of i64 and u8.   That part worked fine, but func_ext.c also uses
> sqliteMalloc

void *sqlite3_malloc(int);
void *sqlite3_realloc(void*, int);
void sqlite3_free(void*);

are the right functions to use (they are in sqlite3.h).

> which is also defined in sqliteInt.h which led me down a rabbit hole of
> pulling
> more and more from sqliteInt.h, and I still can't eliminate the errors and
> warnings.  As a reminder, I didn't write the original source code, and I
> have
> only the vaguest sense of the meaning and need for these functions.  So, if
> anyone has any insight on how to accomplish the same goal without using
> internal definitions, I'd appreciate hearing about it.

I attached a patch with the required changes just to compile using
only .
Used the current source code of the extensions on the contrib page.

This is not enough to create a sqlite module, but at least it compiles
without using the private sqlite headers.


Regards,
~Nuno Lucas

>
> Liam
diff -urN orig/func_ext.c fixed/func_ext.c
--- orig/func_ext.c	2007-09-05 21:29:10.0 +0100
+++ fixed/func_ext.c	2007-09-15 05:16:34.0 +0100
@@ -13,13 +13,13 @@
 #define HAVE_COSH 1
 #define HAVE_TANH 1
 #define HAVE_LOG10 1
-#define HAVE_ISBLANK 1
+//#define HAVE_ISBLANK 1
 #define SQLITE_SOUNDEX 1
 #define HAVE_TRIM 1		/* LMH 2007-03-25 if sqlite has trim functions */
 
 //#if SQLITE_WITH_EXTRA_FUNCTIONS
 
-#include "sqliteInt.h"
+#include "sqlite3.h"
 #include 
 /* relicoder */
 #include 
@@ -29,10 +29,18 @@
 
 #include 
 #include 
-#include "vdbeInt.h"
-#include "os.h"
 #include "map.h"
 
+
+typedef uint8_t u8;
+typedef uint16_tu16;
+typedef int64_t i64;
+
+static char *sqlite3StrDup( const char *z ) {
+char *res = sqlite3_malloc( strlen(z)+1 );
+return strcpy( res, z );
+}
+
 /*
 ** These are copied verbatim from fun.c so as to not have the names exported
 */
@@ -98,6 +106,55 @@
   0x,
 };
 
+/* LMH salvaged from sqlite3 3.3.13 source code src/utf.c */
+#define READ_UTF8(zIn, c) { \
+  int xtra;\
+  c = *(zIn)++;\
+  xtra = xtra_utf8_bytes[c];   \
+  switch( xtra ){  \
+case 4: c = (int)0xFFFD; break;\
+case 3: c = (c<<6) + *(zIn)++; \
+case 2: c = (c<<6) + *(zIn)++; \
+case 1: c = (c<<6) + *(zIn)++; \
+c -= xtra_utf8_bits[xtra]; \
+if( (utf_mask[xtra]&c)==0  \
+|| (c&0xF800)==0xD800  \
+|| (c&0xFFFE)==0xFFFE ){  c = 0xFFFD; }\
+  }\
+}
+
+static int sqlite3ReadUtf8(const unsigned char *z){
+  int c;
+  READ_UTF8(z, c);
+  return c;
+}
+
+#define SKIP_UTF8(zIn) {   \
+  zIn += (xtra_utf8_bytes[*(u8 *)zIn] + 1);\
+}
+
+/*
+** pZ is a UTF-8 encoded unicode string. If nByte is less than zero,
+** return the number of unicode characters in pZ up to (but not including)
+** the first 0x00 byte. If nByte is not less than zero, return the
+** number of unicode characters in the first nByte of pZ (or up to 
+** the first 0x00, whichever comes first).
+*/
+static int sqlite3Utf8CharLen(const char *z, int nByte){
+  int r = 0;
+  const char *zTerm;
+  if( nByte>=0 ){
+zTerm = &z[nByte];
+  }else{
+zTerm = (const char *)(-1);
+  }
+  assert( z<=zTerm );
+  while( *z!=0 && zneedCollSeq = 1;
   }
 }
+#endif
   }
 
   for(i=0; ineedCollSeq = 1;
   }
 }
+#endif
   }
 }
 
 //#endif
-
-
-/* LMH salvaged from sqlite3 3.3.13 source code src/utf.c */
-#define READ_UTF8(zIn, c) { \
-  int xtra;\
-  c = *(zIn)++;\
-  xtra = xtra_utf8_bytes[c];   \
-  switch( xtra ){  \
-case 4: c = (int)0xFFFD; break;\
-case 3: c = (c<<6) + *(zIn)++; \
-case 2: c = (c<<6) + *(zIn)++; \
-case 1: c = (c<<6) + *(zIn)++; \
-c -= xtra_utf8_bits[xtra]; \
-if( (utf_mask[xtra]&c)==0  \
-|| (c&0xF800)==0xD800  \
-|| (c&0xFFFE)==0xFFFE ){  c = 0xFFFD; }\
-  }\
-}
-int sqlite3ReadUtf8(const unsigned char *z){
-  int c;
-  READ_UTF8(z, c);
-  return c;
-}
-
-#define SKIP_UTF8(zIn) {   \
-  zIn += (xtra_utf8_bytes[*(u8 *)zIn] + 1);\
-}
-
-/*
-** pZ is a UTF-8 encoded unicode string. If nByte is less than zero,
-** return the number of unicode cha

Re: [sqlite] extension-functions.tgz for sqlite3 3.4.1 ?

2007-09-17 Thread Liam Healy
Thank you Nuno and Joe for your help.  I have posted a new version, now
called extension-functions.c, which works on external interfaces only and
therefore does not require the sqlite3 source code.  I have made everything
a single C file with instructions as a comment at the top, hence no need for
a tarball.  I made some revisions so that it will compile without warnings
under Mac OS X, which is fussier about unsigned vs. signed chars.

Liam

On 9/15/07, Nuno Lucas <[EMAIL PROTECTED]> wrote:
>
> On 9/14/07, Liam Healy <[EMAIL PROTECTED]> wrote:
> > I tried eliminating sqliteInt.h and replacing with explicit declarations
> > of i64 and u8.   That part worked fine, but func_ext.c also uses
> > sqliteMalloc
>
> void *sqlite3_malloc(int);
> void *sqlite3_realloc(void*, int);
> void sqlite3_free(void*);
>
> are the right functions to use (they are in sqlite3.h).
>
> > which is also defined in sqliteInt.h which led me down a rabbit hole of
> > pulling
> > more and more from sqliteInt.h, and I still can't eliminate the errors
> and
> > warnings.  As a reminder, I didn't write the original source code, and I
> > have
> > only the vaguest sense of the meaning and need for these functions.  So,
> if
> > anyone has any insight on how to accomplish the same goal without using
> > internal definitions, I'd appreciate hearing about it.
>
> I attached a patch with the required changes just to compile using
> only .
> Used the current source code of the extensions on the contrib page.
>
> This is not enough to create a sqlite module, but at least it compiles
> without using the private sqlite headers.
>
>
> Regards,
> ~Nuno Lucas
>
> >
> > Liam
>
>