Advertisement
Guest User

Untitled

a guest
Jan 25th, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.11 KB | None | 0 0
  1.  
  2. /* Vittorio Camisa 0000629715 */
  3. #include <stdio.h>
  4.  
  5. #include <rpc/rpc.h>
  6.  
  7. #include "RPC_xFile.h"
  8.  
  9.  
  10.  
  11. main(int argc, char **argv)
  12.  
  13. {
  14.    
  15.  
  16.     CLIENT *c1;
  17.  
  18.     int *ris;
  19.  
  20.     char *server;
  21.  
  22.     char inp[10];
  23.  
  24.    
  25.     //variabili programma
  26.     modifica mod;
  27.     char tmp[20];
  28.     int *risInt,i;
  29.     visualizza *risV;
  30.     char *ora;
  31.     ora = (char*)malloc(10);
  32.    
  33.  
  34.     if (argc != 2)
  35.  
  36.     {
  37.  
  38.         fprintf(stderr, "uso: %s host \n", argv[0]);
  39.  
  40.         exit(1);
  41.  
  42.     }
  43.  
  44.     server = argv[1];
  45.  
  46.     puts("Inserisci:\n\tV=Visualizzare voli in arrivo\n\tM=Modifica volo\nScelta:");
  47.     while( gets(inp) )
  48.  
  49.     {
  50.         if( inp[0] == 'M' || inp[0] == 'm')
  51.         {
  52.             c1 = clnt_create(server, RPCPROG, RPCVERS, "udp");
  53.  
  54.             if (c1 == NULL)
  55.  
  56.             {
  57.  
  58.                 clnt_pcreateerror(server);
  59.  
  60.                 exit(1);
  61.  
  62.             }
  63.            
  64.             printf("Inserisci ID: ");
  65.             gets(tmp);
  66.             mod.ID = tmp;
  67.            
  68.             printf("Inserisci ritardo: ");
  69.             gets(tmp);
  70.             mod.ritardo = atoi(tmp);
  71.            
  72.             printf("Inserisci gate: ");
  73.             gets(tmp);
  74.             mod.gate = atoi(tmp);
  75.            
  76.             printf("Inserisci banco: ");
  77.             gets(tmp);
  78.             mod.banco = tmp[0];
  79.            
  80.             risInt = modifica_volo_1(&mod,c1);
  81.             if( ris == NULL)
  82.  
  83.             {
  84.  
  85.                 clnt_perror(c1,server);
  86.                 exit(1);
  87.                 //NB!!! CONTROLLARE CHE LA CHIAMATA REMOTA NON RESTITUISCA NULL!!!!
  88.  
  89.             }
  90.             if( risInt == -1)
  91.             {
  92.                 printf("Errore in modifica\n");
  93.             }
  94.             else
  95.             {
  96.                 printf("Modifiche apportate con successo\n");
  97.             }
  98.         }
  99.         else if( inp[0] == 'v' || inp[0] == 'V')
  100.         {
  101.             c1 = clnt_create(server, RPCPROG, RPCVERS, "udp");
  102.  
  103.             if (c1 == NULL)
  104.  
  105.             {
  106.  
  107.                 clnt_pcreateerror(server);
  108.  
  109.                 exit(1);
  110.  
  111.             }
  112.            
  113.             printf("Inserisci ora (hh:mm): ");
  114.             gets(ora);
  115.            
  116.            
  117.             risV = modifica_volo_1(&ora,c1);
  118.             if( risV == NULL)
  119.  
  120.             {
  121.  
  122.                 clnt_perror(c1,server);
  123.                 exit(1);
  124.                 //NB!!! CONTROLLARE CHE LA CHIAMATA REMOTA NON RESTITUISCA NULL!!!!
  125.  
  126.             }
  127.             printf("Voli in partenza entro un'ora da %s:\n",ora);
  128.             for(i=0;i<5;i++)
  129.             {
  130.                 if( risV->str[i].s != NULL)
  131.                 {
  132.                     printf("%s\n\t",risV->str[i].s);
  133.                 }
  134.             }
  135.            
  136.         }
  137.        
  138.         puts("Inserisci:\n\tV=Visualizzare voli in arrivo\n\tM=Modifica volo\nScelta:");
  139.     }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement