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_neu/phonebook_client.c | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Bachelor/Verteilte Systeme/Praktikum2/loesung_neu/phonebook_client.c (limited to 'Bachelor/Verteilte Systeme/Praktikum2/loesung_neu/phonebook_client.c') diff --git a/Bachelor/Verteilte Systeme/Praktikum2/loesung_neu/phonebook_client.c b/Bachelor/Verteilte Systeme/Praktikum2/loesung_neu/phonebook_client.c new file mode 100644 index 0000000..d78675c --- /dev/null +++ b/Bachelor/Verteilte Systeme/Praktikum2/loesung_neu/phonebook_client.c @@ -0,0 +1,79 @@ +/* + * 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 "phonebook.h" +#include + +void +phonebook_1(char *host) +{ + CLIENT *clnt; + int *result_1; + int input; + phonebookEntry add_1_arg; + str_number *result_2; + str_name search_1_arg; + +#ifndef DEBUG + clnt = clnt_create (host, Phonebook, ONE, "udp"); + if (clnt == NULL) { + clnt_pcreateerror (host); + exit (1); + } +#endif /* DEBUG */ + do + { + printf("1 add entry\n"); + printf("2 search entry\n"); + printf("0 exit\n"); + scanf("%d",&input); + switch(input) + { + case 1: { + printf("Add Entry\n"); + printf("Please enter name: "); + scanf("%s",&add_1_arg.name); + printf("Please enter number: "); + scanf("%s",&add_1_arg.number); + result_1 = add_1(&add_1_arg, clnt); + if (result_1 == (int *) NULL) { + clnt_perror (clnt, "call failed"); + } + break; + } + case 2: { + printf("Search Entry\n"); + printf("Enter name to search: "); + scanf("%s",&search_1_arg.name); + result_2 = search_1(&search_1_arg, clnt); + printf("Found: %s\n", result_2->number); + if (result_2 == (str_number *) NULL) { + clnt_perror (clnt, "call failed"); + } + break; + } + default: break; + } + } while (input != 0); +#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]; + phonebook_1 (host); +exit (0); +} -- cgit v1.2.3