diff options
author | Max Christian Pohle | 2021-11-23 19:19:07 +0100 |
---|---|---|
committer | Max Christian Pohle | 2021-11-23 19:21:08 +0100 |
commit | dd41b7c512c6f2bde11dd9378a49a17b80d7df92 (patch) | |
tree | f9465db51d43603adc602c63f9cd80395eaff670 | |
parent | 7991c931a0d7a6888ca151869137b7f9ab78852c (diff) | |
download | ohmycgi-dd41b7c512c6f2bde11dd9378a49a17b80d7df92.tar.bz2 ohmycgi-dd41b7c512c6f2bde11dd9378a49a17b80d7df92.zip |
simplified further for initial compatibility with FreeBSD
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | main.c | 4 |
2 files changed, 7 insertions, 4 deletions
@@ -6,6 +6,11 @@ CFLAGS := ${cflags.${BUILD}} | |||
6 | 6 | ||
7 | LIBS := -lcups | 7 | LIBS := -lcups |
8 | 8 | ||
9 | CFLAGS += -L/usr/local/lib | ||
10 | CFLAGS += -I/usr/local/include | ||
11 | |||
12 | FILES := cgi.c | ||
13 | |||
9 | test: main | 14 | test: main |
10 | ./main | 15 | ./main |
11 | 16 | ||
@@ -15,5 +20,5 @@ clean: | |||
15 | rm -f ./main | 20 | rm -f ./main |
16 | 21 | ||
17 | %: | 22 | %: |
18 | $(CC) $(CFLAGS) -o $@ cgi.c main.c $(LIBS) | 23 | $(CC) $(CFLAGS) -o $@ $(FILES) main.c $(LIBS) |
19 | 24 | ||
@@ -254,7 +254,7 @@ static int serve(int server_fd) | |||
254 | } | 254 | } |
255 | 255 | ||
256 | int main(const int argc, char const * argv[]) { | 256 | int main(const int argc, char const * argv[]) { |
257 | int server_fd = -1, opt = 1; | 257 | int server_fd = -1; |
258 | 258 | ||
259 | int port = atoi(argc > 1 ? argv[1] : "8080"); | 259 | int port = atoi(argc > 1 ? argv[1] : "8080"); |
260 | 0 == port ? port = 8080 : port; | 260 | 0 == port ? port = 8080 : port; |
@@ -269,8 +269,6 @@ int main(const int argc, char const * argv[]) { | |||
269 | // I <3 C | 269 | // I <3 C |
270 | 0 == (server_fd = socket(AF_INET, SOCK_STREAM, 0)) | 270 | 0 == (server_fd = socket(AF_INET, SOCK_STREAM, 0)) |
271 | ? err(errno, NULL) | 271 | ? err(errno, NULL) |
272 | : setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &opt, sizeof(opt)) | ||
273 | ? err(errno, "setsockopt failed on socket with fileno %d", server_fd) | ||
274 | : bind(server_fd, (struct sockaddr*) &address, sizeof(address)) | 272 | : bind(server_fd, (struct sockaddr*) &address, sizeof(address)) |
275 | ? err(errno, NULL) | 273 | ? err(errno, NULL) |
276 | : listen(server_fd, SOMAXCONN) | 274 | : listen(server_fd, SOMAXCONN) |