SHARE
TWEET

Untitled

a guest May 23rd, 2018 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void scanUser(User *user, bool update)
  2. {
  3.     String buffer;
  4.     Text buffer_t;
  5.     int flag;
  6.  
  7.     // Inserimento username
  8.  
  9.     do{
  10.         readString(buffer, STRING_LENGTH, "Inserisci username:");
  11.     }while(!update && strcmp(buffer, "") == 0);
  12.  
  13.     if(strcmp(buffer, "") != 0)
  14.     {
  15.         strcpy(user->username, buffer);
  16.     }
  17.  
  18.     //Inserimento password
  19.  
  20.  
  21.     do{
  22.         readString(buffer, STRING_LENGTH, "Inserisci password:");
  23.  
  24.         if(strcmp(buffer, "") == 0 && update)
  25.         {
  26.             flag = 0;
  27.         }
  28.         else
  29.         {
  30.             flag = passwordCheck(buffer);
  31.         }
  32.  
  33.     }while(flag == 1);
  34.  
  35.     if(strcmp(buffer, "") != 0)
  36.     {
  37.         strcpy(user->password, buffer);
  38.     }
  39.  
  40.     //Inserimento nome
  41.  
  42.     do{
  43.         printf("Inserisci nome: ");
  44.         readString(buffer, STRING_LENGTH);
  45.     }while((mode == false) && strcmp(buffer, "") == 0);
  46.  
  47.     if(strcmp(buffer, "") != 0)
  48.     {
  49.         strcpy(user->name, buffer);
  50.     }
  51.  
  52.     //Inserimento descrizione
  53.  
  54.     do{
  55.         printf("Inserisci una descrizione: ");
  56.         readString(buffer_t, TEXT_LENGTH);
  57.     }while((mode == false) && strcmp(buffer_t, "") == 0);
  58.  
  59.     if(strcmp(buffer_t, "") != 0)
  60.     {
  61.         strcpy(user->description, buffer_t);
  62.     }
  63.  
  64.     //Inserimento data di nascita
  65.  
  66.     do{
  67.         printf("Inserisci data di nascita (GG-MM-AAAA): ");
  68.         readString(buffer, TEXT_LENGTH);
  69.     }while((mode == false) && strcmp(buffer, "") == 0);
  70.  
  71.     if(strcmp(buffer, "") != 0)
  72.     {
  73.         stringToDate(buffer, &user->birthDate);
  74.     }
  75.  
  76.     if(mode == false)
  77.     {
  78.         time_t t = time(NULL);
  79.         struct tm tm = *localtime(&t);
  80.  
  81.         user->signUpDate.day = tm.tm_mday;
  82.         user->signUpDate.month = tm.tm_mon + 1;
  83.         user->signUpDate.year = tm.tm_year + 1900;
  84.     }
  85. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top