tinyhttpd.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. diff -ur tinyhttpd-0.1.0/httpd.c tinyhttpd-0.1.0-patched/httpd.c
  2. --- tinyhttpd-0.1.0/httpd.c 2001-04-21 19:13:13.000000000 -0500
  3. +++ tinyhttpd-0.1.0-patched/httpd.c 2007-07-02 09:19:27.000000000 -0500
  4. @@ -4,14 +4,6 @@
  5. * CSE 4344 (Network concepts), Prof. Zeigler
  6. * University of Texas at Arlington
  7. */
  8. -/* This program compiles for Sparc Solaris 2.6.
  9. - * To compile for Linux:
  10. - * 1) Comment out the #include <pthread.h> line.
  11. - * 2) Comment out the line that defines the variable newthread.
  12. - * 3) Comment out the two lines that run pthread_create().
  13. - * 4) Uncomment the line that runs accept_request().
  14. - * 5) Remove -lsocket from the Makefile.
  15. - */
  16. #include <stdio.h>
  17. #include <sys/socket.h>
  18. #include <sys/types.h>
  19. @@ -22,7 +14,6 @@
  20. #include <strings.h>
  21. #include <string.h>
  22. #include <sys/stat.h>
  23. -#include <pthread.h>
  24. #include <sys/wait.h>
  25. #include <stdlib.h>
  26. @@ -30,7 +21,6 @@
  27. #define SERVER_STRING "Server: jdbhttpd/0.1.0\r\n"
  28. -void accept_request(int);
  29. void bad_request(int);
  30. void cat(int, FILE *);
  31. void cannot_execute(int);
  32. @@ -102,7 +92,7 @@
  33. }
  34. }
  35. - sprintf(path, "htdocs%s", url);
  36. + sprintf(path, "/var/www%s", url);
  37. if (path[strlen(path) - 1] == '/')
  38. strcat(path, "index.html");
  39. if (stat(path, &st) == -1) {
  40. @@ -475,11 +465,10 @@
  41. int main(void)
  42. {
  43. int server_sock = -1;
  44. - u_short port = 0;
  45. + u_short port = 80;
  46. int client_sock = -1;
  47. struct sockaddr_in client_name;
  48. int client_name_len = sizeof(client_name);
  49. - pthread_t newthread;
  50. server_sock = startup(&port);
  51. printf("httpd running on port %d\n", port);
  52. @@ -491,9 +480,7 @@
  53. &client_name_len);
  54. if (client_sock == -1)
  55. error_die("accept");
  56. - /* accept_request(client_sock); */
  57. - if (pthread_create(&newthread , NULL, accept_request, client_sock) != 0)
  58. - perror("pthread_create");
  59. + accept_request(client_sock);
  60. }
  61. close(server_sock);
  62. diff -ur tinyhttpd-0.1.0/Makefile tinyhttpd-0.1.0-patched/Makefile
  63. --- tinyhttpd-0.1.0/Makefile 2001-04-21 17:03:39.000000000 -0500
  64. +++ tinyhttpd-0.1.0-patched/Makefile 2007-07-02 10:29:41.000000000 -0500
  65. @@ -1,7 +1,7 @@
  66. all: httpd
  67. httpd: httpd.c
  68. - gcc -W -Wall -lsocket -lpthread -o httpd httpd.c
  69. + $(CC) $(CFLAGS) $(LDFLAGS) -W -Wall -lpthread -o httpd httpd.c
  70. clean:
  71. - rm httpd
  72. + rm -f httpd