mirror of
https://github.com/fumiama/C302.git
synced 2026-02-15 11:49:46 +09:00
Compare commits
2 Commits
728f72e8f6
...
4dcf6d63ef
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4dcf6d63ef | ||
|
|
743dd4f8ef |
@@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 2.6)
|
cmake_minimum_required(VERSION 2.6...4.1.1)
|
||||||
project(C302 C)
|
project(C302 C)
|
||||||
SET(CMAKE_BUILD_TYPE "Release")
|
SET(CMAKE_BUILD_TYPE "Release")
|
||||||
|
|
||||||
|
|||||||
17
c302.c
17
c302.c
@@ -2,8 +2,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/select.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include "c302.h"
|
#include "c302.h"
|
||||||
|
|
||||||
static void http_error(errcode_enum_t code, char* msg) {
|
static void http_error(errcode_enum_t code, char* msg) {
|
||||||
@@ -31,3 +33,18 @@ int main(int argc, char **argv) {
|
|||||||
};
|
};
|
||||||
return writev(1, (const struct iovec *)&iov, 4) != len+sizeof(uint32_t);
|
return writev(1, (const struct iovec *)&iov, 4) != len+sizeof(uint32_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __attribute__((destructor)) defer_close_fp() {
|
||||||
|
fflush(stdout);
|
||||||
|
char buf[256];
|
||||||
|
fd_set rfds;
|
||||||
|
struct timeval tv;
|
||||||
|
int ret;
|
||||||
|
FD_ZERO(&rfds);
|
||||||
|
FD_SET(0, &rfds);
|
||||||
|
tv.tv_sec = 1;
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
if (select(1, &rfds, NULL, NULL, &tv) > 0 && FD_ISSET(0, &rfds)) {
|
||||||
|
read(0, buf, sizeof(buf));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user