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: 15364.217.117.29.29.1231492092.squirrel@fmf.vgtu.lt (view raw or flat)
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

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-2014 The PostgreSQL Global Development Group