summaryrefslogtreecommitdiff
path: root/util.h
blob: 05cef2214a367be8f53e790497a080e650336581 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#pragma once

#include <sys/socket.h>


#define PTHREAD_CHECK(func_,...) do { int ret=(func_)(__VA_ARGS__); if(ret!=0){ fprintf(stderr,#func_ ": %s\n",strerror(ret)); exit(1); } } while(0)


char* copy_buf(const char *buf,int len);
char* copy_str(const char *str);

void str_toupper(char *str);

// Returns -1 on error, 0 on success
int sendall(int sock,const char *buf,ssize_t len);
int sendallf(int sock,const char *format,...) __attribute__((format (printf, 2, 3)));