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: 15364.217.117.29.29.1231492092.squirrel@fmf.vgtu.lt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello,

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
bit:

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 );

PG_FUNCTION_INFO_V1( hello );
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
Lukas
UAB nSoft
+370 655 10 655
http://www.nsoft.lt

--
This message has been scanned for viruses and
dangerous content by OpenProtect(http://www.openprotect.com), and is
believed to be clean.

Responses

Browse pgsql-novice by date

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