From: | Joel Dudley <Joel(dot)Dudley(at)DevelopOnline(dot)com> |
---|---|
To: | "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org> |
Subject: | C functions, arguments, and ssh oh my! |
Date: | 2001-03-27 19:25:32 |
Message-ID: | A04BDD2C264AD41181C000508BDCB72A4F2B8A@USAZDOLEXCH0 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello All,
I am writing my first C function for postgres and failing miserably. my C
function needs to get passed a username (char) , uid(int), and gid(int) and
what it does with those is builds a command string for an external app that
is called with system() and exits 0. I know this is strange and ugly but I
need to trigger this external app when an insert is made into a user table.
I am looking into the version 1 calling convention to get these arguments
into my C function but I can't seem to match the types correctly. I am
looking at SPI with triggers now but I don't know if that will work either.
Am I barking up the wrong tree here? any comments are appreciated and I
appreciate the time you have taken to read my post. Below is to cludgy poor
code I have so far (it doesnt work of course) and I am halfway between
converting to version 1 calling but I wanted to give you an idea of what I
am trying to do. Thanks again.
- Joel
#include <stdlib.h>
#include "postgres.h"
#include "fmgr.h"
/*int *ssh_exec(char *uname[FILENAME_MAX], char *uid[FILENAME_MAX], char
*gid[FILENAME_MAX])*/
PG_FUNCTION_INFO_V1(ssh_exec);
Datum
ssh_exec(PG_FUNCTION_ARGS)
{
char sshcmd[255];
strncpy(sshcmd, "/usr/local/bin/plsshexec ", 255);
strncat(sshcmd, *uname, 255);
strncat(sshcmd, " ", 255);
strncat(sshcmd, *uid, 255);
strncat(sshcmd, " ", 255);
strncat(sshcmd, *gid, 255);
system(sshcmd);
return 0;
}
From | Date | Subject | |
---|---|---|---|
Next Message | Alfred Perlstein | 2001-03-27 19:31:28 | Re: C functions, arguments, and ssh oh my! |
Previous Message | Patrick Aland | 2001-03-27 18:59:03 | Two tables for the price of one? |