Deleted Added
full compact
simple_httpd.c (42714) simple_httpd.c (43939)
1/* simpleHTTPd (C) 1998 netSTOR Technologies, Inc. ("netSTOR")
2 FreeBSD port and additional work by Marc Nicholas <marc@netstor.com>
3 Based on work by:-
4 Thierry Leconte & Yury Shimanovsky
5 My Russian webserver writing friends :-)
6
7 This is an HTTP daemon that will serve up HTML, text files, JPEGs,
8 GIFs and do simple CGI work.
9
10 You may use this code for non-commercial distribution only. Commercial
11 distribution requires the express, written permission of netSTOR. No
12 warranty is implied or given -- use at your own risk!
13*/
14
15/*
16 * $Id: simple_httpd.c,v 1.1.1.1 1998/08/27 17:38:45 abial Exp $
1/*-
2 * SimpleHTTPd v1.0 - a very small, barebones HTTP server
3 *
4 * Copyright (c) 1998-1999 Marc Nicholas <marc@netstor.com>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $Id: simple_httpd.c,v 1.2.2.1 1999/02/05 12:21:41 abial Exp $
17 */
18
19#include <stdio.h>
20#include <unistd.h>
21#include <stdlib.h>
22#include <sys/stat.h>
23#include <sys/time.h>
24#include <sys/types.h>
25#include <time.h>
26#include <sys/socket.h>
27#include <netinet/in.h>
28#include <arpa/inet.h>
29#include <netdb.h>
30#include <fcntl.h>
31#include <string.h>
32#include <signal.h>
33#include <sys/wait.h>
29 */
30
31#include <stdio.h>
32#include <unistd.h>
33#include <stdlib.h>
34#include <sys/stat.h>
35#include <sys/time.h>
36#include <sys/types.h>
37#include <time.h>
38#include <sys/socket.h>
39#include <netinet/in.h>
40#include <arpa/inet.h>
41#include <netdb.h>
42#include <fcntl.h>
43#include <string.h>
44#include <signal.h>
45#include <sys/wait.h>
34#define LOGDIR "/var/log"
35
36int http_sock, con_sock;
37int http_port = 80;
38struct sockaddr_in source;
39char homedir[100];
40char *adate();
41struct hostent *hst;
42

--- 82 unchanged lines hidden (view full) ---

125 if (p=strstr(req,"\r")) *p=0;
126
127 if (geteuid())
128 {
129 strcpy(logfile,getenv("HOME"));
130 strcat(logfile,"/");
131 strcat(logfile,"jhttp.log");
132 }
46
47int http_sock, con_sock;
48int http_port = 80;
49struct sockaddr_in source;
50char homedir[100];
51char *adate();
52struct hostent *hst;
53

--- 82 unchanged lines hidden (view full) ---

136 if (p=strstr(req,"\r")) *p=0;
137
138 if (geteuid())
139 {
140 strcpy(logfile,getenv("HOME"));
141 strcat(logfile,"/");
142 strcat(logfile,"jhttp.log");
143 }
133 else strcpy(logfile, LOGDIR "/jhttpd.log");
144 else strcpy(logfile,"/var/log/jhttpd.log");
134
135 if ( access(logfile,W_OK))
136 {
137 lg=creat (logfile,O_WRONLY);
138 chmod (logfile,00600);
139 close(lg);
140 }
141

--- 203 unchanged lines hidden (view full) ---

345
346char *adate()
347{
348 static char out[50];
349 long now;
350 struct tm *t;
351 time(&now);
352 t = localtime(&now);
145
146 if ( access(logfile,W_OK))
147 {
148 lg=creat (logfile,O_WRONLY);
149 chmod (logfile,00600);
150 close(lg);
151 }
152

--- 203 unchanged lines hidden (view full) ---

356
357char *adate()
358{
359 static char out[50];
360 long now;
361 struct tm *t;
362 time(&now);
363 t = localtime(&now);
353
354 sprintf(out, "%4d/%02d/%02d %02d:%02d:%02d",
355 t->tm_year+1900, t->tm_mon+1, t->tm_mday,
356 t->tm_hour, t->tm_min, t->tm_sec );
364 sprintf(out, "%02d:%02d:%02d %02d/%02d/%02d",
365 t->tm_hour, t->tm_min, t->tm_sec,
366 t->tm_mday, t->tm_mon+1, t->tm_year );
357 return out;
358}
367 return out;
368}