1/* 2 * Copyright 2017, Data61, CSIRO (ABN 41 687 119 230) 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <camkes.h> 8#include <buffer.h> 9#include <string.h> 10#include <stdio.h> 11 12int run(void) { 13 14 char *buffer_str = (char*)buffer; 15 while(true) { 16 /* Wait for event */ 17 ev_wait(); 18 printf("Got string: %s\n", buffer_str); 19 20 int len = strnlen(buffer_str, REVERSE_STRING_MAX_LEN); 21 for (int i = 0; i < len / 2; ++i) { 22 int swap_idx = len - i - 1; 23 char tmp = buffer_str[i]; 24 buffer_str[i] = buffer_str[swap_idx]; 25 buffer_str[swap_idx] = tmp; 26 } 27 28 /* Signal to client that we are finished */ 29 ev1_emit(); 30 } 31 32 return 0; 33} 34