pike.git / bin / httpd.pike

version» Context lines:

pike.git/bin/httpd.pike:1:   #!/usr/local/bin/pike    - /* $Id: httpd.pike,v 1.2 1997/05/31 22:03:38 grubba Exp $ */ + /* $Id: httpd.pike,v 1.3 1999/03/19 19:59:33 neotron Exp $ */      /* A very small httpd capable of fetching files only.    * Written by Fredrik Hübinette as a demonstration of Pike    */      #include <simulate.h>    - inherit "/precompiled/port"; + inherit Stdio.Port;      /* number of bytes to read for each write */   #define BLOCK 16060      /* Where do we have the html files ? */   #define BASE "/home/hubbe/pike/src/"      /* File to return when we can't find the file requested */   #define NOFILE "/home/hubbe/www/html/nofile.html"      /* Port to open */   #define PORT 1905      program output_class=class   { -  inherit "/precompiled/file" : socket; -  inherit "/precompiled/file" : file; +  inherit Stdio.File : socket; +  inherit Stdio.File : file;       int offset=0;       void write_callback()    {    int written;    string data;       file::seek(offset);    data=file::read(BLOCK); -  if(strlen(data)) +  if(data && strlen(data))    {    written=socket::write(data);    if(written >= 0)    {    offset+=written;    return;    }    perror("Error: "+socket::errno()+".\n");    }    destruct(this_object());