-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathkcomm.h
59 lines (53 loc) · 1.2 KB
/
kcomm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include"k.h"
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <errno.h>
#if defined(WIN32)||defined(WIN64)
#include <winsock2.h>
#include<windows.h>
#include<math.h>
extern int errno;
#define ERRNO (errno=WSAGetLastError())
#else
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)>(b))?(b):(a))
#define ERRNO errno
#endif
#define SHORTBUFLEN 16384
#define BUFLEN 65536
#define LONGBUFLEN 262144
#define BUFFSIZE 65536
#define SYMSIZE 1024
#define BUFF128K 131072
#define BUFF256K 262144
#define BUFF512K 524288
#define BUFF1M 1048576
#define BUFF2M 2097152
#define BUFF4M 4194304
#define BUFF8M 8388608
#define BUFF16M 16777216
#define K3(f) K f(K x,K y,K z)
#define K4(f) K f(K x,K y,K z,K w)
#define K5(f) K f(K x,K y,K z,K w,K u)
#define K6(f) K f(K x,K y,K z,K w,K u,K v)
#define xz xK[2]
#define xw xK[3]
int kstrncpy(char*buf,K x,int n){
int i,size=x->n;
char *ptr=buf;
if (size>=n)size=n-1;
for(i=0;i<size;i++)*(ptr++)=kG(x)[i];
*ptr=0;
return size;
}