Postgesql lib - Mailing list pgsql-novice

From Lukas
Subject Postgesql lib
Date
Msg-id 15364.217.117.29.29.1231492092.squirrel@fmf.vgtu.lt
Whole thread Raw
Responses Re: Postgesql lib  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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@xxxxx.ltB?" when I am giving "lukas@xxxxx.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.


pgsql-novice by date:

Previous
From: Bastiaan Olij
Date:
Subject: Re: invalid byte sequence for encoding "UTF8":
Next
From: Tom Lane
Date:
Subject: Re: Postgesql lib