Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Vittorio Camisa 0000629715 */
- #include <stdio.h>
- #include <rpc/rpc.h>
- #include "RPC_xFile.h"
- main(int argc, char **argv)
- {
- CLIENT *c1;
- int *ris;
- char *server;
- char inp[10];
- //variabili programma
- modifica mod;
- char tmp[20];
- int *risInt,i;
- visualizza *risV;
- char *ora;
- ora = (char*)malloc(10);
- if (argc != 2)
- {
- fprintf(stderr, "uso: %s host \n", argv[0]);
- exit(1);
- }
- server = argv[1];
- puts("Inserisci:\n\tV=Visualizzare voli in arrivo\n\tM=Modifica volo\nScelta:");
- while( gets(inp) )
- {
- if( inp[0] == 'M' || inp[0] == 'm')
- {
- c1 = clnt_create(server, RPCPROG, RPCVERS, "udp");
- if (c1 == NULL)
- {
- clnt_pcreateerror(server);
- exit(1);
- }
- printf("Inserisci ID: ");
- gets(tmp);
- mod.ID = tmp;
- printf("Inserisci ritardo: ");
- gets(tmp);
- mod.ritardo = atoi(tmp);
- printf("Inserisci gate: ");
- gets(tmp);
- mod.gate = atoi(tmp);
- printf("Inserisci banco: ");
- gets(tmp);
- mod.banco = tmp[0];
- risInt = modifica_volo_1(&mod,c1);
- if( ris == NULL)
- {
- clnt_perror(c1,server);
- exit(1);
- //NB!!! CONTROLLARE CHE LA CHIAMATA REMOTA NON RESTITUISCA NULL!!!!
- }
- if( risInt == -1)
- {
- printf("Errore in modifica\n");
- }
- else
- {
- printf("Modifiche apportate con successo\n");
- }
- }
- else if( inp[0] == 'v' || inp[0] == 'V')
- {
- c1 = clnt_create(server, RPCPROG, RPCVERS, "udp");
- if (c1 == NULL)
- {
- clnt_pcreateerror(server);
- exit(1);
- }
- printf("Inserisci ora (hh:mm): ");
- gets(ora);
- risV = modifica_volo_1(&ora,c1);
- if( risV == NULL)
- {
- clnt_perror(c1,server);
- exit(1);
- //NB!!! CONTROLLARE CHE LA CHIAMATA REMOTA NON RESTITUISCA NULL!!!!
- }
- printf("Voli in partenza entro un'ora da %s:\n",ora);
- for(i=0;i<5;i++)
- {
- if( risV->str[i].s != NULL)
- {
- printf("%s\n\t",risV->str[i].s);
- }
- }
- }
- puts("Inserisci:\n\tV=Visualizzare voli in arrivo\n\tM=Modifica volo\nScelta:");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement