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 $ |
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> |
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 } |
144 else strcpy(logfile,"/var/log/jhttpd.log"); |
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); |
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 ); |
367 return out; 368} |