home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / m / menu5.c < prev    next >
C/C++ Source or Header  |  1993-02-01  |  5KB  |  166 lines

  1. /*
  2. Menu program for modem logins.
  3. Author: Alec Lanari
  4. Date: January 1993
  5. */
  6.  
  7. #define _STRING_BUILTINS
  8. #include <stdio.h>
  9. #include <curses.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12.  
  13. int main(void)
  14. {   
  15.    int option;          /*variable to record which menu option is returned*/
  16.    initscr();           /*initialization needed for curses.h calls*/ 
  17.    option=menu();       /*call function menu*/
  18.    endwin();            /*close curses.h calls*/
  19.    exit(0);
  20. } /* END MAIN */
  21.  
  22. int menu()
  23. {
  24.    int choice;         /*declare choice to be an integer*/   
  25.    int press_key;      /*variable needed to call getchar function*/ 
  26.    char *filename;     /*variable used to store filename for tranfers*/ 
  27.    char *zsend;        /*variable used to store sz command*/
  28.    char *tmp_command;  /*temp variable for command to be executed*/ 
  29.    int done;           /*boolean variable used to terminate do loop*/
  30.    done = FALSE;       /*initialize boolean variable to false*/
  31.     
  32.  
  33.    /* start a loop to check for correct input */
  34.    do
  35.    { 
  36.       refresh();       /*make current screen look like stdscr*/
  37.       clear();         /*clear the screen*/
  38.               
  39.       printf("\n\n\n\n"); 
  40.       printf(" 1 - Send a File to Unix \n ");
  41.       printf("2 - Receive a File from Unix \n ");
  42.       printf("3 - Send a File to Another Unix Site \n ");
  43.       printf("4 - Send Mail to a Remote User \n ");
  44.       printf("5 - Quit \n ");
  45.       printf("\n\n Please Enter Choice ==> ");
  46.  
  47.       scanf("%d", &choice);
  48.  
  49.       if (choice == 1)
  50.       { 
  51.      printf("\n Choice %d was entered. \n", choice);  
  52.      
  53.      /*
  54.         Call up menu for Send a File to Unix.
  55.         This will call the program rz. The program will put
  56.         the file(s) into the directory $home/transfers.
  57.      */
  58.  
  59.      refresh();
  60.      clear();
  61.      fflush(stdin);
  62.  
  63.      printf("\n\n SENDING A FILE FROM YOUR PC TO UNIX \n");
  64.      printf("\n The file will be place in the TRANSFERS directory in your account. \n");
  65.      printf("\n Start sending the file now using Zmodem. \n");
  66.  
  67.  
  68.  
  69.     /* replace this command if zmodem utilities are in another directory */
  70. /*       system("//otter/users/lanari/modem/zmodem/rz"); */
  71.  
  72.  
  73.       }  /* IF */  
  74.  
  75.       else if (choice == 2)
  76.       { 
  77.      /* Call up menu for Receive a File from Unix.
  78.         Show a listing of the directory so the user can choose
  79.         which file to get. Then run the program sz with the file
  80.         that is to be transfered. The files will be taken from
  81.         the directory $home/transfers.
  82.      */        
  83.  
  84.      refresh();   
  85.      clear();
  86.      fflush(stdin);
  87.  
  88.      printf("\n\n GET FILE FROM UNIX AND SEND IT TO YOUR PC \n"); 
  89.  
  90.      /* listing of user's TRANSFER dirctory */
  91.      printf("\n Here is a listing of your TRANSFERS directory. \n");
  92.      system("ls -alg ~/transfers");                       
  93.  
  94.      /* Ask user to input filename they want to receive */ 
  95.      printf("\n Please enter the filename you want: ");
  96.      fflush(stdin);
  97.      gets(filename);
  98.  
  99.      /* Enter command you want to run in zsend */
  100.      /* replace this command if zmodem utilities are in another directory */
  101.      /* system("//otter/users/lanari/modem/zmodem/sz"); */
  102.      zsend="file ~/transfers/"; 
  103.  
  104.      /* Initialize tmp_command as NULL */
  105.      tmp_command="\0";
  106.  
  107.      /* Copy the zsend string into the tmp_command string */
  108.      strcpy(tmp_command,zsend);                                      
  109.  
  110.      /* Concatenate tmp_command with the filename the user entered */
  111.      strcat(tmp_command,filename);    
  112.  
  113.      /* Execute the system command with the full pathname and filename */               
  114.      system(tmp_command);
  115.  
  116.      printf("\n\n");;
  117.      printf("Press RETURN to continue: ");
  118.      fflush(stdin);          /*flushes out buffer of stdin*/
  119.      press_key=getchar();    /*waits for return to be pressed from keyboard*/
  120.  
  121.  
  122.       }  /* ELSE IF */   
  123.  
  124.       else if (choice == 3)
  125.       {  
  126.      printf("\n Choice %d was entered \n", choice);
  127.  
  128.      /* Call up menu for Send a File to another Unix Site.
  129.         This will show a directory listing of $home/transfers.
  130.         The user will select a file to transfer and a site to send
  131.         it to. We will then queue the job up with uucp and send
  132.         the file to the site via uucico through a poll file.
  133.      */ 
  134.       }  /* ELSE IF */                                       
  135.  
  136.       else if (choice == 4)
  137.       {  
  138.      printf("\n Choice %d was entered \n", choice); 
  139.  
  140.      /* Call up menu for Send Mail to a Remote User.
  141.         Not sure of how to set this up just yet.
  142.      */                
  143.      system("pwd");
  144.      system("ls" " -alg");  
  145.  
  146.      printf("\n Press RETURN to continue: ");
  147.      fflush(stdin);          /*flushes out buffer of stdin*/
  148.      press_key=getchar();    /*waits for return to be pressed from keyboard*/
  149.  
  150.       }  /* ELSE IF */
  151.  
  152.       else if (choice == 5)                                      
  153.       {  
  154.      printf("\n Choice %d was entered \n", choice);        
  155.  
  156.      /* Exits this function and returns control back to main. */   
  157.      done = TRUE;
  158.      return choice;
  159.       }  /* ELSE IF */
  160.  
  161.    } while (!done); /* WHILE */ 
  162.  
  163. } /* END MENU */
  164.  
  165.  
  166.