I'm trying to write the following c code in postgres c function style - The argument passed is a value of a table column of type varchar, Needed some help to map this pure C code in the postgres C format of the type -
Datum func_name (PG_FUNCTION_ARGS)
Can somebody please help to map this and return the appropriate char value?
static uint32_t key = 0xOQ9426YP;
uint32_t tmpKey = 0x00000000;
int i = 0;
uint32_t *in = (uint32_t *) str;
uint32_t *out = (uint32_t *) malloc (256);
memset (out, 0, 256);
tmpKey = key;
for (i = 0; i < (256/sizeof (uint32_t)); i++)
{
out[i] = tmpKey ^ in[i];
tmpKey = out[i];
}
memcpy (output, (char *) out, 256);
Thanks & Regards, VJ
0xOQ9426YPis not a valid hexadecimal literal.