Skip site navigation (1) Skip section navigation (2)

Postgesql lib

From: "Lukas" <lukas(at)fmf(dot)vtu(dot)lt>
To: pgsql-novice(at)postgresql(dot)org
Subject: Postgesql lib
Date: 2009-01-09 09:08:12
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice

 I am trying to write simple PG Lib on C (on Linux), it is working, bus I
have some problem with data types, maybe someone can explain me a little

1. What is wrong with my assignments (first To = PG_GETARG_TEXT_P(0),
later VARDATA(To)? Because send mail gets something like this
"lukas(at)xxxxx(dot)ltB?" when I am giving "lukas(at)xxxxx(dot)lt" as a function
parameter in sql query.
2. Can anyone explain use and return values of VARDATA?
3. Any more comments on code below? it works, but data passes to sendmail
is with "garbage"..?

Datum hello( PG_FUNCTION_ARGS );


    text *To, *Subject, *Body;

    To = PG_GETARG_TEXT_P(0);
    Subject = PG_GETARG_TEXT_P(1);
    Body = PG_GETARG_TEXT_P(2);

    FILE *sendmail;
    sendmail = popen (SENDMAILPATH, "w");

    fprintf (sendmail, "To: %s\n", VARDATA(To));
    fprintf (sendmail, "Subject: %s\n", VARDATA(Subject));
    fprintf (sendmail, "%s\n", VARDATA(Body));

    ats = pclose (sendmail);
    PG_RETURN_TEXT_P( ats );

Thank you
UAB nSoft
+370 655 10 655

This message has been scanned for viruses and
dangerous content by OpenProtect(, and is
believed to be clean.


pgsql-novice by date

Next:From: Tom LaneDate: 2009-01-09 13:15:38
Subject: Re: Postgesql lib
Previous:From: Bastiaan OlijDate: 2009-01-08 21:32:42
Subject: Re: invalid byte sequence for encoding "UTF8":

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group