pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Lonnie Cumberland <lonnie_cumberland@yahoo.com>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: pgsql-interfaces@postgresql.org
Subject: Now for the VARDATA, VARSIZE, and VARHDRSZ stuff
Date: Sun, 15 Apr 2001 14:27:55 -0700 (PDT)
Message-ID: <20010415212755.2676.qmail@web12503.mail.yahoo.com> (raw)
In-Reply-To: <Pine.LNX.4.30.0104152150520.760-100000@peter.localdomain>

Hello All,

That fixed the problem I think as I am no longer getting the loading errors and
the functions appear to be being called.

I now have a simple question about the use of these VARDATA() VARSIZE() and
VARHDRSZ() wrappers

I tried to make the modifications using the manual for reference, but there
seems to be little information related to these VAR???() wrappers and my simple
routine went off into never-never land.

I have a simple function that used to work with individual pointers.

My original simple routine:
------------------------------------------------------------------------------
void public_to_enc(char *public_userid, char *enc_userid )
{
    char ch[3];
    int i,j;
    char buff[5];
    int sp=0;
 
    // Clear out the public_userid place
    strcpy(enc_userid,"");
 
    while(*public_userid!='\0')
    {
        ch[0]=*public_userid;
        ch[1]=*(public_userid+1);
        i=atoi(ch);
        j=i;
        sp++;

        //      printf("48 sect --- i=%d\n",i);
        if((i>=1)&&(i<=10))
        {
                i+=47;
        }
        else
        //      printf("65 sect --- i=%d\n",i);
        if((i>=11)&&(i<=36))
        {
                i+=54;
        }
        else
        //      printf("97 sect --- i=%d\n",i);
        if((i>=37)&&(i<=62))
        {
                i+=60;
         }
         else
         printf("public_enc: ERROR !!!!\n\n");
 
        sprintf(buff,"%c",i);
 
        // Add the value to our string
        strcat(enc_userid,buff);
 
        public_userid+=2;
        }
}                                                                              

------------------------------------------------------------------------------

and my new modified routine of the above:
------------------------------------------------------------------------------
text *
encode(text *enc_userid)
{
    int32 new_text_size = VARSIZE(enc_userid) * 2 - VARHDRSZ;
    text *new_text = (text *) palloc(new_text_size);
 
    // Clear out the public_userid place
    memset((void *) new_text, 0, new_text_size);
 
    VARSIZE(new_text) = new_text_size;
 
    // range values
    //          (0 - 9)  ---- dec 48 - 57 ascii
    //          (A - Z)  ---- dec 65 - 90 ascii
    //          (a - z)  ---- dec 97 - 122 ascii
    char ch;
    int i,j;
    char buff[5];
    int sp=0;
 
    while(VARDATA(enc_userid)!='\0')
    {
        ch=VARDATA(enc_userid);
        i=ch;
        j=i;
        sp++;
        //      printf("48 sect --- i=%d\n",i);
        if((i>=48)&&(i<=57))
        {
                i-=47;
        }
        //      printf("65 sect --- i=%d\n",i);
        else
        if((i>=65)&&(i<=90))
        {
                i-=54;
        }
        else
        //      printf("97 sect --- i=%d\n",i);
        if((i>=97)&&(i<=122))
        {
                i-=60;
        }
        else
        printf("public encoder: ERROR !!!!\n\n");
 
        sprintf(buff,"%02d",i);
 
        // Add the value to our string
        strcat(VARDATA(new_text),VARDATA(buff));
 
        enc_userid++;
        }
    // Add the value to our string
    strcat(VARDATA(new_text),VARDATA("\0"));
 
    return (new_text);
}                                              
-------------------------------------------------------------------------------

The problem is that I do not think that I have converted the second version
over correctly and would like to know if someone could take a look to see what
might be wrong.

Also, I just wanted to say that I really appreciate all of the help that you
you have given me to get started using this interface with PostgreSQL.

Best Regards,
Lonnie



--- Peter Eisentraut <peter_e@gmx.net> wrote:
> Lonnie Cumberland writes:
> 
> > trdata=# select concat_text('a','d');
> > ERROR:  Load of file /test/trfuncs.so failed: /test/trfuncs.so: undefined
> > symbol: MemoryContextAlloc__FP17MemoryContextDataUi
> 
> Name mangling at its finest.  You need to put extern "C" around all
> #include's of PostgreSQL header files as well.
> 
> -- 
> Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter
> 


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/



view thread (5+ messages)  latest in thread

Message-ID: <20010415212755.2676.qmail@web12503.mail.yahoo.com>
Permalink:  ../20010415212755.2676.qmail@web12503.mail.yahoo.com/
Also on:    postgresql.org/message-id/20010415212755.2676.qmail@web12503.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: lonnie_cumberland@yahoo.com, peter_e@gmx.net
  Subject: Re: Now for the VARDATA, VARSIZE, and VARHDRSZ stuff
  In-Reply-To: <20010415212755.2676.qmail@web12503.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox