Skip to content
Snippets Groups Projects
Commit 95d08208 authored by David Hedbor's avatar David Hedbor
Browse files

Now compiles and works with 0.7 (httpd doesn't exactly work perfectly though).

Rev: bin/httpd.pike:1.3
Rev: bin/rsif:1.2
parent bb12ba29
No related branches found
No related tags found
No related merge requests found
#!/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 Hbinette as a demonstration of Pike
......@@ -8,7 +8,7 @@
#include <simulate.h>
inherit "/precompiled/port";
inherit Stdio.Port;
/* number of bytes to read for each write */
#define BLOCK 16060
......@@ -24,8 +24,8 @@ inherit "/precompiled/port";
program output_class=class
{
inherit "/precompiled/file" : socket;
inherit "/precompiled/file" : file;
inherit Stdio.File : socket;
inherit Stdio.File : file;
int offset=0;
......@@ -36,7 +36,7 @@ program output_class=class
file::seek(offset);
data=file::read(BLOCK);
if(strlen(data))
if(data && strlen(data))
{
written=socket::write(data);
if(written >= 0)
......
#!/usr/local/bin/pike
#include <simulate.h>
import Stdio;
int main(int argc, string *argv)
{
int i;
string file;
if(argc<4)
if(argc < 4)
{
perror("Usage: rsif <from> <to> <files>\n");
werror("Usage: rsif <from> <to> <files>\n");
return 1;
}
for(i=3; i<argc; i++)
for(i = 3; i < argc; i++)
{
string file_contents;
if(file_contents=read_bytes(argv[i]))
if(file_contents = read_bytes(argv[i]))
{
if(-1!=strstr(file_contents,argv[1]))
if(-1 != search(file_contents,argv[1]))
{
write("Processing "+argv[i]+".\n");
file_contents=replace(file_contents,argv[1],argv[2]);
write("Processing %s.\n", argv[i]);
file_contents = replace(file_contents,argv[1],argv[2]);
if( mv(argv[i],argv[i]+"~") )
if( mv(argv[i], argv[i]+"~") )
{
write_file(argv[i],file_contents);
}else{
write_file(argv[i], file_contents);
} else {
write("Failed to create backup file.\n");
}
}
}
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment