From: | Joel Dudley <Joel(dot)Dudley(at)DevelopOnline(dot)com> |
---|---|
To: | "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org> |
Subject: | fmgr, C , and character arguments |
Date: | 2001-03-27 22:45:17 |
Message-ID: | A04BDD2C264AD41181C000508BDCB72A4F2B91@USAZDOLEXCH0 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello all,
I am having a bit of trouble getting my arguments formatted into a
command string for system(). Here is what I have so far for code.
#include <string.h>
#include <stdlib.h>
#include "postgres.h"
#include "fmgr.h"
PG_FUNCTION_INFO_V1(ssh_exec);
Datum
ssh_exec(PG_FUNCTION_ARGS)
{
char *uname = PG_GETARG_CHAR(0);
char *uid = PG_GETARG_CHAR(1);
char *gid = PG_GETARG_CHAR(2);
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;
}
I am thinking that strncpy is not a bad idea after moving to the V-1
function manager interface. As I am sure you can see I am a C hack at best.
what is the best way to format the string and make this code work? memcpy?
Thanks for reading my post.
- Joel
From | Date | Subject | |
---|---|---|---|
Next Message | Adam Haberlach | 2001-03-28 00:53:26 | Out of date security docs |
Previous Message | Rich Shepard | 2001-03-27 22:09:08 | Alternate data locations |