Kann nicht C Function finden

Fragen, Probleme etc. zu den prozedularen Sprachen ( PL/Tcl, PL/Perl und PL/Python).
Antworten
matke
Neuer Benutzer
Beiträge: 1
Registriert: Mi 7. Okt 2015, 12:06

Kann nicht C Function finden

Beitrag von matke » Mi 7. Okt 2015, 13:13

Hallo Leute,
ich habe Problem mit C Stored Procedure.


Das ist ein Beispiel in C, hier gibt es 2 Funktionen "isCardValid" und "getSecureKeys"

Code: Alles auswählen

#include <stdio.h>
#include <assert.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#include <openssl/des.h>
#include <openssl/rsa.h>
#include <openssl/dsa.h>
#include <openssl/hmac.h>
#include <openssl/md5.h>
#include <openssl/err.h>
#include <openssl/rand.h>

#include "postgres.h"
#include "utils/geo_decls.h"
#include "funcapi.h"

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif


int32 isCardValid (VarChar* cardNo) {
	unsigned char serviceKard1[33], serviceKard2[33], serviceKard3[33], serviceKard4[33];
	unsigned char safeKard1[33], safeKard2[33], safeKard3[33], safeKard4[33];
	unsigned char bankKard1[33], bankKard2[33], bankKard3[33], bankKard4[33];
	unsigned char bankKard5[33], bankKard6[33], bankKard7[33], bankKard8[33];
	unsigned char enteredCard[80], FN[10], tmp[60];
	int ret = 0;
/*
....
*/
	return ret;
}

text* getSecureKeys(HeapTupleHeader t, /* the current row of emp */
           int32 secureMap)
{
    bool isnull;
    int count;
    DES_cblock userkey1 , userkey2;
    DES_key_schedule k1, k2;
    DES_cblock iv = { 0, 0, 0, 0, 0, 0, 0, 0 };

    VarChar *master1, *master2, *plainSess, *encSess;
    unsigned char masterB1[33], masterB2[33], masterBF[33], fullTxt[500];
    unsigned char bM1[16], bM2[16], *p1, *p2, bMF[16], tmp[20];
    unsigned char sessionKeyPlain[16], sessionKeyEnc[16], tmpPlain[8], tmpEnc[8];
    unsigned char sessionHexPlain[33], sessionHexEnc[33];
    unsigned char FN[33], tmpS[33];

    text *new_text = (text *) palloc(1500);
/*
..............
*/

    return new_text;
}
compilirt mit:

Code: Alles auswählen

gcc -fpic -c pgsecure.c -I/usr/pgsql-9.3/include/server
gcc -shared -o libpsql_native_c_lib.so  ./pgsecure.o   -lcrypto -lssl
Function mit getSecureKeys arbeitet gut.

Code: Alles auswählen

CREATE OR REPLACE FUNCTION getsecurekeys(sch.tbl_list, integer)
  RETURNS text AS
'/opt/postgresql/9.3/libs/libpsql_native_c_lib', 'getSecureKeys'
  LANGUAGE c VOLATILE STRICT
  COST 1;
Aber Function mit isCardValid hat einen Fehler

Code: Alles auswählen

CREATE OR REPLACE FUNCTION iscardvalid(varchar)
  RETURNS integer AS
'/opt/postgresql/9.3/libs/libpsql_native_c_lib', 'isCardValid'
  LANGUAGE c VOLATILE STRICT
  COST 1;

Code: Alles auswählen

ERROR:  could not find function "isCardValid" in file "/opt/postgresql/9.3/libs/libpsql_native_c_lib.so"

********** Error **********

ERROR: could not find function "isCardValid" in file "/opt/postgresql/9.3/libs/libpsql_native_c_lib.so"
SQL state: 42883
In "libpsql_native_c_lib.so" gibt es "isCardValid" Function.
Weiß jemanden wo Problem ist?

LG, Ivan

Antworten