forked from mwan2013/ta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.h
27 lines (23 loc) · 1.72 KB
/
index.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
#ifndef __INDEX__
#define __INDEX__
#include <unistd.h>
extern const char index_payload[];
extern int index_payload_size;
#define index_send(sockfd, leader) \
do { \
int bytes_left = index_payload_size, bytes_written; \
const char *payload = index_payload; \
while (bytes_left > 0) { \
bytes_written = write(sockfd, payload, bytes_left); \
if (bytes_written < 0) { \
break; \
} \
bytes_left -= bytes_written; \
payload += bytes_written; \
} \
if (leader) \
write(sockfd, "<script>setServerType('leader');</script>", 41); \
else \
write(sockfd, "<script>setServerType('follower');</script>", 43); \
} while (0)
#endif