/*{{{ quit -- quit with confirm*/ int quit() { struct menu_state *state; /* place to keep menu state */ int confirm; /* confirm the quit */ state = menu_define(font,quit_menu,0,0,MENU_COLOR); state = menu_setup(state,screen,mousex,mousey,0); /* The extra call to menu_get() makes the use of the mouse buttons consistent on the menus; namely the action is selected by the button going up. */ menu_get(state,mouse,BUTTON_SYS,0); menu_get(state,mouse,0,0); confirm = menu_ischoice(state) ? menu_choice(state) : 0; menu_destroy(state); if (confirm == M_QUIT) { _quit(); exit(0); } else if (confirm == M_SUSPEND) suspend(); }
int searchServerInfo(char* progName, char* serverAddress, char* serverPort) { /* Nom du fichier demandé */ char* filename; /* Déclaration de la liste chainée contenant les noms des fichiers disponibles*/ list ma_liste = NULL; /* Set connection with server */ sockcli = sockConnect(serverAddress, serverPort); /* Get list of available files from server */ ma_liste = getFilenameList(sockcli); /* Boucle infinie */ while (true) { /* Print list of available files */ printf("\n\n Fichiers disponibles\n\n"); print_list(ma_liste); printf("\n"); /* Select one file from the list */ filename = menu_choice(ma_liste); /* Send the requested file to the server. */ sendFilename(filename); /* Receive the file content from the server. */ getFileContent(progName, filename, sockcli); } printf("\n[%ld] Fermeture de la socket.\n\n \n", (long int) getpid()); close(sockcli); return EXIT_SUCCESS; }