Guest User

cliente

a guest
Jun 5th, 2016
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.29 KB | None | 0 0
  1. #include <unistd.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <fcntl.h>  
  5. #include <string.h>
  6. #include <sys/stat.h>
  7.  
  8. //Global variables
  9.  
  10. char message[BUFSIZ];
  11. char option[BUFSIZ];
  12.  
  13.  
  14. // Declaration of functions
  15.  
  16. void firstmenu();
  17. void loginserver();
  18. void adduser();
  19. void mainmenu();
  20.  
  21. //Menus
  22.  
  23. void firstmenu() {
  24.    
  25.   char answer;
  26.    
  27.   system("clear");
  28.   printf("Welcome to Message Chat!\n\n");
  29.   printf("This project was developed by:\n");
  30.   printf("Helder Bessa  up201503035@fc.up.pt    201503035\n");
  31.   printf("Rafael Novais up201508010@fc.up.pt    201508010\n\n");
  32.   printf("For more info read the README.txt file.\n\n");
  33.   printf("\nDo you have an account?(y/n)\n");
  34.  
  35.   scanf( "%c" , &answer );
  36.  
  37.   if( answer == 'y'){
  38.     system("clear");
  39.     loginserver();
  40.   }
  41.   else if (answer == 'n') {
  42.     system("clear");
  43.     adduser();
  44.   }
  45.   else firstmenu();
  46. }
  47.  
  48. void loginserver() {
  49.  
  50.   char username[80];
  51.   system("clear");
  52.   printf("Username:");
  53.   scanf("%s" ,username);
  54.   char *password = getpass("Password:");
  55.  
  56.   // check with server login information
  57. }
  58. void adduser() {
  59.   char user[80];
  60.   printf("Welcome to the sign up menu!\n\n");
  61.   printf("Write a username that nobody is using and that you like.\n");
  62.   printf("Username:");
  63.   scanf("%s",user);
  64.   // check with server if someone is using username
  65.  
  66.  
  67.  
  68.   printf("\nWrite a password\n");
  69.   char *password = getpass("Password:");
  70.   char *password2 = getpass("Confirm your password:");
  71.   if (strcmp(password, password2)==0) {
  72.     //check with server
  73.     printf("The passwords match\n");
  74.   }
  75.   else {
  76.     system("clear");
  77.     printf("The passwords don't match!\n");
  78.     adduser();
  79.   }
  80.          
  81.  
  82.  
  83. }
  84.    
  85. void mainmenu() {
  86.  
  87.   char menuoption;
  88.  
  89.   system("clear");
  90.   printf("----------Menu----------\n");
  91.   printf("(1) List online users \n");
  92.   printf("(2) Open chat \n");
  93.   printf("(3) Change password \n");
  94.   printf("(4) Logout \n");
  95.   printf("(5) Quit \n");
  96.   scanf("%c" ,&menuoption);
  97.  
  98.   switch(menuoption) {
  99.   case '1' :
  100.     break ;
  101.   case '2':
  102.     break;
  103.  
  104.   case '3':
  105.     break;
  106.  
  107.   case '4':
  108.     break;
  109.    
  110.   case '5':
  111.     system("clear");
  112.     exit(0);
  113.    
  114.     break;
  115.  
  116.   default :
  117.     printf("Invalid option\n");
  118.     mainmenu();
  119.   }  
  120. }
  121. int main() {
  122.   firstmenu();
  123. }
Add Comment
Please, Sign In to add comment