Compare commits

...

2 Commits

Author SHA1 Message Date
源文雨
4dcf6d63ef feat: add unistd header 2026-01-30 23:12:46 +08:00
源文雨
743dd4f8ef feat: adapt to latest CGI protocol 2026-01-30 23:09:38 +08:00
2 changed files with 18 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 2.6...4.1.1)
project(C302 C)
SET(CMAKE_BUILD_TYPE "Release")

17
c302.c
View File

@@ -2,8 +2,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/select.h>
#include <sys/uio.h>
#include <time.h>
#include <unistd.h>
#include "c302.h"
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);
}
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));
}
}