"Gowey, Geoffrey" <ggowey@rxhope.com> writes:
> No example that I have run across illustrates how to convert
> a param entered to be used w/ regular c functions (in this case
> strcat).
I think the technique exhibited in the 7.1 contrib/soundex module is
about the cleanest: use the text type's I/O conversion functions.
Preferably with macros to hide the notational cruft:
#define _textin(str) DatumGetPointer(DirectFunctionCall1(textin, CStringGetDatum(str)))
#define _textout(str) DatumGetPointer(DirectFunctionCall1(textout, PointerGetDatum(str)))
/*
* SQL function: text_soundex(text) returns text
*/
PG_FUNCTION_INFO_V1(text_soundex);
Datum
text_soundex(PG_FUNCTION_ARGS)
{
char outstr[SOUNDEX_LEN + 1];
char *arg;
arg = _textout(PG_GETARG_TEXT_P(0));
soundex(arg, outstr);
PG_RETURN_TEXT_P(_textin(outstr));
}
'arg' and 'outstr' are null-terminated strings here.
regards, tom lane