1/* 2 * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <assert.h> 8#include <camkes.h> 9#include <stddef.h> 10#include <stdio.h> 11#include <stdlib.h> 12#include <string.h> 13 14char *a_exchange(const char *input, char **output, char **joint) 15{ 16 char *reply = strdup("This is a string from server."); 17 *output = malloc(30); 18 strncpy(*output, reply, 30); 19 (*output)[29] = '\0'; 20 21 printf("Server input: %s\n", input); 22 printf("Server joint: %s\n", *joint); 23 24 free(*joint); 25 26 *joint = malloc(50); 27 strcpy(*joint, input); 28 strcpy(*joint + strlen(input), reply); 29 30 return reply; 31} 32 33