From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../Praktikum2/loesung/telbuch_client.c | 108 +++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 Bachelor/Verteilte Systeme/Praktikum2/loesung/telbuch_client.c (limited to 'Bachelor/Verteilte Systeme/Praktikum2/loesung/telbuch_client.c') diff --git a/Bachelor/Verteilte Systeme/Praktikum2/loesung/telbuch_client.c b/Bachelor/Verteilte Systeme/Praktikum2/loesung/telbuch_client.c new file mode 100644 index 0000000..cc846e2 --- /dev/null +++ b/Bachelor/Verteilte Systeme/Praktikum2/loesung/telbuch_client.c @@ -0,0 +1,108 @@ +/* + * This is sample code generated by rpcgen. + * These are only templates and you can use them + * as a guideline for developing your own functions. + */ + +#include "telbuch.h" + + +void +telbuch_verwaltung_1(char *host) +{ + CLIENT *clnt; + +#ifndef DEBUG + clnt = clnt_create (host, TELBUCH_VERWALTUNG, ONE, "udp"); + if (clnt == NULL) { + clnt_pcreateerror (host); + exit (1); + } +#endif /* DEBUG */ + + + /* my code START */ + addStruct addentry_1_arg; + searchStruct searchentry_1_arg; + Ergebnis* result; + void* erg; + int w; + char name[41]; + char nname[20]; + char vname[20]; + char telnr[20]; + + printf("\nOptionen:"); + printf("\n1. Eintrag suchen"); + printf("\n2. Eintrag eintragen"); + printf("\n0. Beenden"); + printf("\n\nWahl: "); + scanf("%d",&w); + + switch (w) + { + case 1: // Nach Eintrag suchen + printf("\nName: "); + scanf("%s %s",nname, vname); // Suchnamen lesen + + strcpy(name,nname); + strcat(name, " "); + strcat(name, vname); + strcpy(searchentry_1_arg.Name,name); // Parameter für Suche füllen + + result = searchentry_1(&searchentry_1_arg, clnt); // Suche durchführen + if (result == (Ergebnis *) NULL) + clnt_perror (clnt, "call failed"); + else + printf("%s\n",result->Eintrag); + break; + case 2: // Eintrag eintragen + printf("\nName: "); + scanf("%s %s",nname, vname); // Name lesen + printf("Nummer: "); + scanf("%s",telnr); // Nummer lesen + + strcpy(name, nname); + strcat(name, " "); + strcat(name, vname); + strcpy(addentry_1_arg.Name,name); // Parameter für Eintrag + strcpy(addentry_1_arg.TelNr,telnr); + result = addentry_1(&addentry_1_arg, clnt); // Eintragen durchführen + if (result == (Ergebnis *) NULL) + clnt_perror (clnt, "call failed"); + else + printf("%s\n",result->Eintrag); + break; + case 0: exit(0); + default: printf("Falsche Eingabe\n"); break; + } + /* my code END */ + + + /*result_1 = addentry_1(&addentry_1_arg, clnt); + if (result_1 == (Ergebnis *) NULL) { + clnt_perror (clnt, "call failed"); + } + result_2 = searchentry_1(&searchentry_1_arg, clnt); + if (result_2 == (Ergebnis *) NULL) { + clnt_perror (clnt, "call failed"); + }*/ +#ifndef DEBUG + clnt_destroy (clnt); +#endif /* DEBUG */ +} + + +int +main (int argc, char *argv[]) +{ + char *host; + + if (argc < 2) { + printf ("usage: %s server_host\n", argv[0]); + exit (1); + } + host = argv[1]; + telbuch_verwaltung_1 (host); +exit (0); +} -- cgit v1.2.3