1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| struct functionsTable
{
double (_stdcall *al)(int T,double* data );
double (_stdcall *bt)(int T,double* data );
double (_stdcall *sg)(int T,double* data );
double (_stdcall *mm)(int T,double* data );
double (_stdcall *cd)(int T, double* data);
double (_stdcall *betas)(int T, double* data);
double (_stdcall *covr)(int T, double* data);
double (_stdcall *acrr)(int T, double* data);
double (_stdcall *Stbl)(double m, double g, double b, double a);
double (_stdcall *StableP)(double x, double m, double g,double b, double a);
double (_stdcall *StableF)(double x, double m, double g, double b, double a);
};
void Erreur(char const *msg)
{
fprintf(stderr, "%s\n", msg);
}
void InitFunctionTable(HMODULE hLibrary, struct functionsTable *pTable)
{
if(hLibrary == NULL) {
Erreur("Bibliothèque non chargée.");
return;
}
pTable->al = (double (_stdcall*)(int, double*)) GetProcAddress(hLibrary, "al");
pTable->bt = (double (_stdcall*)(int, double*)) GetProcAddress(hLibrary, "bt");
pTable->sg = (double (_stdcall*)(int, double*)) GetProcAddress(hLibrary, "sg");
pTable->mm = (double (_stdcall*)(int, double*)) GetProcAddress(hLibrary, "mm");
pTable->cd = (double (_stdcall*)(int, double*)) GetProcAddress(hLibrary, "cd");
pTable->betas = (double (_stdcall*)(int, double*)) GetProcAddress(hLibrary, "betas");
pTable->covr = (double (_stdcall*)(int, double*)) GetProcAddress(hLibrary, "covr");
pTable->acrr = (double (_stdcall*)(int, double*)) GetProcAddress(hLibrary, "acrr");
pTable->Stbl = (double (_stdcall*)(double, double, double, double)) GetProcAddress(hLibrary, "Stbl");
pTable->StableP = (double (_stdcall*)(double, double, double, double, double)) GetProcAddress(hLibrary, "StableP");
pTable->StableF = (double (_stdcall*)(double, double, double, double, double)) GetProcAddress(hLibrary, "StableF");
if(pTable->al == NULL) Erreur("Echec pour fonction 'al'.");
if(pTable->bt == NULL) Erreur("Echec pour fonction 'bt'.");
if(pTable->sg == NULL) Erreur("Echec pour fonction 'sg'.");
if(pTable->mm == NULL) Erreur("Echec pour fonction 'mm'.");
if(pTable->cd == NULL) Erreur("Echec pour fonction 'cd'.");
if(pTable->betas == NULL) Erreur("Echec pour fonction 'betas'.");
if(pTable->covr == NULL) Erreur("Echec pour fonction 'covr'.");
if(pTable->acrr == NULL) Erreur("Echec pour fonction 'acrr'.");
if(pTable->Stbl == NULL) Erreur("Echec pour fonction 'Stbl'.");
if(pTable->StableP == NULL) Erreur("Echec pour fonction 'StableP'.");
if(pTable->StableF == NULL) Erreur("Echec pour fonction 'StableF'.");
}
JNIEXPORT void JNICALL Initialize(JNIEnv * env, jobject thisObject)
{
if ((dll=LoadLibrary("Stable.dll"))) {
functions = malloc(struct functionsTable);
InitFunctionTable(dll, functions);
} else{
dll = NULL;
functions = NULL;
}
} |
Partager