Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int autenticazione(char *user, char *pass){// funzione da rivedere
- int ris=0;
- char temp[MAX_DIM];
- char *userid;
- char *passID;
- FILE *fileAutentic=fopen("autenticazione", "");//file per salvare gli utenti rgistrati
- if(fileAutentic==NULL)
- ERRORE("errore nella fopen\n");
- while(!feof(fileAutentic)){
- int userID = fscanf(fileAutentic, "%s", &userid)
- if(userID==-1)
- ERRORE("errore nella fscanf\n");
- while(userID!=0){// userID!=0, quindi ha letto un user
- if(strcmp(temp,user)==0){ // vede se l'user passato è presente nel file
- int password = fscanf(fileAutentic, "%s", &passID) {
- if(password==-1)
- ERRORE("errore nella fscanf\n");
- }
- if(strcmp(temp,pass)==0){ // confronta le password
- ris=1;// sono uguali, quindi l'utente già è presente;
- }
- }
- }
- if(ris==0){// l'utente non c'è, si deve iscrivere
- int registraUser=fprintf(fileAutentic,"%s\n",user);
- if(registraUser<0) ERRORE("errore nella read\n");
- int registraPass=fprintf(fileAutentic,"%s\n",pass);
- if(registraPass<0) ERRORE("errore nella read\n");
- ris=1; //l'utente è si è appena registrato, non ha una sua lista messaggi, la si deve creare
- lista=nuovaListaMess();
- }
- int close=fclose(fileAutentic);
- if (close < 0) ERRORE("errore nella fclose\n");
- return ris;
- }
Add Comment
Please, Sign In to add comment