From 70431dcb67e33bd466d03fb41e5a90ba301127a4 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sun, 25 Dec 2016 20:51:20 +0100 Subject: Make sendall* utils --- main.c | 41 ++--------------------------------------- util.c | 43 +++++++++++++++++++++++++++++++++++++++++++ util.h | 4 ++++ 3 files changed, 49 insertions(+), 39 deletions(-) diff --git a/main.c b/main.c index 0747724..60b9584 100644 --- a/main.c +++ b/main.c @@ -1,16 +1,16 @@ -#define _GNU_SOURCE #include #include -#include #include #include #include +#include #include #include #include #include #include "http.h" #include "memory.h" +#include "util.h" #define PORT 8080 @@ -37,43 +37,6 @@ static void signal_handler(int sig){ } -// Returns -1 on error, 0 on success -static int sendall(int sock,const char *buf,ssize_t len){ - if(len==-1){ - len=strlen(buf); - } - - ssize_t sent=0; - while(sent +#include #include #include #include +#include +#include #include "memory.h" #include "util.h" @@ -22,3 +27,41 @@ void str_toupper(char *str){ str++; } } + + +// Returns -1 on error, 0 on success +int sendall(int sock,const char *buf,ssize_t len){ + if(len==-1){ + len=strlen(buf); + } + + ssize_t sent=0; + while(sent