1/* Utility functions for the test apps */ 2 3#include <stdio.h> 4#include <kernel/OS.h> 5#include <string.h> 6#include <sys/time.h> 7#include <malloc.h> 8 9#include "sys/socket.h" 10#include "netinet/in.h" 11#include "arpa/inet.h" 12#include "sys/select.h" 13 14#include "ufunc.h" 15 16void err(int error, char *msg) 17{ 18 printf("Error: %s\n", msg); 19 printf("Code: %d\n", error); 20 printf("Desc: %s\n", strerror(error)); 21 exit(-1); 22} 23 24void test_banner(char *msg) 25{ 26 int sl = strlen(msg); 27 char *buf = (char*)malloc(sl + 5); 28 29 memset(buf, '=', sl + 4); 30 printf("%s\n", buf); 31 buf[1] = buf[sl + 2] = ' '; 32 memcpy(&buf[2], msg, sl); 33 printf("%s\n", buf); 34 memset(buf, '=', sl + 4); 35 printf("%s\n", buf); 36} 37