static int dico_init(dico *self, PyObject *args, PyObject *kwds) { char* nomdic ; if (!PyArg_ParseTuple(args, "s", &nomdic)) { return -1; } if (Dic_load(&self->dic, nomdic)) { return -2; } return 0; }
int main(int argc, char *argv[]) { Game game ; Dictionary dic ; unsigned short int state[3] ; static char* nomdic = "../dic/ods7.dawg" ; unsigned long int seed = time(0) ; int noprint = 0; int notiret = 0; int nbessai = 1000; int c; verbeux = 0; srand48(0); state[2] = 0xB97A ; opterr = 0; while ((c = getopt (argc, argv, "qd:n:s:e:vht")) != -1) { switch (c) { case 'v': verbeux++; break; case 's': state[2]= atoi(optarg); break; case 'e': nbessai = atoi(optarg); break; case 't': notiret = 1; break; case 'q': noprint = 1; break; case 'd': nomdic = optarg; break; case 'n': seed = strtoul(optarg, NULL, 10); break; case 'h' : help() ; exit(10) ; break ; case '?': if (isprint (optopt)) { help() ; fprintf (stderr, "Option inconnue `-%c'.\n", optopt); } else { help() ; fprintf (stderr, "Caractère non reconnu dans les options `\\x%x'.\n",optopt); } return 1; default: abort (); } } if (! nomdic) { help() ; puts("Spécifier un dictionnaire avec l'option -d (ex : -d ods7.dawg)") ; exit(11); } switch (Dic_load(&dic, nomdic)) { case 0: /* cas normal */ break; case 1: help(); printf("chargement: problème d'ouverture de %s\n",nomdic) ; exit(1); break; case 2: help(); printf("chargement: mauvais en-tete de dictionnaire\n"); exit(2); break; case 3: help(); printf("chargement: problème 3 d'allocation mémoire\n"); exit(3); break; case 4: help(); printf("chargement: problème 4 d'allocation mémoire\n"); exit(4); break; case 5: help(); printf("chargement: problème de lecture des arcs du dictionnaire\n"); exit(5); break; default: help(); printf("chargement: problème non-repertorié\n"); exit(6); break; } state[0] = seed>>16 ; state[1] = seed&0x0000FFFF ; printf("<?xml version=\"1.0\"?>\n"); printf("<partie "); printf("num=\"%lu\" ",seed); printf("seed=\"%u\" ",state[2]); printf("dic=\"%s\" >\n",nomdic) ; game = Game_create(dic); main_loop(game,noprint,notiret,nbessai,state); Game_destroy(game); Dic_destroy(dic); return 0; }