From: nishi Date: Fri, 1 Mar 2024 14:07:57 +0000 (+0000) Subject: formatting, and changed the url of git repo X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=fd96ba18416c03f61021385ee4372c845c0db383;p=libw3.git formatting, and changed the url of git repo git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@259 d27a3e52-49c5-7645-884c-6793ebffc270 --- diff --git a/Example/httpd/httpd.c b/Example/httpd/httpd.c index 73c4750..bbaf8e7 100644 --- a/Example/httpd/httpd.c +++ b/Example/httpd/httpd.c @@ -8,18 +8,18 @@ #include #include +#include #include +#include +#include +#include #include #include #include #include #include #include -#include -#include #include -#include -#include char* root = NULL; @@ -150,7 +150,7 @@ response : { if(path[strlen(path) - 1] == '/') { struct stat old_s = s; char* index = __W3_Concat(path, "index.html"); - if(stat(index, &s)){ + if(stat(index, &s)) { send(sock, "HTTP/1.1 200 OK\r\n", 17, 0); send(sock, "Connection: close\r\n", 19, 0); char* length = malloc(1025); @@ -328,7 +328,7 @@ response : { send(sock, "\r\n", 2, 0); if(strcasecmp(method, "HEAD") != 0) send(sock, html, strlen(html), 0); free(html); -out:; + out:; } else { send(sock, "HTTP/1.1 308 Permanent Redirect\r\n", 33, 0); send(sock, "Connection: close\r\n", 19, 0); @@ -497,7 +497,7 @@ int main(int argc, char** argv) { } if(root != NULL) free(root); root = __W3_Strdup(line + j + 1); - }else if(strcasecmp(line, "Port") == 0) { + } else if(strcasecmp(line, "Port") == 0) { if(!hasparam) { fprintf(stderr, "%s: config line %d, directive needs a parameter\n", argv[0], linenum); err++; @@ -561,50 +561,57 @@ int main(int argc, char** argv) { int exitcode = 0; int port = atoi(portstr); int server_socket; - if((server_socket = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)) < 0){ - return -1;goto exitnow; + if((server_socket = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)) < 0) { + return -1; + goto exitnow; } struct sockaddr_in6 server_address; - if((server_socket = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)) < 0){ - return -1;goto exitnow; + if((server_socket = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)) < 0) { + return -1; + goto exitnow; } int yes = 1; - if(setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0){ + if(setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) { close(server_socket); - return -1;goto exitnow; + return -1; + goto exitnow; } - if(setsockopt(server_socket, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes)) < 0){ + if(setsockopt(server_socket, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes)) < 0) { close(server_socket); - return 1;goto exitnow; + return 1; + goto exitnow; } int no = 0; - if(setsockopt(server_socket, IPPROTO_IPV6, IPV6_V6ONLY, &no, sizeof(no)) < 0){ + if(setsockopt(server_socket, IPPROTO_IPV6, IPV6_V6ONLY, &no, sizeof(no)) < 0) { close(server_socket); - return 1;goto exitnow; + return 1; + goto exitnow; } memset(&server_address, 0, sizeof(server_address)); server_address.sin6_family = AF_INET6; server_address.sin6_addr = in6addr_any; server_address.sin6_port = htons(port); - if(bind(server_socket, (struct sockaddr*)&server_address, sizeof(server_address)) < 0){ + if(bind(server_socket, (struct sockaddr*)&server_address, sizeof(server_address)) < 0) { close(server_socket); - return -1;goto exitnow; + return -1; + goto exitnow; } - if(listen(server_socket, 128) < 0){ + if(listen(server_socket, 128) < 0) { close(server_socket); - return -1;goto exitnow; + return -1; + goto exitnow; } signal(SIGCHLD, SIG_IGN); __W3_Debug("HTTPd", "Ready"); - while(1){ + while(1) { struct sockaddr_in claddr; int clen = sizeof(claddr); int sock = accept(server_socket, (struct sockaddr*)&claddr, &clen); pid_t p = fork(); - if(p == 0){ + if(p == 0) { http_handler(sock); _exit(-1); - }else{ + } else { close(sock); } } diff --git a/README b/README index 64e0648..73402c2 100644 --- a/README +++ b/README @@ -6,7 +6,7 @@ Main repository: http://sw.nishi.boats/sw/~nishi/libw3 Website: http://nishi.boats/libw3 Mirrors at: -1. https://github.com/j-eoeo/libw3 +1. https://github.com/nissmick/libw3 Do not send the pull requests to this! Just send me email. Example applications: diff --git a/W3Version.h.m4 b/W3Version.h.m4 index 301191d..e7bd535 100644 --- a/W3Version.h.m4 +++ b/W3Version.h.m4 @@ -6,7 +6,7 @@ extern "C" { #endif -#define LIBW3_VERSION "2.20B" \ +#define LIBW3_VERSION "2.20C" \ SUFFIX ifdef(`HTTP_SUPPORT', `#define LIBW3_HTTP_SUPPORT', `')