Hi guys,

I've read all the information about developing UDFs which I could find. I know 
that in earlier versions of Firebird it was not possible to pass NULL 
parameters. However I am using Firebird 2.5 and I want to return a NULL value 
instead of an empty BLOB. I do not want to pass NULLs. Is this possible?

Please take a look at this function:

BLOBCALLBACK blob_load(char *s, BLOBCALLBACK b)
{
    if (b->blob_handle) {
         unsigned char *buffer;
             int buffsize = 4096;
             FILE *file;
             file = fopen(s, "rb");
             if (file) {
               buffer = (unsigned char *) malloc(buffsize);
               if (buffer) {
                        int readSize;
                        for (;;) {
                          readSize = fread(buffer, 1, buffsize, file);
                          b->blob_put_segment(b->blob_handle, buffer, readSize);
                          if (readSize != buffsize) {
                                   break;
                          }
                        }
                        free(buffer);
               } 
               fclose(file);
             }
    }
    return b;
}

It loads data from the disk and returns it as a blob. The problem is that 
sometimes on the disk there might be an empty file. There is a difference 
between an empty file and a file which does not exist and I would like to 
reflect that by retuning a NULL if the file does not exist and returning an 
empty blob in a case where file exists but it is empty.

I've tried to setup blob strucutre like this:

                           b->blob_get_segment = NULL;
                           b->blob_number_segments = NULL;
                           b->blob_max_segment = NULL;
                           b->blob_total_length = NULL;
                           b->blob_put_segment = NULL;

but without success.

So..is it possible to return NULL instead of an empty blob? 

Thank you.






------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to