|
|
@ -6,7 +6,9 @@ |
|
|
|
|
|
|
|
#define debug |
|
|
|
|
|
|
|
int char_to_int(char *argv, int *nombre) { |
|
|
|
enum bool {false, true}; |
|
|
|
|
|
|
|
enum bool char_to_int(char *argv, int *nombre) { |
|
|
|
char* error; |
|
|
|
error=argv; |
|
|
|
*nombre=strtol(argv,&error,10); |
|
|
@ -59,8 +61,26 @@ int main(int argc, char** argv) { |
|
|
|
#ifdef debug |
|
|
|
fprintf(stderr,"stratégie %s (branche %d)\n",argv[j],branche_etoile(i)); |
|
|
|
#endif |
|
|
|
lib_players[branche_etoile(i)] = dlopen(argv[j], RTLD_LAZY); |
|
|
|
// TODO : continuer le chargement de la bibliothèque |
|
|
|
if( (lib_players[branche_etoile(i)] = dlopen(argv[j], RTLD_LAZY)) == NULL) { |
|
|
|
/* échec du chargement, on décharge toutes les stratégies précédement chargées */ |
|
|
|
for(j=0; j<i; j++) { |
|
|
|
if(lib_players[branche_etoile(j)] != NULL) |
|
|
|
dlclose(lib_players[branche_etoile(j)]); |
|
|
|
} |
|
|
|
return 5; |
|
|
|
} else { |
|
|
|
/* on initialise la bibliothèque */ |
|
|
|
char* error; |
|
|
|
void (*library_init) (); |
|
|
|
*(void **) (&library_init) = dlsym(lib_players[branche_etoile(i)],"InitLibrary"); |
|
|
|
if((error=dlerror()) == NULL) { |
|
|
|
(*library_init)("toto"); // TODO : passer le nom de la stratégie en paramètre |
|
|
|
} |
|
|
|
#ifdef debug |
|
|
|
else |
|
|
|
fprintf(stderr,"function InitLibrary not found in stratégie (branche %d)\n",branche_etoile(i)); |
|
|
|
#endif |
|
|
|
} |
|
|
|
j++; |
|
|
|
} else { |
|
|
|
/* on ajoute un joueur réel */ |
|
|
@ -71,12 +91,21 @@ int main(int argc, char** argv) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef debug |
|
|
|
for(i=0;i<6;printf("%d ",lib_players[i++])); |
|
|
|
puts(""); |
|
|
|
#endif |
|
|
|
|
|
|
|
/* on démarre le jeu */ |
|
|
|
|
|
|
|
|
|
|
|
/* fin du jeu */ |
|
|
|
|
|
|
|
|
|
|
|
/* on décharge toutes les stratégies */ |
|
|
|
for(i=0; i<nb_player ; i++) |
|
|
|
if(lib_players[branche_etoile(i)] != NULL) |
|
|
|
dlclose(lib_players[branche_etoile(i)]); |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |